diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index 736d169ec6..df52343db2 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -71,10 +71,10 @@ 'browser/notification_presenter.h', 'browser/notification_presenter_mac.h', 'browser/notification_presenter_mac.mm', + 'browser/platform_notification_service_impl.cc', + 'browser/platform_notification_service_impl.h', 'browser/linux/notification_presenter_linux.h', 'browser/linux/notification_presenter_linux.cc', - 'browser/remote_debugging_server.cc', - 'browser/remote_debugging_server.h', 'browser/url_request_context_getter.cc', 'browser/url_request_context_getter.h', 'browser/views/inspectable_web_contents_view_views.h', diff --git a/brightray/browser/browser_client.cc b/brightray/browser/browser_client.cc index b391cffaf8..b884cdcdbf 100644 --- a/brightray/browser/browser_client.cc +++ b/brightray/browser/browser_client.cc @@ -8,7 +8,7 @@ #include "browser/browser_main_parts.h" #include "browser/devtools_manager_delegate.h" #include "browser/media/media_capture_devices_dispatcher.h" -#include "browser/notification_presenter.h" +#include "browser/platform_notification_service_impl.h" #include "base/base_paths.h" #include "base/path_service.h" @@ -39,14 +39,6 @@ BrowserContext* BrowserClient::browser_context() { return browser_main_parts_->browser_context(); } -NotificationPresenter* BrowserClient::notification_presenter() { -#if defined(OS_MACOSX) || defined(OS_LINUX) - if (!notification_presenter_) - notification_presenter_.reset(NotificationPresenter::Create()); -#endif - return notification_presenter_.get(); -} - BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts( const content::MainFunctionParams&) { return new BrowserMainParts; @@ -67,21 +59,14 @@ net::URLRequestContextGetter* BrowserClient::CreateRequestContext( return context->CreateRequestContext(protocol_handlers, protocol_interceptors.Pass()); } -void BrowserClient::ShowDesktopNotification( - const content::ShowDesktopNotificationHostMsgParams& params, - content::BrowserContext* browser_context, - int render_process_id, - scoped_ptr delegate, - base::Closure* cancel_callback) { - auto presenter = notification_presenter(); - if (presenter) - presenter->ShowNotification(params, delegate.Pass(), cancel_callback); -} - content::MediaObserver* BrowserClient::GetMediaObserver() { return MediaCaptureDevicesDispatcher::GetInstance(); } +content::PlatformNotificationService* BrowserClient::GetPlatformNotificationService() { + return PlatformNotificationServiceImpl::GetInstance(); +} + void BrowserClient::GetAdditionalAllowedSchemesForFileSystem( std::vector* additional_schemes) { additional_schemes->push_back(content::kChromeDevToolsScheme); diff --git a/brightray/browser/browser_client.h b/brightray/browser/browser_client.h index e3e256249d..fad326e10b 100644 --- a/brightray/browser/browser_client.h +++ b/brightray/browser/browser_client.h @@ -11,7 +11,6 @@ namespace brightray { class BrowserContext; class BrowserMainParts; -class NotificationPresenter; class BrowserClient : public content::ContentBrowserClient { public: @@ -22,7 +21,6 @@ class BrowserClient : public content::ContentBrowserClient { BrowserContext* browser_context(); BrowserMainParts* browser_main_parts() { return browser_main_parts_; } - NotificationPresenter* notification_presenter(); protected: // Subclasses should override this to provide their own BrowserMainParts @@ -41,20 +39,14 @@ class BrowserClient : public content::ContentBrowserClient { private: content::BrowserMainParts* CreateBrowserMainParts( const content::MainFunctionParams&) override; - void ShowDesktopNotification( - const content::ShowDesktopNotificationHostMsgParams& params, - content::BrowserContext* browser_context, - int render_process_id, - scoped_ptr delegate, - base::Closure* cancel_callback) override; content::MediaObserver* GetMediaObserver() override; + content::PlatformNotificationService* GetPlatformNotificationService() override; void GetAdditionalAllowedSchemesForFileSystem( std::vector* additional_schemes) override; base::FilePath GetDefaultDownloadDirectory() override; content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override; BrowserMainParts* browser_main_parts_; - scoped_ptr notification_presenter_; DISALLOW_COPY_AND_ASSIGN(BrowserClient); }; diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index cb374ff4c9..6d2a378be8 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -99,6 +99,11 @@ base::FilePath BrowserContext::GetPath() const { return path_; } +scoped_ptr BrowserContext::CreateZoomLevelDelegate( + const base::FilePath& partition_path) { + return scoped_ptr(); +} + bool BrowserContext::IsOffTheRecord() const { return false; } diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index 90cefbcf79..ec1dd095b2 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -46,6 +46,8 @@ class BrowserContext : public content::BrowserContext, void RegisterInternalPrefs(PrefRegistrySimple* pref_registry); + scoped_ptr CreateZoomLevelDelegate( + const base::FilePath& partition_path) override; bool IsOffTheRecord() const override; net::URLRequestContextGetter* GetRequestContext() override; net::URLRequestContextGetter* GetRequestContextForRenderProcess( diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index 351bee9c98..de938eacd9 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -5,11 +5,12 @@ #include "browser/browser_main_parts.h" #include "browser/browser_context.h" -#include "browser/remote_debugging_server.h" +#include "browser/devtools_manager_delegate.h" #include "browser/web_ui_controller_factory.h" #include "base/command_line.h" #include "base/strings/string_number_conversions.h" +#include "content/public/browser/devtools_http_handler.h" #include "content/public/common/content_switches.h" #include "net/proxy/proxy_resolver_v8.h" @@ -125,16 +126,9 @@ void BrowserMainParts::PreMainMessageLoopRun() { web_ui_controller_factory_.get()); // --remote-debugging-port - base::CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(switches::kRemoteDebuggingPort)) { - std::string port_str = command_line->GetSwitchValueASCII(switches::kRemoteDebuggingPort); - int port; - if (base::StringToInt(port_str, &port) && port >= 0 && port < 65535) - remote_debugging_server_.reset( - new RemoteDebuggingServer("127.0.0.1", static_cast(port))); - else - DLOG(WARNING) << "Invalid http debugger port number " << port; - } + auto command_line = base::CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kRemoteDebuggingPort)) + devtools_http_handler_.reset(DevToolsManagerDelegate::CreateHttpHandler()); } void BrowserMainParts::PostMainMessageLoopRun() { diff --git a/brightray/browser/browser_main_parts.h b/brightray/browser/browser_main_parts.h index 3e52af4bd5..59674ef2e5 100644 --- a/brightray/browser/browser_main_parts.h +++ b/brightray/browser/browser_main_parts.h @@ -9,6 +9,10 @@ #include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_main_parts.h" +namespace content { +class DevToolsHttpHandler; +} + #if defined(TOOLKIT_VIEWS) namespace brightray { class ViewsDelegate; @@ -25,7 +29,6 @@ namespace brightray { class BrowserContext; class WebUIControllerFactory; -class RemoteDebuggingServer; class BrowserMainParts : public content::BrowserMainParts { public: @@ -58,7 +61,7 @@ class BrowserMainParts : public content::BrowserMainParts { scoped_ptr browser_context_; scoped_ptr web_ui_controller_factory_; - scoped_ptr remote_debugging_server_; + scoped_ptr devtools_http_handler_; #if defined(TOOLKIT_VIEWS) scoped_ptr views_delegate_; diff --git a/brightray/browser/devtools_contents_resizing_strategy.h b/brightray/browser/devtools_contents_resizing_strategy.h index 806d78a715..9c82c060b1 100644 --- a/brightray/browser/devtools_contents_resizing_strategy.h +++ b/brightray/browser/devtools_contents_resizing_strategy.h @@ -6,9 +6,9 @@ #define BRIGHTRAY_BROWSER_DEVTOOLS_CONTENTS_RESIZING_STRATEGY_H_ #include "base/basictypes.h" -#include "ui/gfx/insets.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/size.h" +#include "ui/gfx/geometry/insets.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/geometry/size.h" // This class knows how to resize both DevTools and inspected WebContents // inside a browser window hierarchy. diff --git a/brightray/browser/devtools_embedder_message_dispatcher.h b/brightray/browser/devtools_embedder_message_dispatcher.h index 1b0bf9e3a0..defe16c1f4 100644 --- a/brightray/browser/devtools_embedder_message_dispatcher.h +++ b/brightray/browser/devtools_embedder_message_dispatcher.h @@ -9,9 +9,9 @@ #include #include "base/callback.h" -#include "ui/gfx/insets.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/size.h" +#include "ui/gfx/geometry/insets.h" +#include "ui/gfx/geometry/rect.h" +#include "ui/gfx/geometry/size.h" namespace base { class ListValue; diff --git a/brightray/browser/devtools_manager_delegate.cc b/brightray/browser/devtools_manager_delegate.cc index 2165b9c852..014a3d825c 100644 --- a/brightray/browser/devtools_manager_delegate.cc +++ b/brightray/browser/devtools_manager_delegate.cc @@ -24,6 +24,7 @@ #include "content/public/common/url_constants.h" #include "content/public/common/user_agent.h" #include "net/socket/tcp_server_socket.h" +#include "net/socket/stream_socket.h" #include "ui/base/resource/resource_bundle.h" using content::DevToolsAgentHost; @@ -65,7 +66,7 @@ class TCPServerSocketFactory scoped_ptr CreateSocketFactory() { - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + auto& command_line = *base::CommandLine::ForCurrentProcess(); // See if the user specified a port on the command line (useful for // automation). If not, use an ephemeral port by specifying 0. int port = 0; @@ -151,8 +152,7 @@ class DevToolsDelegate : public content::DevToolsHttpHandlerDelegate { std::string GetDiscoveryPageHTML() override; bool BundlesFrontendResources() override; base::FilePath GetDebugFrontendDir() override; - scoped_ptr CreateSocketForTethering( - net::StreamListenSocket::Delegate* delegate, + scoped_ptr CreateSocketForTethering( std::string* name) override; private: @@ -178,11 +178,9 @@ base::FilePath DevToolsDelegate::GetDebugFrontendDir() { return base::FilePath(); } -scoped_ptr -DevToolsDelegate::CreateSocketForTethering( - net::StreamListenSocket::Delegate* delegate, +scoped_ptr DevToolsDelegate::CreateSocketForTethering( std::string* name) { - return scoped_ptr(); + return scoped_ptr(); } } // namespace diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 4fae3a1ae1..88ed18dc1f 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -162,7 +162,7 @@ void InspectableWebContentsImpl::ShowDevTools() { agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get()); frontend_host_.reset(content::DevToolsFrontendHost::Create( - web_contents_->GetRenderViewHost(), this)); + web_contents_->GetMainFrame(), this)); agent_host_->AttachClient(this); GURL devtools_url(base::StringPrintf(kChromeUIDevToolsURL, can_dock_ ? "true" : "")); @@ -243,7 +243,7 @@ void InspectableWebContentsImpl::AppendToFile( void InspectableWebContentsImpl::RequestFileSystems() { devtools_web_contents()->GetMainFrame()->ExecuteJavaScript( - base::ASCIIToUTF16("InspectorFrontendAPI.fileSystemsLoaded([])")); + base::ASCIIToUTF16("DevToolsAPI.fileSystemsLoaded([])")); } void InspectableWebContentsImpl::AddFileSystem() { @@ -296,7 +296,7 @@ void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(const std::st std::string error = embedder_message_dispatcher_->Dispatch(method, ¶ms); if (id) { std::string ack = base::StringPrintf( - "InspectorFrontendAPI.embedderMessageAck(%d, \"%s\");", id, error.c_str()); + "DevToolsAPI.embedderMessageAck(%d, \"%s\");", id, error.c_str()); devtools_web_contents()->GetMainFrame()->ExecuteJavaScript(base::UTF8ToUTF16(ack)); } } @@ -308,7 +308,7 @@ void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontendToBackend( void InspectableWebContentsImpl::DispatchProtocolMessage( content::DevToolsAgentHost* agent_host, const std::string& message) { - std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");"; + std::string code = "DevToolsAPI.dispatchMessage(" + message + ");"; base::string16 javascript = base::UTF8ToUTF16(code); web_contents()->GetMainFrame()->ExecuteJavaScript(javascript); } @@ -317,10 +317,11 @@ void InspectableWebContentsImpl::AgentHostClosed( content::DevToolsAgentHost* agent_host, bool replaced) { } -void InspectableWebContentsImpl::AboutToNavigateRenderView( - content::RenderViewHost* render_view_host) { - frontend_host_.reset(content::DevToolsFrontendHost::Create( - render_view_host, this)); +void InspectableWebContentsImpl::AboutToNavigateRenderFrame( + content::RenderFrameHost* new_host) { + if (new_host->GetParent()) + return; + frontend_host_.reset(content::DevToolsFrontendHost::Create(new_host, this)); } void InspectableWebContentsImpl::DidFinishLoad(content::RenderFrameHost* render_frame_host, @@ -355,6 +356,7 @@ bool InspectableWebContentsImpl::AddMessageToConsole( bool InspectableWebContentsImpl::ShouldCreateWebContents( content::WebContents* web_contents, int route_id, + int main_frame_route_id, WindowContainerType window_container_type, const base::string16& frame_name, const GURL& target_url, diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index 9c80be071d..7e249e8aa6 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -15,7 +15,7 @@ #include "content/public/browser/devtools_frontend_host.h" #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_observer.h" -#include "ui/gfx/rect.h" +#include "ui/gfx/geometry/rect.h" class PrefRegistrySimple; @@ -104,7 +104,7 @@ class InspectableWebContentsImpl : bool replaced) override; // content::WebContentsObserver: - void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) override; + void AboutToNavigateRenderFrame(content::RenderFrameHost* new_host) override; void DidFinishLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url) override; void WebContentsDestroyed() override; @@ -118,6 +118,7 @@ class InspectableWebContentsImpl : bool ShouldCreateWebContents( content::WebContents* web_contents, int route_id, + int main_frame_route_id, WindowContainerType window_container_type, const base::string16& frame_name, const GURL& target_url, diff --git a/brightray/browser/linux/notification_presenter_linux.cc b/brightray/browser/linux/notification_presenter_linux.cc index 193e80c76d..a3d72bc8fa 100644 --- a/brightray/browser/linux/notification_presenter_linux.cc +++ b/brightray/browser/linux/notification_presenter_linux.cc @@ -9,7 +9,7 @@ #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "content/public/browser/desktop_notification_delegate.h" -#include "content/public/common/show_desktop_notification_params.h" +#include "content/public/common/platform_notification_data.h" #include "common/application_info.h" namespace brightray { @@ -51,11 +51,11 @@ NotificationPresenterLinux::~NotificationPresenterLinux() { } void NotificationPresenterLinux::ShowNotification( - const content::ShowDesktopNotificationHostMsgParams& params, + const content::PlatformNotificationData& data, scoped_ptr delegate_ptr, base::Closure* cancel_callback) { - std::string title = base::UTF16ToUTF8(params.title); - std::string body = base::UTF16ToUTF8(params.body); + std::string title = base::UTF16ToUTF8(data.title); + std::string body = base::UTF16ToUTF8(data.body); NotifyNotification* notification = notify_notification_new(title.c_str(), body.c_str(), nullptr); content::DesktopNotificationDelegate* delegate = delegate_ptr.release(); diff --git a/brightray/browser/linux/notification_presenter_linux.h b/brightray/browser/linux/notification_presenter_linux.h index 6701d399c4..384e2d2f8c 100644 --- a/brightray/browser/linux/notification_presenter_linux.h +++ b/brightray/browser/linux/notification_presenter_linux.h @@ -25,8 +25,8 @@ class NotificationPresenterLinux : public NotificationPresenter { private: // NotificationPresenter: - virtual void ShowNotification( - const content::ShowDesktopNotificationHostMsgParams&, + void ShowNotification( + const content::PlatformNotificationData&, scoped_ptr delegate, base::Closure* cancel_callback) override; diff --git a/brightray/browser/media/media_stream_devices_controller.cc b/brightray/browser/media/media_stream_devices_controller.cc index b55e73844f..3d4f4cc332 100644 --- a/brightray/browser/media/media_stream_devices_controller.cc +++ b/brightray/browser/media/media_stream_devices_controller.cc @@ -51,7 +51,7 @@ bool MediaStreamDevicesController::TakeAction() { // Do special handling of desktop screen cast. if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE || request_.video_type == content::MEDIA_TAB_VIDEO_CAPTURE || - request_.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE || + request_.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE || request_.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE) { HandleUserMediaRequest(); return true; @@ -59,7 +59,7 @@ bool MediaStreamDevicesController::TakeAction() { // Deny the request if there is no device attached to the OS. if (!HasAnyAvailableDevice()) { - Deny(); + Deny(content::MEDIA_DEVICE_NO_HARDWARE); return true; } @@ -149,11 +149,11 @@ void MediaStreamDevicesController::Accept() { cb.Run(devices, content::MEDIA_DEVICE_OK, scoped_ptr()); } -void MediaStreamDevicesController::Deny() { +void MediaStreamDevicesController::Deny(content::MediaStreamRequestResult result) { content::MediaResponseCallback cb = callback_; callback_.Reset(); cb.Run(content::MediaStreamDevices(), - content::MEDIA_DEVICE_PERMISSION_DENIED, + result, scoped_ptr()); } @@ -168,9 +168,9 @@ void MediaStreamDevicesController::HandleUserMediaRequest() { devices.push_back(content::MediaStreamDevice( content::MEDIA_TAB_VIDEO_CAPTURE, "", "")); } - if (request_.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE) { + if (request_.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE) { devices.push_back(content::MediaStreamDevice( - content::MEDIA_LOOPBACK_AUDIO_CAPTURE, "loopback", "System Audio")); + content::MEDIA_DESKTOP_AUDIO_CAPTURE, "loopback", "System Audio")); } if (request_.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE) { content::DesktopMediaID screen_id; diff --git a/brightray/browser/media/media_stream_devices_controller.h b/brightray/browser/media/media_stream_devices_controller.h index e77af47702..47aacfb66b 100644 --- a/brightray/browser/media/media_stream_devices_controller.h +++ b/brightray/browser/media/media_stream_devices_controller.h @@ -23,7 +23,7 @@ class MediaStreamDevicesController { // Explicitly accept or deny the request. void Accept(); - void Deny(); + void Deny(content::MediaStreamRequestResult result); private: // Handle the request of desktop or tab screen cast. diff --git a/brightray/browser/network_delegate.cc b/brightray/browser/network_delegate.cc index ec019a5f28..a065a6ebf0 100644 --- a/brightray/browser/network_delegate.cc +++ b/brightray/browser/network_delegate.cc @@ -21,6 +21,15 @@ int NetworkDelegate::OnBeforeURLRequest( return net::OK; } +void NetworkDelegate::OnResolveProxy(const GURL& url, + int load_flags, + const net::ProxyService& proxy_service, + net::ProxyInfo* result) { +} + +void NetworkDelegate::OnProxyFallback(const net::ProxyServer& bad_proxy, int net_error) { +} + int NetworkDelegate::OnBeforeSendHeaders( net::URLRequest* request, const net::CompletionCallback& callback, @@ -28,6 +37,11 @@ int NetworkDelegate::OnBeforeSendHeaders( return net::OK; } +void NetworkDelegate::OnBeforeSendProxyHeaders(net::URLRequest* request, + const net::ProxyInfo& proxy_info, + net::HttpRequestHeaders* headers) { +} + void NetworkDelegate::OnSendHeaders( net::URLRequest* request, const net::HttpRequestHeaders& headers) { @@ -92,10 +106,17 @@ bool NetworkDelegate::OnCanThrottleRequest( return false; } -int NetworkDelegate::OnBeforeSocketStreamConnect( - net::SocketStream* socket, - const net::CompletionCallback& callback) { - return net::OK; +bool NetworkDelegate::OnCanEnablePrivacyMode( + const GURL& url, + const GURL& first_party_for_cookies) const { + return false; +} + +bool NetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( + const net::URLRequest& request, + const GURL& target_url, + const GURL& referrer_url) const { + return false; } } // namespace brightray diff --git a/brightray/browser/network_delegate.h b/brightray/browser/network_delegate.h index 2279b3c981..fcfbdbb892 100644 --- a/brightray/browser/network_delegate.h +++ b/brightray/browser/network_delegate.h @@ -15,46 +15,57 @@ class NetworkDelegate : public net::NetworkDelegate { virtual ~NetworkDelegate(); protected: - virtual int OnBeforeURLRequest(net::URLRequest* request, - const net::CompletionCallback& callback, - GURL* new_url) override; - virtual int OnBeforeSendHeaders(net::URLRequest* request, - const net::CompletionCallback& callback, - net::HttpRequestHeaders* headers) override; - virtual void OnSendHeaders(net::URLRequest* request, - const net::HttpRequestHeaders& headers) override; - virtual int OnHeadersReceived( + int OnBeforeURLRequest(net::URLRequest* request, + const net::CompletionCallback& callback, + GURL* new_url) override; + void OnResolveProxy(const GURL& url, + int load_flags, + const net::ProxyService& proxy_service, + net::ProxyInfo* result) override; + void OnProxyFallback(const net::ProxyServer& bad_proxy, int net_error) override; + int OnBeforeSendHeaders(net::URLRequest* request, + const net::CompletionCallback& callback, + net::HttpRequestHeaders* headers) override; + void OnBeforeSendProxyHeaders(net::URLRequest* request, + const net::ProxyInfo& proxy_info, + net::HttpRequestHeaders* headers) override; + void OnSendHeaders(net::URLRequest* request, + const net::HttpRequestHeaders& headers) override; + int OnHeadersReceived( net::URLRequest* request, const net::CompletionCallback& callback, const net::HttpResponseHeaders* original_response_headers, scoped_refptr* override_response_headers, GURL* allowed_unsafe_redirect_url) override; - virtual void OnBeforeRedirect(net::URLRequest* request, - const GURL& new_location) override; - virtual void OnResponseStarted(net::URLRequest* request) override; - virtual void OnRawBytesRead(const net::URLRequest& request, - int bytes_read) override; - virtual void OnCompleted(net::URLRequest* request, bool started) override; - virtual void OnURLRequestDestroyed(net::URLRequest* request) override; - virtual void OnPACScriptError(int line_number, - const base::string16& error) override; - virtual AuthRequiredResponse OnAuthRequired( + void OnBeforeRedirect(net::URLRequest* request, + const GURL& new_location) override; + void OnResponseStarted(net::URLRequest* request) override; + void OnRawBytesRead(const net::URLRequest& request, + int bytes_read) override; + void OnCompleted(net::URLRequest* request, bool started) override; + void OnURLRequestDestroyed(net::URLRequest* request) override; + void OnPACScriptError(int line_number, + const base::string16& error) override; + AuthRequiredResponse OnAuthRequired( net::URLRequest* request, const net::AuthChallengeInfo& auth_info, const AuthCallback& callback, net::AuthCredentials* credentials) override; - virtual bool OnCanGetCookies(const net::URLRequest& request, - const net::CookieList& cookie_list) override; - virtual bool OnCanSetCookie(const net::URLRequest& request, - const std::string& cookie_line, - net::CookieOptions* options) override; - virtual bool OnCanAccessFile(const net::URLRequest& request, - const base::FilePath& path) const override; - virtual bool OnCanThrottleRequest( - const net::URLRequest& request) const override; - virtual int OnBeforeSocketStreamConnect( - net::SocketStream* stream, - const net::CompletionCallback& callback) override; + bool OnCanGetCookies(const net::URLRequest& request, + const net::CookieList& cookie_list) override; + bool OnCanSetCookie(const net::URLRequest& request, + const std::string& cookie_line, + net::CookieOptions* options) override; + bool OnCanAccessFile(const net::URLRequest& request, + const base::FilePath& path) const override; + bool OnCanThrottleRequest(const net::URLRequest& request) const override; + bool OnCanEnablePrivacyMode( + const GURL& url, + const GURL& first_party_for_cookies) const override; + bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( + const net::URLRequest& request, + const GURL& target_url, + const GURL& referrer_url) const override; private: DISALLOW_COPY_AND_ASSIGN(NetworkDelegate); diff --git a/brightray/browser/notification_presenter.h b/brightray/browser/notification_presenter.h index 6c7def322a..ad17cdb3c5 100644 --- a/brightray/browser/notification_presenter.h +++ b/brightray/browser/notification_presenter.h @@ -6,7 +6,7 @@ namespace content { class DesktopNotificationDelegate; -struct ShowDesktopNotificationHostMsgParams; +struct PlatformNotificationData; } namespace brightray { @@ -18,7 +18,7 @@ class NotificationPresenter { static NotificationPresenter* Create(); virtual void ShowNotification( - const content::ShowDesktopNotificationHostMsgParams&, + const content::PlatformNotificationData&, scoped_ptr delegate, base::Closure* cancel_callback) = 0; }; diff --git a/brightray/browser/notification_presenter_mac.h b/brightray/browser/notification_presenter_mac.h index 508ad315f0..fd9dd737d9 100644 --- a/brightray/browser/notification_presenter_mac.h +++ b/brightray/browser/notification_presenter_mac.h @@ -20,8 +20,9 @@ class NotificationPresenterMac : public NotificationPresenter { NotificationPresenterMac(); ~NotificationPresenterMac(); - virtual void ShowNotification( - const content::ShowDesktopNotificationHostMsgParams&, + // NotificationPresenter: + void ShowNotification( + const content::PlatformNotificationData&, scoped_ptr delegate, base::Closure* cancel_callback) override; diff --git a/brightray/browser/notification_presenter_mac.mm b/brightray/browser/notification_presenter_mac.mm index 78e3cc2fd4..f0a08d7597 100644 --- a/brightray/browser/notification_presenter_mac.mm +++ b/brightray/browser/notification_presenter_mac.mm @@ -8,8 +8,8 @@ #include "base/bind.h" #include "base/stl_util.h" #include "base/strings/sys_string_conversions.h" +#include "content/public/common/platform_notification_data.h" #include "content/public/browser/desktop_notification_delegate.h" -#include "content/public/common/show_desktop_notification_params.h" #import @@ -40,12 +40,12 @@ NotificationPresenterMac::~NotificationPresenterMac() { } void NotificationPresenterMac::ShowNotification( - const content::ShowDesktopNotificationHostMsgParams& params, + const content::PlatformNotificationData& data, scoped_ptr delegate, base::Closure* cancel_callback) { auto notification = [[NSUserNotification alloc] init]; - notification.title = base::SysUTF16ToNSString(params.title); - notification.informativeText = base::SysUTF16ToNSString(params.body); + notification.title = base::SysUTF16ToNSString(data.title); + notification.informativeText = base::SysUTF16ToNSString(data.body); notifications_map_[delegate.get()].reset(notification); [NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification]; diff --git a/brightray/browser/platform_notification_service_impl.cc b/brightray/browser/platform_notification_service_impl.cc new file mode 100644 index 0000000000..f47d385119 --- /dev/null +++ b/brightray/browser/platform_notification_service_impl.cc @@ -0,0 +1,64 @@ +// Copyright (c) 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE-CHROMIUM file. + +#include "browser/platform_notification_service_impl.h" + +#include "browser/notification_presenter.h" + +#include "content/public/browser/desktop_notification_delegate.h" + +namespace brightray { + +// static +PlatformNotificationServiceImpl* +PlatformNotificationServiceImpl::GetInstance() { + return Singleton::get(); +} + +PlatformNotificationServiceImpl::PlatformNotificationServiceImpl() {} +PlatformNotificationServiceImpl::~PlatformNotificationServiceImpl() {} + +NotificationPresenter* PlatformNotificationServiceImpl::notification_presenter() { +#if defined(OS_MACOSX) || defined(OS_LINUX) + if (!notification_presenter_) + notification_presenter_.reset(NotificationPresenter::Create()); +#endif + return notification_presenter_.get(); +} + +blink::WebNotificationPermission PlatformNotificationServiceImpl::CheckPermission( + content::ResourceContext* resource_context, + const GURL& origin, + int render_process_id) { + return blink::WebNotificationPermissionAllowed; +} + +void PlatformNotificationServiceImpl::DisplayNotification( + content::BrowserContext* browser_context, + const GURL& origin, + const SkBitmap& icon, + const content::PlatformNotificationData& notification_data, + scoped_ptr delegate, + int render_process_id, + base::Closure* cancel_callback) { + auto presenter = notification_presenter(); + if (presenter) + presenter->ShowNotification(notification_data, delegate.Pass(), cancel_callback); +} + +void PlatformNotificationServiceImpl::DisplayPersistentNotification( + content::BrowserContext* browser_context, + int64 service_worker_registration_id, + const GURL& origin, + const SkBitmap& icon, + const content::PlatformNotificationData& notification_data, + int render_process_id) { +} + +void PlatformNotificationServiceImpl::ClosePersistentNotification( + content::BrowserContext* browser_context, + const std::string& persistent_notification_id) { +} + +} // namespace brightray diff --git a/brightray/browser/platform_notification_service_impl.h b/brightray/browser/platform_notification_service_impl.h new file mode 100644 index 0000000000..1a542bcc89 --- /dev/null +++ b/brightray/browser/platform_notification_service_impl.h @@ -0,0 +1,61 @@ +// Copyright (c) 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE-CHROMIUM file. + +#ifndef BROWSER_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ +#define BROWSER_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ + +#include "base/memory/singleton.h" +#include "content/public/browser/platform_notification_service.h" + +namespace brightray { + +class NotificationPresenter; + +class PlatformNotificationServiceImpl + : public content::PlatformNotificationService { + public: + // Returns the active instance of the service in the browser process. Safe to + // be called from any thread. + static PlatformNotificationServiceImpl* GetInstance(); + + NotificationPresenter* notification_presenter(); + + private: + friend struct DefaultSingletonTraits; + + PlatformNotificationServiceImpl(); + ~PlatformNotificationServiceImpl() override; + + // content::PlatformNotificationService: + virtual blink::WebNotificationPermission CheckPermission( + content::ResourceContext* resource_context, + const GURL& origin, + int render_process_id) override; + virtual void DisplayNotification( + content::BrowserContext* browser_context, + const GURL& origin, + const SkBitmap& icon, + const content::PlatformNotificationData& notification_data, + scoped_ptr delegate, + int render_process_id, + base::Closure* cancel_callback) override; + virtual void DisplayPersistentNotification( + content::BrowserContext* browser_context, + int64 service_worker_registration_id, + const GURL& origin, + const SkBitmap& icon, + const content::PlatformNotificationData& notification_data, + int render_process_id) override; + virtual void ClosePersistentNotification( + content::BrowserContext* browser_context, + const std::string& persistent_notification_id) override; + + scoped_ptr notification_presenter_; + + DISALLOW_COPY_AND_ASSIGN(PlatformNotificationServiceImpl); +}; + +} // namespace brightray + +#endif // BROWSER_PLATFORM_NOTIFICATION_SERVICE_IMPL_H_ diff --git a/brightray/browser/remote_debugging_server.cc b/brightray/browser/remote_debugging_server.cc deleted file mode 100644 index 9aa004c313..0000000000 --- a/brightray/browser/remote_debugging_server.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#include "browser/remote_debugging_server.h" - -#include "browser/devtools_manager_delegate.h" - -#include "base/files/file_util.h" -#include "content/public/browser/devtools_http_handler.h" -#include "net/socket/tcp_server_socket.h" - -namespace brightray { - -namespace { - -class TCPServerSocketFactory - : public content::DevToolsHttpHandler::ServerSocketFactory { - public: - TCPServerSocketFactory(const std::string& address, uint16 port, int backlog) - : content::DevToolsHttpHandler::ServerSocketFactory(address, port, backlog) {} - - private: - // content::DevToolsHttpHandler::ServerSocketFactory: - scoped_ptr Create() const override { - return scoped_ptr(new net::TCPServerSocket(NULL, net::NetLog::Source())); - } - - DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); -}; - -} // namespace - -RemoteDebuggingServer::RemoteDebuggingServer(const std::string& ip, uint16 port) { - scoped_ptr factory( - new TCPServerSocketFactory(ip, port, 1)); - devtools_http_handler_ = DevToolsManagerDelegate::CreateHttpHandler(); -} - -RemoteDebuggingServer::~RemoteDebuggingServer() { - devtools_http_handler_->Stop(); -} - -} // namespace brightray diff --git a/brightray/browser/remote_debugging_server.h b/brightray/browser/remote_debugging_server.h deleted file mode 100644 index 89faf65730..0000000000 --- a/brightray/browser/remote_debugging_server.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#ifndef BROWSER_REMOTE_DEBUGGING_SERVER_H_ -#define BROWSER_REMOTE_DEBUGGING_SERVER_H_ - -#include - -#include "base/basictypes.h" - -namespace content { -class DevToolsHttpHandler; -} - -namespace brightray { - -class RemoteDebuggingServer { - public: - RemoteDebuggingServer(const std::string& ip, uint16 port); - virtual ~RemoteDebuggingServer(); - - private: - content::DevToolsHttpHandler* devtools_http_handler_; - - DISALLOW_COPY_AND_ASSIGN(RemoteDebuggingServer); -}; - -} // namespace brightray - -#endif // BROWSER_REMOTE_DEBUGGING_SERVER_H_ diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index 5cafb8aed7..8a14293981 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -142,7 +142,7 @@ net::HostResolver* URLRequestContextGetter::host_resolver() { net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + auto& command_line = *base::CommandLine::ForCurrentProcess(); if (!url_request_context_.get()) { url_request_context_.reset(new net::URLRequestContext); network_delegate_.reset(delegate_->CreateNetworkDelegate()); diff --git a/brightray/browser/views/views_delegate.cc b/brightray/browser/views/views_delegate.cc index a1078d41cb..0d28ddcc32 100644 --- a/brightray/browser/views/views_delegate.cc +++ b/brightray/browser/views/views_delegate.cc @@ -54,6 +54,10 @@ HICON ViewsDelegate::GetDefaultWindowIcon() const { return LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(1 /* IDR_MAINFRAME */)); } +HICON ViewsDelegate::GetSmallWindowIcon() const { + return GetDefaultWindowIcon(); +} + bool ViewsDelegate::IsWindowInMetro(gfx::NativeWindow window) const { return false; } diff --git a/brightray/browser/views/views_delegate.h b/brightray/browser/views/views_delegate.h index 27d6420728..bd1e7bc2b6 100644 --- a/brightray/browser/views/views_delegate.h +++ b/brightray/browser/views/views_delegate.h @@ -36,6 +36,7 @@ class ViewsDelegate : public views::ViewsDelegate { #if defined(OS_WIN) virtual HICON GetDefaultWindowIcon() const override; + virtual HICON GetSmallWindowIcon() const override; virtual bool IsWindowInMetro(gfx::NativeWindow window) const override; #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) virtual gfx::ImageSkia* GetDefaultWindowIcon() const override; diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 3f108160ed..78ddaee215 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 3f108160eded696b3e843c2fbb4e5e2ac696555e +Subproject commit 78ddaee2158886da53d0801db572be38230fd814