diff --git a/brightray/.gitignore b/brightray/.gitignore index 3f04a5e2f1b3..859306a729e5 100644 --- a/brightray/.gitignore +++ b/brightray/.gitignore @@ -2,6 +2,8 @@ /brightray.sdf /brightray.sln /brightray.vcxproj* +/brightray.suo +/brightray.v12.suo /brightray.xcodeproj/ /build/ diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index 8dd2a64ce089..d7ae15b9ffc2 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -12,17 +12,21 @@ 'include_dirs': [ '.', '<(libchromiumcontent_include_dir)', - '<(libchromiumcontent_include_dir)/third_party/skia/include/config', + '<(libchromiumcontent_include_dir)/skia/config', '<(libchromiumcontent_include_dir)/third_party/skia/include/core', + '<(libchromiumcontent_include_dir)/third_party/WebKit', + '<(libchromiumcontent_library_dir)/gen', ], 'direct_dependent_settings': { 'include_dirs': [ + '.', '..', '<(libchromiumcontent_include_dir)', - '<(libchromiumcontent_include_dir)/third_party/skia/include/config', - # For SkMatrix.h. + '<(libchromiumcontent_include_dir)/skia/config', '<(libchromiumcontent_include_dir)/third_party/skia/include/core', '<(libchromiumcontent_include_dir)/third_party/icu/source/common', + '<(libchromiumcontent_include_dir)/third_party/WebKit', + '<(libchromiumcontent_library_dir)/gen', ], }, 'sources': [ @@ -113,6 +117,7 @@ 'link_settings': { 'libraries': [ '<(brightray_source_root)/<(libchromiumcontent_library_dir)/base_static.lib', + '<(brightray_source_root)/<(libchromiumcontent_library_dir)/chromiumviews.lib', '<(brightray_source_root)/<(libchromiumcontent_library_dir)/chromiumcontent.dll.lib', '<(brightray_source_root)/<(libchromiumcontent_library_dir)/sandbox_static.lib', ], diff --git a/brightray/brightray.gypi b/brightray/brightray.gypi index daf5f2737cf5..b73a7ea07651 100644 --- a/brightray/brightray.gypi +++ b/brightray/brightray.gypi @@ -72,11 +72,21 @@ 'VCLinkerTool': { 'AdditionalDependencies': [ 'advapi32.lib', + 'dwmapi.lib', + 'gdi32.lib', + 'oleacc.lib', 'user32.lib', ], }, }, 'conditions': [ + ['OS=="win"', { + 'defines': [ + 'USE_AURA', + 'VIEWS_IMPLEMENTATION', + 'WEBVIEW_IMPLEMENTATION', + ], + }], ['OS not in ["mac", "win"]', { 'defines': [ 'USE_X11', diff --git a/brightray/browser/browser_client.cc b/brightray/browser/browser_client.cc index 82c0d7acb5f0..fabd51cc74cd 100644 --- a/brightray/browser/browser_client.cc +++ b/brightray/browser/browser_client.cc @@ -56,9 +56,10 @@ content::BrowserMainParts* BrowserClient::CreateBrowserMainParts( net::URLRequestContextGetter* BrowserClient::CreateRequestContext( content::BrowserContext* browser_context, - content::ProtocolHandlerMap* protocol_handlers) { + content::ProtocolHandlerMap* protocol_handlers, + content::ProtocolHandlerScopedVector protocol_interceptors) { auto context = static_cast(browser_context); - return context->CreateRequestContext(protocol_handlers); + return context->CreateRequestContext(protocol_handlers, protocol_interceptors.Pass()); } void BrowserClient::ShowDesktopNotification( diff --git a/brightray/browser/browser_client.h b/brightray/browser/browser_client.h index 41a3861f61f2..42a7380a63c3 100644 --- a/brightray/browser/browser_client.h +++ b/brightray/browser/browser_client.h @@ -34,7 +34,9 @@ class BrowserClient : public content::ContentBrowserClient { // Subclasses that override this (e.g., to provide their own protocol // handlers) should call this implementation after doing their own work. virtual net::URLRequestContextGetter* CreateRequestContext( - content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE; + content::BrowserContext* browser_context, + content::ProtocolHandlerMap* protocol_handlers, + content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE; private: virtual content::BrowserMainParts* CreateBrowserMainParts( diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 4970530d7bff..d82f4bc256ed 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -16,7 +16,7 @@ #include "base/prefs/json_pref_store.h" #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" -#include "base/prefs/pref_service_builder.h" +#include "base/prefs/pref_service_factory.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/resource_context.h" #include "content/public/browser/storage_partition.h" @@ -76,8 +76,8 @@ void BrowserContext::Initialize() { path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); - PrefServiceBuilder builder; - builder.WithUserFilePrefs(prefs_path, + base::PrefServiceFactory prefs_factory; + prefs_factory.SetUserPrefsFile(prefs_path, JsonPrefStore::GetTaskRunnerForFile( prefs_path, content::BrowserThread::GetBlockingPool())); @@ -85,7 +85,7 @@ void BrowserContext::Initialize() { RegisterInternalPrefs(registry); RegisterPrefs(registry); - prefs_.reset(builder.Create(registry)); + prefs_ = prefs_factory.Create(registry); } BrowserContext::~BrowserContext() { @@ -99,7 +99,8 @@ void BrowserContext::RegisterInternalPrefs(PrefRegistrySimple* registry) { } net::URLRequestContextGetter* BrowserContext::CreateRequestContext( - content::ProtocolHandlerMap* protocol_handlers) { + content::ProtocolHandlerMap* protocol_handlers, + content::ProtocolHandlerScopedVector protocol_interceptors) { DCHECK(!url_request_getter_); auto io_loop = content::BrowserThread::UnsafeGetMessageLoopForThread( content::BrowserThread::IO); @@ -110,7 +111,8 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext( io_loop, file_loop, base::Bind(&BrowserContext::CreateNetworkDelegate, base::Unretained(this)), - protocol_handlers); + protocol_handlers, + protocol_interceptors.Pass()); resource_context_->set_url_request_context_getter(url_request_getter_.get()); return url_request_getter_.get(); } @@ -153,14 +155,36 @@ net::URLRequestContextGetter* return GetRequestContext(); } -void BrowserContext::RequestMIDISysExPermission( +void BrowserContext::RequestMidiSysExPermission( int render_process_id, int render_view_id, + int bridge_id, const GURL& requesting_frame, - const MIDISysExPermissionCallback& callback) { + bool user_gesture, + const MidiSysExPermissionCallback& callback) { callback.Run(false); } +void BrowserContext::CancelMidiSysExPermissionRequest( + int render_process_id, + int render_view_id, + int bridge_id, + const GURL& requesting_frame) { +} + +void BrowserContext::RequestProtectedMediaIdentifierPermission( + int render_process_id, + int render_view_id, + int bridge_id, + int group_id, + const GURL& requesting_frame, + const ProtectedMediaIdentifierPermissionCallback& callback) { + callback.Run(false); +} + +void BrowserContext::CancelProtectedMediaIdentifierPermissionRequests(int group_id) { +} + content::ResourceContext* BrowserContext::GetResourceContext() { return resource_context_.get(); } diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index b92deb75c574..a43d2380da10 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -25,7 +25,8 @@ class BrowserContext : public content::BrowserContext { virtual void Initialize(); net::URLRequestContextGetter* CreateRequestContext( - content::ProtocolHandlerMap*); + content::ProtocolHandlerMap* protocol_handlers, + content::ProtocolHandlerScopedVector protocol_interceptors); PrefService* prefs() { return prefs_.get(); } @@ -54,11 +55,26 @@ class BrowserContext : public content::BrowserContext { virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition( const base::FilePath& partition_path, bool in_memory); - virtual void RequestMIDISysExPermission( + virtual void RequestMidiSysExPermission( int render_process_id, int render_view_id, + int bridge_id, const GURL& requesting_frame, - const MIDISysExPermissionCallback&) OVERRIDE; + bool user_gesture, + const MidiSysExPermissionCallback& callback) OVERRIDE; + virtual void CancelMidiSysExPermissionRequest( + int render_process_id, + int render_view_id, + int bridge_id, + const GURL& requesting_frame) OVERRIDE; + virtual void RequestProtectedMediaIdentifierPermission( + int render_process_id, + int render_view_id, + int bridge_id, + int group_id, + const GURL& requesting_frame, + const ProtectedMediaIdentifierPermissionCallback& callback) OVERRIDE; + virtual void CancelProtectedMediaIdentifierPermissionRequests(int group_id) OVERRIDE; virtual content::ResourceContext* GetResourceContext() OVERRIDE; virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index 8601b0426cdb..ceee0d51e6a3 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -7,6 +7,8 @@ #include "browser/browser_context.h" #include "browser/web_ui_controller_factory.h" #include "net/proxy/proxy_resolver_v8.h" +#include "ui/gfx/screen.h" +#include "ui/views/widget/desktop_aura/desktop_screen.h" namespace brightray { @@ -24,6 +26,10 @@ void BrowserMainParts::PreMainMessageLoopRun() { new WebUIControllerFactory(browser_context_.get())); content::WebUIControllerFactory::RegisterFactory( web_ui_controller_factory_.get()); + +#if defined(OS_WIN) + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); +#endif } void BrowserMainParts::PostMainMessageLoopRun() { diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 1ccb4e1054d4..739acf44ecb1 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -117,7 +117,7 @@ void InspectableWebContentsImpl::UpdateFrontendDockSide() { auto javascript = base::StringPrintf( "InspectorFrontendAPI.setDockSide(\"%s\")", dock_side_.c_str()); devtools_web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame( - string16(), ASCIIToUTF16(javascript)); + base::string16(), base::ASCIIToUTF16(javascript)); } void InspectableWebContentsImpl::ActivateWindow() { diff --git a/brightray/browser/media/media_capture_devices_dispatcher.cc b/brightray/browser/media/media_capture_devices_dispatcher.cc index eb3e6731a27f..65ea4b94be9c 100644 --- a/brightray/browser/media/media_capture_devices_dispatcher.cc +++ b/brightray/browser/media/media_capture_devices_dispatcher.cc @@ -6,8 +6,7 @@ #include "base/logging.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/media_devices_monitor.h" -#include "content/public/common/desktop_media_id.h" +#include "content/public/browser/media_capture_devices.h" #include "content/public/common/media_stream_request.h" namespace brightray { @@ -30,6 +29,11 @@ const content::MediaStreamDevice* FindDeviceWithId( return NULL; } +const MediaStreamDevices& EmptyDevices() { + static MediaStreamDevices* devices = new MediaStreamDevices; + return *devices; +} + } // namespace MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { @@ -37,8 +41,7 @@ MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { } MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() - : devices_enumerated_(false), - is_device_enumeration_disabled_(false) { + : is_device_enumeration_disabled_(false) { // MediaCaptureDevicesDispatcher is a singleton. It should be created on // UI thread. DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -49,21 +52,17 @@ MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {} const MediaStreamDevices& MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!is_device_enumeration_disabled_ && !devices_enumerated_) { - content::EnsureMonitorCaptureDevices(); - devices_enumerated_ = true; - } - return audio_devices_; + if (is_device_enumeration_disabled_) + return EmptyDevices(); + return content::MediaCaptureDevices::GetInstance()->GetAudioCaptureDevices(); } const MediaStreamDevices& MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!is_device_enumeration_disabled_ && !devices_enumerated_) { - content::EnsureMonitorCaptureDevices(); - devices_enumerated_ = true; - } - return video_devices_; + if (is_device_enumeration_disabled_) + return EmptyDevices(); + return content::MediaCaptureDevices::GetInstance()->GetVideoCaptureDevices(); } void MediaCaptureDevicesDispatcher::GetDefaultDevices( @@ -128,36 +127,33 @@ void MediaCaptureDevicesDispatcher::DisableDeviceEnumerationForTesting() { is_device_enumeration_disabled_ = true; } -void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged( - const content::MediaStreamDevices& devices) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread, - base::Unretained(this), devices)); +void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged() { } -void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged( - const content::MediaStreamDevices& devices) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind(&MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread, - base::Unretained(this), devices)); +void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged() { } void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged( int render_process_id, int render_view_id, int page_request_id, + const GURL& security_origin, const content::MediaStreamDevice& device, content::MediaRequestState state) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); } -void MediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged( - int render_process_id, int render_view_id, int stream_id, - bool is_playing, float power_dbfs, bool clipped) { +void MediaCaptureDevicesDispatcher::OnAudioStreamPlaying( + int render_process_id, + int render_frame_id, + int stream_id, + const ReadPowerAndClipCallback& power_read_callback) { +} + +void MediaCaptureDevicesDispatcher::OnAudioStreamStopped( + int render_process_id, + int render_frame_id, + int stream_id) { } void MediaCaptureDevicesDispatcher::OnCreatingAudioStream( @@ -166,18 +162,4 @@ void MediaCaptureDevicesDispatcher::OnCreatingAudioStream( DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); } -void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread( - const content::MediaStreamDevices& devices) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - devices_enumerated_ = true; - audio_devices_ = devices; -} - -void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread( - const content::MediaStreamDevices& devices) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - devices_enumerated_ = true; - video_devices_ = devices; -} - } // namespace brightray diff --git a/brightray/browser/media/media_capture_devices_dispatcher.h b/brightray/browser/media/media_capture_devices_dispatcher.h index d10c27df1bc3..3b29fae4701a 100644 --- a/brightray/browser/media/media_capture_devices_dispatcher.h +++ b/brightray/browser/media/media_capture_devices_dispatcher.h @@ -51,23 +51,24 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { void DisableDeviceEnumerationForTesting(); // Overridden from content::MediaObserver: - virtual void OnAudioCaptureDevicesChanged( - const content::MediaStreamDevices& devices) OVERRIDE; - virtual void OnVideoCaptureDevicesChanged( - const content::MediaStreamDevices& devices) OVERRIDE; + virtual void OnAudioCaptureDevicesChanged() OVERRIDE; + virtual void OnVideoCaptureDevicesChanged() OVERRIDE; virtual void OnMediaRequestStateChanged( int render_process_id, int render_view_id, int page_request_id, + const GURL& security_origin, const content::MediaStreamDevice& device, content::MediaRequestState state) OVERRIDE; - virtual void OnAudioStreamPlayingChanged( + virtual void OnAudioStreamPlaying( int render_process_id, - int render_view_id, + int render_frame_id, int stream_id, - bool is_playing, - float power_dBFS, - bool clipped) OVERRIDE; + const ReadPowerAndClipCallback& power_read_callback) OVERRIDE; + virtual void OnAudioStreamStopped( + int render_process_id, + int render_frame_id, + int stream_id) OVERRIDE; virtual void OnCreatingAudioStream(int render_process_id, int render_view_id) OVERRIDE; @@ -77,20 +78,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { MediaCaptureDevicesDispatcher(); virtual ~MediaCaptureDevicesDispatcher(); - // Called by the MediaObserver() functions, executed on UI thread. - void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices); - void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices); - - // A list of cached audio capture devices. - content::MediaStreamDevices audio_devices_; - - // A list of cached video capture devices. - content::MediaStreamDevices video_devices_; - - // Flag to indicate if device enumeration has been done/doing. - // Only accessed on UI thread. - bool devices_enumerated_; - // Flag used by unittests to disable device enumeration. bool is_device_enumeration_disabled_; diff --git a/brightray/browser/media/media_stream_devices_controller.cc b/brightray/browser/media/media_stream_devices_controller.cc index a85c1c928d46..22fb0d1310de 100644 --- a/brightray/browser/media/media_stream_devices_controller.cc +++ b/brightray/browser/media/media_stream_devices_controller.cc @@ -41,6 +41,7 @@ MediaStreamDevicesController::MediaStreamDevicesController( MediaStreamDevicesController::~MediaStreamDevicesController() { if (!callback_.is_null()) { callback_.Run(content::MediaStreamDevices(), + content::MEDIA_DEVICE_INVALID_STATE, scoped_ptr()); } } @@ -150,13 +151,15 @@ void MediaStreamDevicesController::Accept() { content::MediaResponseCallback cb = callback_; callback_.Reset(); - cb.Run(devices, scoped_ptr()); + cb.Run(devices, content::MEDIA_DEVICE_OK, scoped_ptr()); } void MediaStreamDevicesController::Deny() { content::MediaResponseCallback cb = callback_; callback_.Reset(); - cb.Run(content::MediaStreamDevices(), scoped_ptr()); + cb.Run(content::MediaStreamDevices(), + content::MEDIA_DEVICE_PERMISSION_DENIED, + scoped_ptr()); } } // namespace brightray diff --git a/brightray/browser/network_delegate.cc b/brightray/browser/network_delegate.cc index 6467dc3e3d6f..ec019a5f2812 100644 --- a/brightray/browser/network_delegate.cc +++ b/brightray/browser/network_delegate.cc @@ -37,7 +37,8 @@ int NetworkDelegate::OnHeadersReceived( net::URLRequest* request, const net::CompletionCallback& callback, const net::HttpResponseHeaders* original_response_headers, - scoped_refptr* override_response_headers) { + scoped_refptr* override_response_headers, + GURL* allowed_unsafe_redirect_url) { return net::OK; } @@ -59,7 +60,7 @@ void NetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) { } void NetworkDelegate::OnPACScriptError(int line_number, - const string16& error) { + const base::string16& error) { } NetworkDelegate::AuthRequiredResponse NetworkDelegate::OnAuthRequired( @@ -97,9 +98,4 @@ int NetworkDelegate::OnBeforeSocketStreamConnect( return net::OK; } -void NetworkDelegate::OnRequestWaitStateChange( - const net::URLRequest& request, - RequestWaitState waiting) { -} - } // namespace brightray diff --git a/brightray/browser/network_delegate.h b/brightray/browser/network_delegate.h index 0d4f2d3600c5..94be71d98528 100644 --- a/brightray/browser/network_delegate.h +++ b/brightray/browser/network_delegate.h @@ -27,8 +27,8 @@ class NetworkDelegate : public net::NetworkDelegate { net::URLRequest* request, const net::CompletionCallback& callback, const net::HttpResponseHeaders* original_response_headers, - scoped_refptr* - override_response_headers) OVERRIDE; + 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; @@ -37,7 +37,7 @@ class NetworkDelegate : public net::NetworkDelegate { virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE; virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE; virtual void OnPACScriptError(int line_number, - const string16& error) OVERRIDE; + const base::string16& error) OVERRIDE; virtual AuthRequiredResponse OnAuthRequired( net::URLRequest* request, const net::AuthChallengeInfo& auth_info, @@ -55,8 +55,6 @@ class NetworkDelegate : public net::NetworkDelegate { virtual int OnBeforeSocketStreamConnect( net::SocketStream* stream, const net::CompletionCallback& callback) OVERRIDE; - virtual void OnRequestWaitStateChange(const net::URLRequest& request, - RequestWaitState state) OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(NetworkDelegate); diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index 4b26d7a93645..578f5a3047ab 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -29,10 +29,12 @@ #include "net/ssl/ssl_config_service_defaults.h" #include "net/url_request/data_protocol_handler.h" #include "net/url_request/file_protocol_handler.h" +#include "net/url_request/protocol_intercept_job_factory.h" #include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_storage.h" #include "net/url_request/url_request_job_factory_impl.h" +#include "webkit/browser/quota/special_storage_policy.h" namespace brightray { @@ -41,11 +43,13 @@ URLRequestContextGetter::URLRequestContextGetter( base::MessageLoop* io_loop, base::MessageLoop* file_loop, base::Callback(void)> network_delegate_factory, - content::ProtocolHandlerMap* protocol_handlers) + content::ProtocolHandlerMap* protocol_handlers, + content::ProtocolHandlerScopedVector protocol_interceptors) : base_path_(base_path), io_loop_(io_loop), file_loop_(file_loop), - network_delegate_factory_(network_delegate_factory) { + network_delegate_factory_(network_delegate_factory), + protocol_interceptors_(protocol_interceptors.Pass()) { // Must first be created on the UI thread. DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); @@ -71,18 +75,18 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { url_request_context_->set_network_delegate(network_delegate_.get()); storage_.reset( new net::URLRequestContextStorage(url_request_context_.get())); - storage_->set_cookie_store(content::CreatePersistentCookieStore( + auto cookie_config = content::CookieStoreConfig( base_path_.Append(FILE_PATH_LITERAL("Cookies")), - false, + content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, nullptr, - nullptr, - nullptr)); + nullptr); + storage_->set_cookie_store(content::CreateCookieStore(cookie_config)); storage_->set_server_bound_cert_service(new net::ServerBoundCertService( new net::DefaultServerBoundCertStore(NULL), base::WorkerPool::GetTaskRunner(true))); storage_->set_http_user_agent_settings( new net::StaticHttpUserAgentSettings( - "en-us,en", EmptyString())); + "en-us,en", base::EmptyString())); scoped_ptr host_resolver( net::HostResolver::CreateDefaultResolver(NULL)); @@ -151,17 +155,31 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { bool set_protocol = job_factory->SetProtocolHandler( it->first, it->second.release()); DCHECK(set_protocol); + (void)set_protocol; // silence unused-variable warning in Release builds on Windows } protocol_handlers_.clear(); job_factory->SetProtocolHandler( - chrome::kDataScheme, new net::DataProtocolHandler); + content::kDataScheme, new net::DataProtocolHandler); job_factory->SetProtocolHandler( - chrome::kFileScheme, + content::kFileScheme, new net::FileProtocolHandler( content::BrowserThread::GetBlockingPool()-> GetTaskRunnerWithShutdownBehavior( base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); - storage_->set_job_factory(job_factory.release()); + + // Set up interceptors in the reverse order. + scoped_ptr top_job_factory = + job_factory.PassAs(); + for (content::ProtocolHandlerScopedVector::reverse_iterator i = + protocol_interceptors_.rbegin(); + i != protocol_interceptors_.rend(); + ++i) { + top_job_factory.reset(new net::ProtocolInterceptJobFactory( + top_job_factory.Pass(), make_scoped_ptr(*i))); + } + protocol_interceptors_.weak_clear(); + + storage_->set_job_factory(top_job_factory.release()); } return url_request_context_.get(); diff --git a/brightray/browser/url_request_context_getter.h b/brightray/browser/url_request_context_getter.h index 7d3e174cd405..ad09e2b409c6 100644 --- a/brightray/browser/url_request_context_getter.h +++ b/brightray/browser/url_request_context_getter.h @@ -32,7 +32,8 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { base::MessageLoop* io_loop, base::MessageLoop* file_loop, base::Callback(void)>, - content::ProtocolHandlerMap*); + content::ProtocolHandlerMap* protocol_handlers, + content::ProtocolHandlerScopedVector protocol_interceptors); virtual ~URLRequestContextGetter(); net::HostResolver* host_resolver(); @@ -53,6 +54,7 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { scoped_ptr storage_; scoped_ptr url_request_context_; content::ProtocolHandlerMap protocol_handlers_; + content::ProtocolHandlerScopedVector protocol_interceptors_; DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter); }; diff --git a/brightray/browser/win/devtools_window.cc b/brightray/browser/win/devtools_window.cc index 9fc4b5dba886..59857057d5a4 100644 --- a/brightray/browser/win/devtools_window.cc +++ b/brightray/browser/win/devtools_window.cc @@ -4,52 +4,63 @@ #include "browser/win/inspectable_web_contents_view_win.h" #include "content/public/browser/web_contents_view.h" -#include "ui/base/win/hidden_window.h" +#include "ui/views/layout/fill_layout.h" +#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" +#include "ui/views/widget/widget_delegate.h" namespace brightray { +namespace { + +class WidgetDelegateView : public views::WidgetDelegateView { + public: + WidgetDelegateView() { + SetLayoutManager(new views::FillLayout); + } + + virtual void DeleteDelegate() OVERRIDE { delete this; } + virtual views::View* GetContentsView() OVERRIDE { return this; } + virtual bool CanResize() const OVERRIDE { return true; } + virtual bool CanMaximize() const OVERRIDE { return true; } + virtual base::string16 GetWindowTitle() const OVERRIDE { return L"Developer Tools"; } + virtual gfx::Size GetPreferredSize() OVERRIDE { return gfx::Size(800, 600); } + virtual gfx::Size GetMinimumSize() OVERRIDE { return gfx::Size(100, 100); } +}; + +} // namespace + DevToolsWindow* DevToolsWindow::Create( InspectableWebContentsViewWin* controller) { return new DevToolsWindow(controller); } DevToolsWindow::DevToolsWindow(InspectableWebContentsViewWin* controller) - : controller_(controller) { + : controller_(controller), + widget_(new views::Widget) { + auto delegate_view = new WidgetDelegateView; + views::Widget::InitParams params; + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + params.top_level = true; + params.native_widget = new views::DesktopNativeWidgetAura(widget_.get()); + params.delegate = delegate_view; + widget_->Init(params); + delegate_view->AddChildView(controller->GetView()); + delegate_view->Layout(); } DevToolsWindow::~DevToolsWindow() { } -LRESULT DevToolsWindow::OnCreate(UINT, WPARAM, LPARAM, BOOL&) { - auto devtools_web_contents = - controller_->inspectable_web_contents()->devtools_web_contents(); - SetParent(devtools_web_contents->GetView()->GetNativeView(), hwnd()); - SetWindowText(hwnd(), L"Developer Tools"); - return 0; +void DevToolsWindow::Show() { + widget_->Show(); } -LRESULT DevToolsWindow::OnDestroy(UINT, WPARAM, LPARAM, BOOL&) { - auto devtools_web_contents = - controller_->inspectable_web_contents()->devtools_web_contents(); - SetParent( - devtools_web_contents->GetView()->GetNativeView(), ui::GetHiddenWindow()); +void DevToolsWindow::Close() { + widget_->Hide(); +} + +void DevToolsWindow::Destroy() { delete this; - return 0; -} - -LRESULT DevToolsWindow::OnSize(UINT, WPARAM, LPARAM, BOOL&) { - RECT rect; - GetClientRect(hwnd(), &rect); - - auto devtools_web_contents = - controller_->inspectable_web_contents()->devtools_web_contents(); - SetWindowPos(devtools_web_contents->GetView()->GetNativeView(), - nullptr, - rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - SWP_NOZORDER | SWP_SHOWWINDOW); - - return 0; } } // namespace brightray diff --git a/brightray/browser/win/devtools_window.h b/brightray/browser/win/devtools_window.h index a6b11bb11e0c..33c1a4120bc1 100644 --- a/brightray/browser/win/devtools_window.h +++ b/brightray/browser/win/devtools_window.h @@ -1,35 +1,33 @@ #ifndef BRIGHTRAY_BROWSER_WIN_DEVTOOLS_WINDOW_H_ #define BRIGHTRAY_BROWSER_WIN_DEVTOOLS_WINDOW_H_ +#include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" -#include "ui/gfx/win/window_impl.h" + +namespace views { +class Widget; +} namespace brightray { class InspectableWebContentsViewWin; -class DevToolsWindow : public gfx::WindowImpl, - public base::SupportsWeakPtr { +class DevToolsWindow : public base::SupportsWeakPtr { public: static DevToolsWindow* Create( InspectableWebContentsViewWin* inspectable_web_contents_view_win); - BEGIN_MSG_MAP_EX(DevToolsWindow) - MESSAGE_HANDLER(WM_CREATE, OnCreate) - MESSAGE_HANDLER(WM_DESTROY, OnDestroy) - MESSAGE_HANDLER(WM_SIZE, OnSize) - END_MSG_MAP() + void Show(); + void Close(); + void Destroy(); private: explicit DevToolsWindow( InspectableWebContentsViewWin* inspectable_web_contents_view_win); ~DevToolsWindow(); - LRESULT OnCreate(UINT message, WPARAM, LPARAM, BOOL& handled); - LRESULT OnDestroy(UINT message, WPARAM, LPARAM, BOOL& handled); - LRESULT OnSize(UINT message, WPARAM, LPARAM, BOOL& handled); - InspectableWebContentsViewWin* controller_; + scoped_ptr widget_; DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); }; diff --git a/brightray/browser/win/inspectable_web_contents_view_win.cc b/brightray/browser/win/inspectable_web_contents_view_win.cc index 24a52b658f7d..641725889bf6 100644 --- a/brightray/browser/win/inspectable_web_contents_view_win.cc +++ b/brightray/browser/win/inspectable_web_contents_view_win.cc @@ -143,7 +143,7 @@ InspectableWebContentsViewWin::InspectableWebContentsViewWin( InspectableWebContentsViewWin::~InspectableWebContentsViewWin() { if (devtools_window_) - DestroyWindow(devtools_window_->hwnd()); + devtools_window_->Destroy(); } views::View* InspectableWebContentsViewWin::GetView() const { @@ -161,19 +161,10 @@ gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const { void InspectableWebContentsViewWin::ShowDevTools() { if (undocked_) { - if (!devtools_window_) { + if (!devtools_window_) devtools_window_ = DevToolsWindow::Create(this)->AsWeakPtr(); - devtools_window_->Init(HWND_DESKTOP, gfx::Rect()); - } - auto contents_view = inspectable_web_contents_->GetWebContents()->GetView(); - auto size = contents_view->GetContainerSize(); - size.Enlarge(-kWindowInset, -kWindowInset); - gfx::CenterAndSizeWindow(contents_view->GetNativeView(), - devtools_window_->hwnd(), - size); - - ShowWindow(devtools_window_->hwnd(), SW_SHOWNORMAL); + devtools_window_->Show(); } else { container_->ShowDevTools(); } @@ -181,7 +172,7 @@ void InspectableWebContentsViewWin::ShowDevTools() { void InspectableWebContentsViewWin::CloseDevTools() { if (undocked_) - SendMessage(devtools_window_->hwnd(), WM_CLOSE, 0, 0); + devtools_window_->Close(); else container_->CloseDevTools(); } @@ -197,7 +188,7 @@ bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) { } else if (side == "right" || side == "bottom") { undocked_ = false; if (devtools_window_) - SendMessage(devtools_window_->hwnd(), WM_CLOSE, 0, 0); + devtools_window_->Close(); container_->SetDockSide(side); } else { return false; diff --git a/brightray/common/application_info_win.cc b/brightray/common/application_info_win.cc index 696d8b36b5ee..fd18d54b0ca4 100644 --- a/brightray/common/application_info_win.cc +++ b/brightray/common/application_info_win.cc @@ -10,14 +10,14 @@ std::string GetApplicationName() { auto module = GetModuleHandle(nullptr); auto info = make_scoped_ptr( FileVersionInfo::CreateFileVersionInfoForModule(module)); - return UTF16ToUTF8(info->product_name()); + return base::UTF16ToUTF8(info->product_name()); } std::string GetApplicationVersion() { auto module = GetModuleHandle(nullptr); auto info = make_scoped_ptr( FileVersionInfo::CreateFileVersionInfoForModule(module)); - return UTF16ToUTF8(info->product_version()); + return base::UTF16ToUTF8(info->product_version()); } } // namespace brightray diff --git a/brightray/common/content_client.cc b/brightray/common/content_client.cc index dd6ce530690c..9d42e350191f 100644 --- a/brightray/common/content_client.cc +++ b/brightray/common/content_client.cc @@ -8,8 +8,8 @@ #include "base/strings/stringprintf.h" #include "base/strings/string_util.h" +#include "content/public/common/user_agent.h" #include "ui/base/resource/resource_bundle.h" -#include "webkit/common/user_agent/user_agent_util.h" namespace brightray { @@ -21,13 +21,13 @@ ContentClient::~ContentClient() { std::string ContentClient::GetProduct() const { auto name = GetApplicationName(); - RemoveChars(name, kWhitespaceASCII, &name); + base::RemoveChars(name, base::kWhitespaceASCII, &name); return base::StringPrintf("%s/%s", name.c_str(), GetApplicationVersion().c_str()); } std::string ContentClient::GetUserAgent() const { - return webkit_glue::BuildUserAgentFromProduct(GetProduct()); + return content::BuildUserAgentFromProduct(GetProduct()); } base::StringPiece ContentClient::GetDataResource( diff --git a/brightray/common/main_delegate.cc b/brightray/common/main_delegate.cc index f85c769bafc4..ea0cbdddb5a4 100644 --- a/brightray/common/main_delegate.cc +++ b/brightray/common/main_delegate.cc @@ -27,14 +27,14 @@ scoped_ptr MainDelegate::CreateContentClient() { bool MainDelegate::BasicStartupComplete(int* exit_code) { content_client_ = CreateContentClient().Pass(); SetContentClient(content_client_.get()); - return false; -} - -void MainDelegate::PreSandboxStartup() { #if defined(OS_MACOSX) OverrideChildProcessPath(); OverrideFrameworkBundlePath(); #endif + return false; +} + +void MainDelegate::PreSandboxStartup() { InitializeResourceBundle(); } diff --git a/brightray/script/build b/brightray/script/build index b13f892b64f0..30ee528230a4 100755 --- a/brightray/script/build +++ b/brightray/script/build @@ -15,7 +15,12 @@ def main(): def run_gyp(): - return subprocess.call([sys.executable, GYP, '--depth', '.', 'brightray.gyp']) + env = os.environ.copy() + gyp_pylib = os.path.join(os.path.dirname(GYP), 'pylib') + env['PYTHONPATH'] = os.path.pathsep.join([gyp_pylib, + env.get('PYTHONPATH', '')]) + return subprocess.call([sys.executable, GYP, '--depth', '.', + 'brightray.gyp'], env=env) def build(): @@ -25,7 +30,8 @@ def build(): return subprocess.call(['make']) assert sys.platform == 'win32', sys.platform - msbuild = os.path.join(os.environ['windir'], 'Microsoft.NET', 'Framework', 'v4.0.30319', 'MSBuild.exe') + program_files = os.environ.get('PROGRAMFILES(X86)', os.environ['PROGRAMFILES']) + msbuild = os.path.join(program_files, 'MSBuild', '12.0', 'Bin', 'MSBuild.exe') return subprocess.call([msbuild, 'brightray.sln']) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 656be9408484..331dbed44676 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 656be9408484de40ba4938ef47acdebeec8a1784 +Subproject commit 331dbed44676c534faf21f7db1985e796260649a