From 710d0fc6c5d97557bfbb7734126a9a2bf485db22 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Thu, 15 Aug 2013 16:07:14 -0400 Subject: [PATCH 01/28] Make overriding BrowserContext::RegisterPrefs actually work We were calling it before derived classes' vtables were set up. Now we wait to call it until the BrowserContext is fully constructed. --- brightray/browser/browser_context.cc | 3 +++ brightray/browser/browser_context.h | 2 ++ brightray/browser/browser_main_parts.cc | 1 + 3 files changed, 6 insertions(+) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 31c00b8d6aa0..3ade3b1c51a8 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -48,6 +48,9 @@ private: }; BrowserContext::BrowserContext() : resource_context_(new ResourceContext) { +} + +void BrowserContext::Initialize() { auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); PrefServiceBuilder builder; builder.WithUserFilePrefs(prefs_path, diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index 85f00148c9c0..ec3f1f6e5a2f 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -22,6 +22,8 @@ public: BrowserContext(); ~BrowserContext(); + void Initialize(); + net::URLRequestContextGetter* CreateRequestContext(content::ProtocolHandlerMap*); PrefService* prefs() { return prefs_.get(); } diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index 04e67f24fb18..bb435057c056 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -22,6 +22,7 @@ BrowserMainParts::~BrowserMainParts() { void BrowserMainParts::PreMainMessageLoopRun() { browser_context_.reset(CreateBrowserContext()); + browser_context_->Initialize(); // These two objects are owned by devtools_http_handler_. auto delegate = new DevToolsDelegate; From f17f9d932c85c44e3349d58bc28f623ee8771dd8 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Fri, 23 Aug 2013 07:48:37 -0400 Subject: [PATCH 02/28] Include gyp as a submodule This makes it so you don't have to install gyp on your system before you can build. --- brightray/.gitmodules | 3 +++ brightray/README.md | 1 - brightray/script/build | 6 ++---- brightray/vendor/gyp | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) create mode 160000 brightray/vendor/gyp diff --git a/brightray/.gitmodules b/brightray/.gitmodules index b5a3d92f902f..1e27bc6b5a21 100644 --- a/brightray/.gitmodules +++ b/brightray/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/libchromiumcontent"] path = vendor/libchromiumcontent url = https://github.com/brightray/libchromiumcontent +[submodule "vendor/gyp"] + path = vendor/gyp + url = https://github.com/svn2github/gyp diff --git a/brightray/README.md b/brightray/README.md index 8882bae914b8..deac3f13e710 100644 --- a/brightray/README.md +++ b/brightray/README.md @@ -14,7 +14,6 @@ sample application written using Brightray. ### Prerequisites * Python 2.7 -* gyp * Linux: * Clang 3.0 * Mac: diff --git a/brightray/script/build b/brightray/script/build index 8e155d37fa67..b13f892b64f0 100755 --- a/brightray/script/build +++ b/brightray/script/build @@ -6,9 +6,7 @@ import sys SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) -GYP = { - 'win32': 'gyp.bat', -}.get(sys.platform, 'gyp') +GYP = os.path.join(SOURCE_ROOT, 'vendor', 'gyp', 'gyp_main.py') def main(): @@ -17,7 +15,7 @@ def main(): def run_gyp(): - return subprocess.call([GYP, '--depth', '.', 'brightray.gyp']) + return subprocess.call([sys.executable, GYP, '--depth', '.', 'brightray.gyp']) def build(): diff --git a/brightray/vendor/gyp b/brightray/vendor/gyp new file mode 160000 index 000000000000..6633baab29b6 --- /dev/null +++ b/brightray/vendor/gyp @@ -0,0 +1 @@ +Subproject commit 6633baab29b60f27e3dca607ffbef689ccdd82b8 From 7dd1b8195f04dac3104401308692774fe8285a33 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Fri, 23 Aug 2013 16:56:05 -0400 Subject: [PATCH 03/28] Update libchromiumcontent to Chrome 29 * vendor/libchromiumcontent 5ffcb39...ccec3a4 (2): > Merge pull request #25 from brightray/29.0.1547.57 > Switch back to using s3put on Linux --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 5ffcb396d64d..ccec3a4031fa 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 5ffcb396d64df97a2d0220101e1e52598a661fc8 +Subproject commit ccec3a4031fa79d61f4199d99e477813d2d72a5a From 4946ec9081ca81ab7febb070a131d0eb0059ee57 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Fri, 23 Aug 2013 16:56:30 -0400 Subject: [PATCH 04/28] Update for utf_string_conversions.h move in Chrome 29 --- brightray/browser/inspectable_web_contents_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 7f694ad54ff5..840712c86a2d 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -13,7 +13,7 @@ #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" #include "base/stringprintf.h" -#include "base/utf_string_conversions.h" +#include "base/strings/utf_string_conversions.h" #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/devtools_client_host.h" #include "content/public/browser/devtools_http_handler.h" From 7d3f371b517232b06dbdd1283358884c8512ec1a Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Fri, 23 Aug 2013 16:56:41 -0400 Subject: [PATCH 05/28] Update for move of MessageLoop into base namespace --- brightray/browser/url_request_context_getter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index e6d73a608f36..47eb355aec71 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -30,8 +30,8 @@ namespace brightray { URLRequestContextGetter::URLRequestContextGetter( const base::FilePath& base_path, - MessageLoop* io_loop, - MessageLoop* file_loop, + base::MessageLoop* io_loop, + base::MessageLoop* file_loop, scoped_ptr network_delegate, content::ProtocolHandlerMap* protocol_handlers) : base_path_(base_path), From 2c030a419d511c1003776e3a4d2870eddf869b86 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Fri, 23 Aug 2013 16:56:53 -0400 Subject: [PATCH 06/28] Update for webkit header moves --- brightray/common/content_client.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/common/content_client.cc b/brightray/common/content_client.cc index 87cc07abfeee..fc294f45ec58 100644 --- a/brightray/common/content_client.cc +++ b/brightray/common/content_client.cc @@ -9,7 +9,7 @@ #include "base/stringprintf.h" #include "base/string_util.h" #include "ui/base/resource/resource_bundle.h" -#include "webkit/user_agent/user_agent_util.h" +#include "webkit/common/user_agent/user_agent_util.h" namespace brightray { From b24d7d7c76373e02e787608bb8805c34e62b6cf4 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Fri, 23 Aug 2013 17:01:18 -0400 Subject: [PATCH 07/28] Update utf_string_conversions.h path in another place --- brightray/common/application_info_win.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/common/application_info_win.cc b/brightray/common/application_info_win.cc index 8363970ebd85..49c53796358e 100644 --- a/brightray/common/application_info_win.cc +++ b/brightray/common/application_info_win.cc @@ -2,7 +2,7 @@ #include "base/file_version_info.h" #include "base/memory/scoped_ptr.h" -#include "base/utf_string_conversions.h" +#include "base/strings/utf_string_conversions.h" namespace brightray { From 8c7de2259bd10586b071895087a7beb1795390c8 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Fri, 23 Aug 2013 17:30:53 -0400 Subject: [PATCH 08/28] Update to latest libchromiumcontent * vendor/libchromiumcontent ccec3a4...a56056d (1): > Stop exporting GURL symbols from test_support_chromiumcontent --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index ccec3a4031fa..a56056d8f6af 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit ccec3a4031fa79d61f4199d99e477813d2d72a5a +Subproject commit a56056d8f6af9d66ffdd998d136323ef659c10c6 From 0575987343fb94258865900b4ce9bffac137e81e Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 12:40:09 -0400 Subject: [PATCH 09/28] Update to Chrome 30 * vendor/libchromiumcontent a56056d...bfb2d7b (1): > Merge pull request #27 from brightray/chrome-30 --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index a56056d8f6af..bfb2d7bd95b4 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit a56056d8f6af9d66ffdd998d136323ef659c10c6 +Subproject commit bfb2d7bd95b41f328989622f7ac416c9544a9478 From 1e99ec9aedc1ee1f0d7cec0cc37da80072ecdae6 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 15:16:49 -0400 Subject: [PATCH 10/28] Update #includes for moves of string-related headers See http://src.chromium.org/viewvc/chrome?view=revision&revision=205050. --- brightray/browser/inspectable_web_contents_impl.cc | 2 +- brightray/browser/notification_presenter_mac.mm | 2 +- brightray/browser/url_request_context_getter.cc | 2 +- brightray/common/content_client.cc | 4 ++-- brightray/common/main_delegate_mac.mm | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 840712c86a2d..b92136321ace 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -12,7 +12,7 @@ #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" -#include "base/stringprintf.h" +#include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/devtools_client_host.h" diff --git a/brightray/browser/notification_presenter_mac.mm b/brightray/browser/notification_presenter_mac.mm index 02ca2927fe38..416e455503a3 100644 --- a/brightray/browser/notification_presenter_mac.mm +++ b/brightray/browser/notification_presenter_mac.mm @@ -5,7 +5,7 @@ #import "browser/notification_presenter_mac.h" -#import "base/stringprintf.h" +#import "base/strings/stringprintf.h" #import "base/strings/sys_string_conversions.h" #import "content/public/browser/render_view_host.h" #import "content/public/common/show_desktop_notification_params.h" diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index 47eb355aec71..4595cf8c7134 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -5,7 +5,7 @@ #include "browser/url_request_context_getter.h" #include "network_delegate.h" -#include "base/string_util.h" +#include "base/strings/string_util.h" #include "base/threading/worker_pool.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/cookie_store_factory.h" diff --git a/brightray/common/content_client.cc b/brightray/common/content_client.cc index fc294f45ec58..a518cc026ca9 100644 --- a/brightray/common/content_client.cc +++ b/brightray/common/content_client.cc @@ -6,8 +6,8 @@ #include "common/application_info.h" -#include "base/stringprintf.h" -#include "base/string_util.h" +#include "base/strings/stringprintf.h" +#include "base/strings/string_util.h" #include "ui/base/resource/resource_bundle.h" #include "webkit/common/user_agent/user_agent_util.h" diff --git a/brightray/common/main_delegate_mac.mm b/brightray/common/main_delegate_mac.mm index c9aaecbede36..7c5aaf68da7c 100644 --- a/brightray/common/main_delegate_mac.mm +++ b/brightray/common/main_delegate_mac.mm @@ -13,7 +13,7 @@ #include "base/mac/bundle_locations.h" #include "base/mac/mac_util.h" #include "base/path_service.h" -#include "base/stringprintf.h" +#include "base/strings/stringprintf.h" #include "base/strings/sys_string_conversions.h" #include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" From 64a5ce6e15b17d130d2cdf5740df3a6ebe761ac6 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 15:17:39 -0400 Subject: [PATCH 11/28] Update for move of scoped_nsobject header and namespace See http://src.chromium.org/viewvc/chrome?view=revision&revision=207616. --- brightray/browser/inspectable_web_contents_view_mac.h | 4 ++-- brightray/browser/notification_presenter_mac.h | 6 +++--- brightray/browser/notification_presenter_mac.mm | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/brightray/browser/inspectable_web_contents_view_mac.h b/brightray/browser/inspectable_web_contents_view_mac.h index a03ccaf6361f..1b5a6e433225 100644 --- a/brightray/browser/inspectable_web_contents_view_mac.h +++ b/brightray/browser/inspectable_web_contents_view_mac.h @@ -3,7 +3,7 @@ #import "browser/inspectable_web_contents_view.h" -#import "base/memory/scoped_nsobject.h" +#import "base/mac/scoped_nsobject.h" @class BRYInspectableWebContentsView; @@ -26,7 +26,7 @@ private: // Owns us. InspectableWebContentsImpl* inspectable_web_contents_; - scoped_nsobject view_; + base::scoped_nsobject view_; DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewMac); }; diff --git a/brightray/browser/notification_presenter_mac.h b/brightray/browser/notification_presenter_mac.h index 5cd2c87e40a4..b3757bf56ea4 100644 --- a/brightray/browser/notification_presenter_mac.h +++ b/brightray/browser/notification_presenter_mac.h @@ -8,7 +8,7 @@ #import "browser/notification_presenter.h" -#import "base/memory/scoped_nsobject.h" +#import "base/mac/scoped_nsobject.h" #import @class BRYUserNotificationCenterDelegate; @@ -30,8 +30,8 @@ class NotificationPresenterMac : public NotificationPresenter { int notification_id) OVERRIDE; private: - std::map> notification_map_; - scoped_nsobject delegate_; + std::map> notification_map_; + base::scoped_nsobject delegate_; }; } diff --git a/brightray/browser/notification_presenter_mac.mm b/brightray/browser/notification_presenter_mac.mm index 416e455503a3..dc2ad9231fba 100644 --- a/brightray/browser/notification_presenter_mac.mm +++ b/brightray/browser/notification_presenter_mac.mm @@ -56,7 +56,7 @@ struct NotificationID { int notification_id; }; -scoped_nsobject CreateUserNotification( +base::scoped_nsobject CreateUserNotification( const content::ShowDesktopNotificationHostMsgParams& params, int render_process_id, int render_view_id) { @@ -65,7 +65,7 @@ scoped_nsobject CreateUserNotification( notification.informativeText = base::SysUTF16ToNSString(params.body); notification.userInfo = NotificationID(render_process_id, render_view_id, params.notification_id).GetUserInfo(); - return scoped_nsobject(notification); + return base::scoped_nsobject(notification); } } From eb446fc7072ce9b74017f8a1a63245842da048b6 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 15:21:43 -0400 Subject: [PATCH 12/28] content::BrowserContext::GetPath is a const member function in Chrome 30 See http://src.chromium.org/viewvc/chrome?view=revision&revision=211931. --- brightray/browser/browser_context.cc | 28 +++++++++++++--------------- brightray/browser/browser_context.h | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 3ade3b1c51a8..38aecce7b77a 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -51,6 +51,18 @@ BrowserContext::BrowserContext() : resource_context_(new ResourceContext) { } void BrowserContext::Initialize() { + base::FilePath path; +#if defined(OS_LINUX) + scoped_ptr env(base::Environment::Create()); + path = base::nix::GetXDGDirectory(env.get(), + base::nix::kXdgConfigHomeEnvVar, + base::nix::kDotConfigDir); +#else + CHECK(PathService::Get(base::DIR_APP_DATA, &path)); +#endif + + path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); + auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); PrefServiceBuilder builder; builder.WithUserFilePrefs(prefs_path, @@ -86,21 +98,7 @@ scoped_ptr BrowserContext::CreateNetworkDelegate() { return make_scoped_ptr(new NetworkDelegate).Pass(); } -base::FilePath BrowserContext::GetPath() { - if (!path_.empty()) - return path_; - - base::FilePath path; -#if defined(OS_LINUX) - scoped_ptr env(base::Environment::Create()); - path = base::nix::GetXDGDirectory(env.get(), - base::nix::kXdgConfigHomeEnvVar, - base::nix::kDotConfigDir); -#else - CHECK(PathService::Get(base::DIR_APP_DATA, &path)); -#endif - - path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); +base::FilePath BrowserContext::GetPath() const { return path_; } diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index ec3f1f6e5a2f..7067aab53139 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -35,7 +35,7 @@ protected: // Subclasses should override this to provide a custom NetworkDelegate implementation. virtual scoped_ptr CreateNetworkDelegate(); - virtual base::FilePath GetPath() OVERRIDE; + virtual base::FilePath GetPath() const OVERRIDE; private: class ResourceContext; From c1c4344879e87a842ccd070400957599f7a6f580 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 15:23:55 -0400 Subject: [PATCH 13/28] BrowserContext::GetSpeechRecognitionPreferences is gone in Chrome 30 See http://src.chromium.org/viewvc/chrome?view=revision&revision=210616. --- brightray/browser/browser_context.cc | 4 ---- brightray/browser/browser_context.h | 1 - 2 files changed, 5 deletions(-) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 38aecce7b77a..660aa69fc0b4 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -140,10 +140,6 @@ content::GeolocationPermissionContext* BrowserContext::GetGeolocationPermissionC return nullptr; } -content::SpeechRecognitionPreferences* BrowserContext::GetSpeechRecognitionPreferences() { - return nullptr; -} - quota::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() { return nullptr; } diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index 7067aab53139..04a4c7eba697 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -51,7 +51,6 @@ private: virtual content::ResourceContext* GetResourceContext() OVERRIDE; virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; - virtual content::SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; base::FilePath path_; From 4d59060657a49e67230ff7be59aa3db739acb842 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 15:26:11 -0400 Subject: [PATCH 14/28] BrowserContext::RequestMIDISysExPermission was added in Chrome 30 See http://src.chromium.org/viewvc/chrome?view=revision&revision=211437. --- brightray/browser/browser_context.cc | 4 ++++ brightray/browser/browser_context.h | 1 + 2 files changed, 5 insertions(+) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 660aa69fc0b4..26b62f4d3167 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -126,6 +126,10 @@ net::URLRequestContextGetter* BrowserContext::GetMediaRequestContextForStoragePa return GetRequestContext(); } +void BrowserContext::RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback& callback) { + callback.Run(false); +} + content::ResourceContext* BrowserContext::GetResourceContext() { return resource_context_.get(); } diff --git a/brightray/browser/browser_context.h b/brightray/browser/browser_context.h index 04a4c7eba697..f18cfdadced6 100644 --- a/brightray/browser/browser_context.h +++ b/brightray/browser/browser_context.h @@ -48,6 +48,7 @@ private: virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(int renderer_child_id) OVERRIDE; virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory); + virtual void RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback&) OVERRIDE; virtual content::ResourceContext* GetResourceContext() OVERRIDE; virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; From aa4f991659a8d9188f8e7b26092ceeb58ebd6a78 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 15:29:17 -0400 Subject: [PATCH 15/28] Add DevToolsFrontendHostDelegate indexing methods from Chrome 30 See http://src.chromium.org/viewvc/chrome?view=revision&revision=215622. --- brightray/browser/inspectable_web_contents_impl.cc | 9 +++++++++ brightray/browser/inspectable_web_contents_impl.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index b92136321ace..341521cf9ba5 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -123,6 +123,15 @@ void InspectableWebContentsImpl::AddFileSystem() { void InspectableWebContentsImpl::RemoveFileSystem(const std::string& file_system_path) { } +void InspectableWebContentsImpl::IndexPath(int request_id, const std::string& file_system_path) { +} + +void InspectableWebContentsImpl::StopIndexing(int request_id) { +} + +void InspectableWebContentsImpl::SearchInPath(int request_id, const std::string& file_system_path, const std::string& query) { +} + void InspectableWebContentsImpl::InspectedContentsClosing() { } diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index 95293e062bd8..b2a772047207 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -60,6 +60,11 @@ private: virtual void RequestFileSystems() OVERRIDE; virtual void AddFileSystem() OVERRIDE; virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE; + virtual void IndexPath(int request_id, const std::string& file_system_path) OVERRIDE; + virtual void StopIndexing(int request_id) OVERRIDE; + virtual void SearchInPath(int request_id, + const std::string& file_system_path, + const std::string& query) OVERRIDE; virtual void InspectedContentsClosing() OVERRIDE; // content::WebContentsObserver From d1623535e84cf5a48c771bc16cee148b470e0578 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 16:13:01 -0400 Subject: [PATCH 16/28] Update browser/media/* for Chrome 30 I took the latest versions of these files from chrome/browser/media, then pared them down to remove all Chrome-isms and uses of UI to prompt the user about allowing access to devices. --- .../media/media_capture_devices_dispatcher.cc | 123 +++++++++++------- .../media/media_capture_devices_dispatcher.h | 56 +++++--- .../media/media_stream_devices_controller.cc | 116 ++++++++++++++--- .../media/media_stream_devices_controller.h | 12 +- 4 files changed, 211 insertions(+), 96 deletions(-) diff --git a/brightray/browser/media/media_capture_devices_dispatcher.cc b/brightray/browser/media/media_capture_devices_dispatcher.cc index 3c15841c1644..1c3f94300502 100644 --- a/brightray/browser/media/media_capture_devices_dispatcher.cc +++ b/brightray/browser/media/media_capture_devices_dispatcher.cc @@ -4,9 +4,10 @@ #include "browser/media/media_capture_devices_dispatcher.h" -#include "base/prefs/pref_service.h" +#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/common/media_stream_request.h" namespace brightray { @@ -16,41 +17,40 @@ using content::MediaStreamDevices; namespace { -const content::MediaStreamDevice* FindDefaultDeviceWithId( +// Finds a device in |devices| that has |device_id|, or NULL if not found. +const content::MediaStreamDevice* FindDeviceWithId( const content::MediaStreamDevices& devices, const std::string& device_id) { - if (devices.empty()) - return NULL; - content::MediaStreamDevices::const_iterator iter = devices.begin(); for (; iter != devices.end(); ++iter) { if (iter->id == device_id) { return &(*iter); } } - - return &(*devices.begin()); + return NULL; }; } // namespace - MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { return Singleton::get(); } MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() - : devices_enumerated_(false) {} + : devices_enumerated_(false), + is_device_enumeration_disabled_(false) { + // MediaCaptureDevicesDispatcher is a singleton. It should be created on + // UI thread. + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); +} MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {} const MediaStreamDevices& MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!devices_enumerated_) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&content::EnsureMonitorCaptureDevices)); + if (!is_device_enumeration_disabled_ && !devices_enumerated_) { + content::EnsureMonitorCaptureDevices(); devices_enumerated_ = true; } return audio_devices_; @@ -59,17 +59,14 @@ MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() { const MediaStreamDevices& MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!devices_enumerated_) { - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&content::EnsureMonitorCaptureDevices)); + if (!is_device_enumeration_disabled_ && !devices_enumerated_) { + content::EnsureMonitorCaptureDevices(); devices_enumerated_ = true; } return video_devices_; } -void MediaCaptureDevicesDispatcher::GetRequestedDevice( - const std::string& requested_device_id, +void MediaCaptureDevicesDispatcher::GetDefaultDevices( bool audio, bool video, content::MediaStreamDevices* devices) { @@ -77,32 +74,58 @@ void MediaCaptureDevicesDispatcher::GetRequestedDevice( DCHECK(audio || video); if (audio) { - const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices(); - const content::MediaStreamDevice* const device = - FindDefaultDeviceWithId(audio_devices, requested_device_id); + const content::MediaStreamDevice* device = GetFirstAvailableAudioDevice(); if (device) devices->push_back(*device); } + if (video) { - const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices(); - const content::MediaStreamDevice* const device = - FindDefaultDeviceWithId(video_devices, requested_device_id); + const content::MediaStreamDevice* device = GetFirstAvailableVideoDevice(); if (device) devices->push_back(*device); } } -void MediaCaptureDevicesDispatcher::GetDefaultDevices( - bool audio, - bool video, - content::MediaStreamDevices* devices) { - if (audio) { - GetRequestedDevice(std::string(), true, false, devices); - } +const content::MediaStreamDevice* +MediaCaptureDevicesDispatcher::GetRequestedAudioDevice( + const std::string& requested_audio_device_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices(); + const content::MediaStreamDevice* const device = + FindDeviceWithId(audio_devices, requested_audio_device_id); + return device; +} - if (video) { - GetRequestedDevice(std::string(), false, true, devices); - } +const content::MediaStreamDevice* +MediaCaptureDevicesDispatcher::GetFirstAvailableAudioDevice() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices(); + if (audio_devices.empty()) + return NULL; + return &(*audio_devices.begin()); +} + +const content::MediaStreamDevice* +MediaCaptureDevicesDispatcher::GetRequestedVideoDevice( + const std::string& requested_video_device_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices(); + const content::MediaStreamDevice* const device = + FindDeviceWithId(video_devices, requested_video_device_id); + return device; +} + +const content::MediaStreamDevice* +MediaCaptureDevicesDispatcher::GetFirstAvailableVideoDevice() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices(); + if (video_devices.empty()) + return NULL; + return &(*video_devices.begin()); +} + +void MediaCaptureDevicesDispatcher::DisableDeviceEnumerationForTesting() { + is_device_enumeration_disabled_ = true; } void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged( @@ -126,15 +149,22 @@ void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged( void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged( int render_process_id, int render_view_id, + int page_request_id, const content::MediaStreamDevice& device, content::MediaRequestState state) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, - base::Bind( - &MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread, - base::Unretained(this), render_process_id, render_view_id, device, - state)); + +} + +void MediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged( + int render_process_id, int render_view_id, int stream_id, + bool is_playing, float power_dbfs, bool clipped) { +} + +void MediaCaptureDevicesDispatcher::OnCreatingAudioStream( + int render_process_id, + int render_view_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); } void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread( @@ -145,17 +175,10 @@ void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread( } void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread( - const content::MediaStreamDevices& devices) { + const content::MediaStreamDevices& devices){ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); devices_enumerated_ = true; video_devices_ = devices; } -void MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread( - int render_process_id, - int render_view_id, - const content::MediaStreamDevice& device, - content::MediaRequestState state) { -} - -} +} // namespace brightray diff --git a/brightray/browser/media/media_capture_devices_dispatcher.h b/brightray/browser/media/media_capture_devices_dispatcher.h index 6edb12b5cf0c..680455e2321d 100644 --- a/brightray/browser/media/media_capture_devices_dispatcher.h +++ b/brightray/browser/media/media_capture_devices_dispatcher.h @@ -8,8 +8,8 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" -#include "base/observer_list.h" #include "content/public/browser/media_observer.h" +#include "content/public/browser/web_contents_delegate.h" #include "content/public/common/media_stream_request.h" namespace brightray { @@ -20,20 +20,35 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { public: static MediaCaptureDevicesDispatcher* GetInstance(); - // Helper for picking the device that was requested for an OpenDevice request. - // If the device requested is not available it will revert to using the first - // available one instead or will return an empty list if no devices of the - // requested kind are present. - void GetRequestedDevice(const std::string& requested_device_id, - bool audio, - bool video, - content::MediaStreamDevices* devices); + // Methods for observers. Called on UI thread. + const content::MediaStreamDevices& GetAudioCaptureDevices(); + const content::MediaStreamDevices& GetVideoCaptureDevices(); + + // Helper to get the default devices which can be used by the media request. + // Uses the first available devices if the default devices are not available. + // If the return list is empty, it means there is no available device on the + // OS. + // Called on the UI thread. void GetDefaultDevices(bool audio, bool video, content::MediaStreamDevices* devices); - const content::MediaStreamDevices& GetAudioCaptureDevices(); - const content::MediaStreamDevices& GetVideoCaptureDevices(); + // Helpers for picking particular requested devices, identified by raw id. + // If the device requested is not available it will return NULL. + const content::MediaStreamDevice* + GetRequestedAudioDevice(const std::string& requested_audio_device_id); + const content::MediaStreamDevice* + GetRequestedVideoDevice(const std::string& requested_video_device_id); + + // Returns the first available audio or video device, or NULL if no devices + // are available. + const content::MediaStreamDevice* GetFirstAvailableAudioDevice(); + const content::MediaStreamDevice* GetFirstAvailableVideoDevice(); + + // Unittests that do not require actual device enumeration should call this + // API on the singleton. It is safe to call this multiple times on the + // signleton. + void DisableDeviceEnumerationForTesting(); // Overridden from content::MediaObserver: virtual void OnAudioCaptureDevicesChanged( @@ -43,13 +58,18 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { virtual void OnMediaRequestStateChanged( int render_process_id, int render_view_id, + int page_request_id, const content::MediaStreamDevice& device, content::MediaRequestState state) OVERRIDE; virtual void OnAudioStreamPlayingChanged( int render_process_id, int render_view_id, int stream_id, - bool playing) OVERRIDE {} + bool is_playing, + float power_dBFS, + bool clipped) OVERRIDE; + virtual void OnCreatingAudioStream(int render_process_id, + int render_view_id) OVERRIDE; private: friend struct DefaultSingletonTraits; @@ -60,11 +80,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { // Called by the MediaObserver() functions, executed on UI thread. void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices); void UpdateVideoDevicesOnUIThread(const content::MediaStreamDevices& devices); - void UpdateMediaRequestStateOnUIThread( - int render_process_id, - int render_view_id, - const content::MediaStreamDevice& device, - content::MediaRequestState state); // A list of cached audio capture devices. content::MediaStreamDevices audio_devices_; @@ -75,8 +90,13 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { // 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_; + + DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); }; -} +} // namespace brightray #endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ diff --git a/brightray/browser/media/media_stream_devices_controller.cc b/brightray/browser/media/media_stream_devices_controller.cc index ea53c20fd29d..e6f0af89b737 100644 --- a/brightray/browser/media/media_stream_devices_controller.cc +++ b/brightray/browser/media/media_stream_devices_controller.cc @@ -4,9 +4,8 @@ #include "browser/media/media_stream_devices_controller.h" -#include "base/values.h" #include "browser/media/media_capture_devices_dispatcher.h" -#include "content/public/browser/browser_thread.h" + #include "content/public/common/media_stream_request.h" namespace brightray { @@ -20,7 +19,7 @@ bool HasAnyAvailableDevice() { MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices(); return !audio_devices.empty() || !video_devices.empty(); -}; +} } // namespace @@ -29,15 +28,39 @@ MediaStreamDevicesController::MediaStreamDevicesController( const content::MediaResponseCallback& callback) : request_(request), callback_(callback), + // For MEDIA_OPEN_DEVICE requests (Pepper) we always request both webcam + // and microphone to avoid popping two infobars. microphone_requested_( - request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE), + request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE || + request.request_type == content::MEDIA_OPEN_DEVICE), webcam_requested_( - request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) { + request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE || + request.request_type == content::MEDIA_OPEN_DEVICE) { } -MediaStreamDevicesController::~MediaStreamDevicesController() {} +MediaStreamDevicesController::~MediaStreamDevicesController() { + if (!callback_.is_null()) { + callback_.Run(content::MediaStreamDevices(), + scoped_ptr()); + } +} bool MediaStreamDevicesController::TakeAction() { + // Tab capture is allowed for extensions only and infobar is not shown for + // extensions. + if (request_.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE || + request_.video_type == content::MEDIA_TAB_VIDEO_CAPTURE) { + Deny(); + return true; + } + + // Deny the request if the security origin is empty, this happens with + // file access without |--allow-file-access-from-files| flag. + if (request_.security_origin.is_empty()) { + Deny(); + return true; + } + // Deny the request if there is no device attached to the OS. if (!HasAnyAvailableDevice()) { Deny(); @@ -53,34 +76,87 @@ void MediaStreamDevicesController::Accept() { content::MediaStreamDevices devices; if (microphone_requested_ || webcam_requested_) { switch (request_.request_type) { - case content::MEDIA_OPEN_DEVICE: + case content::MEDIA_OPEN_DEVICE: { + const content::MediaStreamDevice* device = NULL; // For open device request pick the desired device or fall back to the // first available of the given type. - MediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice( - request_.requested_device_id, - microphone_requested_, - webcam_requested_, - &devices); + if (request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) { + device = MediaCaptureDevicesDispatcher::GetInstance()-> + GetRequestedAudioDevice(request_.requested_audio_device_id); + // TODO(wjia): Confirm this is the intended behavior. + if (!device) { + device = MediaCaptureDevicesDispatcher::GetInstance()-> + GetFirstAvailableAudioDevice(); + } + } else if (request_.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE) { + // Pepper API opens only one device at a time. + device = MediaCaptureDevicesDispatcher::GetInstance()-> + GetRequestedVideoDevice(request_.requested_video_device_id); + // TODO(wjia): Confirm this is the intended behavior. + if (!device) { + device = MediaCaptureDevicesDispatcher::GetInstance()-> + GetFirstAvailableVideoDevice(); + } + } + if (device) + devices.push_back(*device); break; - case content::MEDIA_DEVICE_ACCESS: - case content::MEDIA_GENERATE_STREAM: - case content::MEDIA_ENUMERATE_DEVICES: + } case content::MEDIA_GENERATE_STREAM: { + bool needs_audio_device = microphone_requested_; + bool needs_video_device = webcam_requested_; + + // Get the exact audio or video device if an id is specified. + if (!request_.requested_audio_device_id.empty()) { + const content::MediaStreamDevice* audio_device = + MediaCaptureDevicesDispatcher::GetInstance()-> + GetRequestedAudioDevice(request_.requested_audio_device_id); + if (audio_device) { + devices.push_back(*audio_device); + needs_audio_device = false; + } + } + if (!request_.requested_video_device_id.empty()) { + const content::MediaStreamDevice* video_device = + MediaCaptureDevicesDispatcher::GetInstance()-> + GetRequestedVideoDevice(request_.requested_video_device_id); + if (video_device) { + devices.push_back(*video_device); + needs_video_device = false; + } + } + + // If either or both audio and video devices were requested but not + // specified by id, get the default devices. + if (needs_audio_device || needs_video_device) { + MediaCaptureDevicesDispatcher::GetInstance()-> + GetDefaultDevices(needs_audio_device, + needs_video_device, + &devices); + } + break; + } case content::MEDIA_DEVICE_ACCESS: // Get the default devices for the request. MediaCaptureDevicesDispatcher::GetInstance()-> GetDefaultDevices(microphone_requested_, webcam_requested_, &devices); break; + case content::MEDIA_ENUMERATE_DEVICES: + // Do nothing. + NOTREACHED(); + break; } } - LOG(ERROR) << "Accept"; - callback_.Run(devices, scoped_ptr()); + content::MediaResponseCallback cb = callback_; + callback_.Reset(); + cb.Run(devices, scoped_ptr()); } void MediaStreamDevicesController::Deny() { - callback_.Run(content::MediaStreamDevices(), - scoped_ptr()); + content::MediaResponseCallback cb = callback_; + callback_.Reset(); + cb.Run(content::MediaStreamDevices(), scoped_ptr()); } -} // namespace brightray +} // namespace brightray diff --git a/brightray/browser/media/media_stream_devices_controller.h b/brightray/browser/media/media_stream_devices_controller.h index bcf4a0f0049e..8a029a38a08e 100644 --- a/brightray/browser/media/media_stream_devices_controller.h +++ b/brightray/browser/media/media_stream_devices_controller.h @@ -5,6 +5,8 @@ #ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ #define BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ +#include + #include "content/public/browser/web_contents_delegate.h" namespace brightray { @@ -16,18 +18,12 @@ class MediaStreamDevicesController { virtual ~MediaStreamDevicesController(); - // Public method to be called before creating the MediaStreamInfoBarDelegate. - // This function will check the content settings exceptions and take the - // corresponding action on exception which matches the request. bool TakeAction(); - // Public methods to be called by MediaStreamInfoBarDelegate; - bool has_audio() const { return microphone_requested_; } - bool has_video() const { return webcam_requested_; } + private: void Accept(); void Deny(); - private: // The original request for access to devices. const content::MediaStreamRequest request_; @@ -41,6 +37,6 @@ class MediaStreamDevicesController { DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); }; -} // namespace brightray +} // namespace brightray #endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ From 4d6ee2c4167548943095646e2b2ab1f6949baff7 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 16:21:01 -0400 Subject: [PATCH 17/28] URLRequestContextStorage::set_http_server_properties takes a scoped_ptr in Chrome 30 See http://src.chromium.org/viewvc/chrome?view=revision&revision=212466. --- brightray/browser/url_request_context_getter.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index 4595cf8c7134..4fe6d3f1b94f 100644 --- a/brightray/browser/url_request_context_getter.cc +++ b/brightray/browser/url_request_context_getter.cc @@ -87,7 +87,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); storage_->set_http_auth_handler_factory( net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); - storage_->set_http_server_properties(new net::HttpServerPropertiesImpl); + scoped_ptr server_properties(new net::HttpServerPropertiesImpl); + storage_->set_http_server_properties(server_properties.Pass()); base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache")); net::HttpCache::DefaultBackend* main_backend = From 91654243483e8986964813762d2b0305b54b0796 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 16:25:17 -0400 Subject: [PATCH 18/28] Update ResourceContext for Chrome 30 See http://src.chromium.org/viewvc/chrome?view=revision&revision=215991. --- brightray/browser/browser_context.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 26b62f4d3167..e43607a196c8 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -44,6 +44,16 @@ private: return getter_->GetURLRequestContext(); } + // FIXME: We should probably allow clients to override this to implement more restrictive policies. + virtual bool AllowMicAccess(const GURL& origin) OVERRIDE { + return true; + } + + // FIXME: We should probably allow clients to override this to implement more restrictive policies. + virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE { + return true; + } + URLRequestContextGetter* getter_; }; From b3b4ab2c70f4e0cfb4fb985bd4980ef771cf9587 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 17:02:35 -0400 Subject: [PATCH 19/28] Update ICU header include path I should have done this as part of #30. --- brightray/brightray.gyp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index b576b273ec75..e7e6fcd66059 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -21,7 +21,7 @@ '<(libchromiumcontent_include_dir)/third_party/skia/include/config', # For SkMatrix.h. '<(libchromiumcontent_include_dir)/third_party/skia/include/core', - '<(libchromiumcontent_include_dir)/third_party/icu/public/common', + '<(libchromiumcontent_include_dir)/third_party/icu/source/common', ], }, 'sources': [ From 1f1f93465bdfba49c383f7fdf91943be22c36057 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Mon, 7 Oct 2013 17:04:22 -0400 Subject: [PATCH 20/28] Make MediaStreamDevicesController::Accept/Deny public again Clients rely on this. --- brightray/browser/media/media_stream_devices_controller.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/brightray/browser/media/media_stream_devices_controller.h b/brightray/browser/media/media_stream_devices_controller.h index 8a029a38a08e..820c87213653 100644 --- a/brightray/browser/media/media_stream_devices_controller.h +++ b/brightray/browser/media/media_stream_devices_controller.h @@ -18,12 +18,14 @@ class MediaStreamDevicesController { virtual ~MediaStreamDevicesController(); + // Accept or deny the request based on the default policy. bool TakeAction(); - private: + // Explicitly accept or deny the request. void Accept(); void Deny(); + private: // The original request for access to devices. const content::MediaStreamRequest request_; From d06ac209473294f9c6056902b0bc951940acca25 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 8 Oct 2013 13:20:43 -0400 Subject: [PATCH 21/28] Update to latest libchromiumcontent * vendor/libchromiumcontent bfb2d7b...759a8d0 (1): > Remove googleurl/ from the distribution --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index bfb2d7bd95b4..759a8d09471f 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit bfb2d7bd95b41f328989622f7ac416c9544a9478 +Subproject commit 759a8d09471fef04acf32d5fc8c48676090b357d From c0e744db789008f764e0a07b46aab1c9391da0c0 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Wed, 9 Oct 2013 12:58:36 -0400 Subject: [PATCH 22/28] Update libchromiumcontent to use Xcode's clang * vendor/libchromiumcontent 759a8d0...21d99bd (1): > Merge pull request #28 from brightray/xcode-clang --- brightray/vendor/libchromiumcontent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 759a8d09471f..21d99bd412dd 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 759a8d09471fef04acf32d5fc8c48676090b357d +Subproject commit 21d99bd412dda76aca6bcc722134d24d8ea17746 From 8ae459e9fa34b8c3e8c485bfcdc00d4a787b68cd Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Thu, 10 Oct 2013 14:07:20 -0400 Subject: [PATCH 23/28] Work around http://crbug.com/279472 for devtools views --- brightray/browser/inspectable_web_contents_impl.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 341521cf9ba5..935026df3198 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -58,6 +58,12 @@ content::WebContents* InspectableWebContentsImpl::GetWebContents() const { void InspectableWebContentsImpl::ShowDevTools() { if (!devtools_web_contents_) { devtools_web_contents_.reset(content::WebContents::Create(content::WebContents::CreateParams(web_contents_->GetBrowserContext()))); + +#if defined(OS_MACOSX) + // Work around http://crbug.com/279472. + devtools_web_contents_->GetView()->SetAllowOverlappingViews(true); +#endif + Observe(devtools_web_contents_.get()); devtools_web_contents_->SetDelegate(this); From 6b9e61c65da7c1d373c9c0c11fa1f61dd90857d3 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Thu, 10 Oct 2013 16:23:52 -0400 Subject: [PATCH 24/28] Fix flashing in WebContents we create If the embedding app creates them it's up to them to fix this. --- brightray/browser/inspectable_web_contents.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/brightray/browser/inspectable_web_contents.cc b/brightray/browser/inspectable_web_contents.cc index ca3bded4a489..5e3af6013de3 100644 --- a/brightray/browser/inspectable_web_contents.cc +++ b/brightray/browser/inspectable_web_contents.cc @@ -2,10 +2,18 @@ #include "browser/inspectable_web_contents_impl.h" +#include "content/public/browser/web_contents_view.h" + namespace brightray { InspectableWebContents* InspectableWebContents::Create(const content::WebContents::CreateParams& create_params) { - return Create(content::WebContents::Create(create_params)); + auto contents = content::WebContents::Create(create_params); +#if defined(OS_MACOSX) + // Work around http://crbug.com/279472. + contents->GetView()->SetAllowOverlappingViews(true); +#endif + + return Create(contents); } InspectableWebContents* InspectableWebContents::Create(content::WebContents* web_contents) { From 9d29c8eb7c4343a54162ce4ff4bccb41343ad62b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 14 May 2013 14:45:34 +0800 Subject: [PATCH 25/28] Use the "chrome-devtools://" scheme to open devtools. --- brightray/brightray.gyp | 6 +- brightray/browser/browser_main_parts.cc | 12 +-- brightray/browser/browser_main_parts.h | 8 +- brightray/browser/devtools_delegate.cc | 49 --------- brightray/browser/devtools_delegate.h | 32 ------ brightray/browser/devtools_ui.cc | 102 ++++++++++++++++++ brightray/browser/devtools_ui.h | 28 +++++ .../browser/inspectable_web_contents_impl.cc | 9 +- .../browser/web_ui_controller_factory.cc | 59 ++++++++++ brightray/browser/web_ui_controller_factory.h | 42 ++++++++ 10 files changed, 246 insertions(+), 101 deletions(-) delete mode 100644 brightray/browser/devtools_delegate.cc delete mode 100644 brightray/browser/devtools_delegate.h create mode 100644 brightray/browser/devtools_ui.cc create mode 100644 brightray/browser/devtools_ui.h create mode 100644 brightray/browser/web_ui_controller_factory.cc create mode 100644 brightray/browser/web_ui_controller_factory.h diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index e7e6fcd66059..128d81ea77b8 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -35,8 +35,8 @@ 'browser/default_web_contents_delegate.cc', 'browser/default_web_contents_delegate.h', 'browser/default_web_contents_delegate_mac.mm', - 'browser/devtools_delegate.cc', - 'browser/devtools_delegate.h', + 'browser/devtools_ui.cc', + 'browser/devtools_ui.h', 'browser/download_manager_delegate.cc', 'browser/download_manager_delegate.h', 'browser/inspectable_web_contents.cc', @@ -66,6 +66,8 @@ 'browser/win/devtools_window.h', 'browser/win/inspectable_web_contents_view_win.cc', 'browser/win/inspectable_web_contents_view_win.h', + 'browser/web_ui_controller_factory.cc', + 'browser/web_ui_controller_factory.h', 'common/application_info.h', 'common/application_info_mac.mm', 'common/application_info_win.cc', diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index bb435057c056..15a7192d0093 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -5,9 +5,8 @@ #include "browser/browser_main_parts.h" #include "browser/browser_context.h" -#include "browser/devtools_delegate.h" +#include "browser/web_ui_controller_factory.h" -#include "content/public/browser/devtools_http_handler.h" #include "net/socket/tcp_listen_socket.h" namespace brightray { @@ -16,19 +15,14 @@ BrowserMainParts::BrowserMainParts() { } BrowserMainParts::~BrowserMainParts() { - devtools_http_handler_->Stop(); - devtools_http_handler_ = nullptr; } void BrowserMainParts::PreMainMessageLoopRun() { browser_context_.reset(CreateBrowserContext()); browser_context_->Initialize(); - // These two objects are owned by devtools_http_handler_. - auto delegate = new DevToolsDelegate; - auto factory = new net::TCPListenSocketFactory("127.0.0.1", 0); - - devtools_http_handler_ = content::DevToolsHttpHandler::Start(factory, std::string(), delegate); + web_ui_controller_factory_.reset(new WebUIControllerFactory(browser_context_.get())); + content::WebUIControllerFactory::RegisterFactory(web_ui_controller_factory_.get()); } BrowserContext* BrowserMainParts::CreateBrowserContext() { diff --git a/brightray/browser/browser_main_parts.h b/brightray/browser/browser_main_parts.h index 7120c619b0b3..ca80e557654f 100644 --- a/brightray/browser/browser_main_parts.h +++ b/brightray/browser/browser_main_parts.h @@ -9,13 +9,10 @@ #include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_main_parts.h" -namespace content { -class DevToolsHttpHandler; -} - namespace brightray { class BrowserContext; +class WebUIControllerFactory; class BrowserMainParts : public content::BrowserMainParts { public: @@ -23,7 +20,6 @@ public: ~BrowserMainParts(); BrowserContext* browser_context() { return browser_context_.get(); } - content::DevToolsHttpHandler* devtools_http_handler() { return devtools_http_handler_; } protected: // Subclasses should override this to provide their own BrowserContxt implementation. The caller @@ -38,7 +34,7 @@ protected: private: scoped_ptr browser_context_; - content::DevToolsHttpHandler* devtools_http_handler_; + scoped_ptr web_ui_controller_factory_; DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); }; diff --git a/brightray/browser/devtools_delegate.cc b/brightray/browser/devtools_delegate.cc deleted file mode 100644 index ccbcd362aa92..000000000000 --- a/brightray/browser/devtools_delegate.cc +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2012 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 "devtools_delegate.h" - -namespace brightray { - -DevToolsDelegate::DevToolsDelegate() { -} - -DevToolsDelegate::~DevToolsDelegate() { -} - -std::string DevToolsDelegate::GetDiscoveryPageHTML() { - return std::string(); -} - -bool DevToolsDelegate::BundlesFrontendResources() { - return true; -} - -base::FilePath DevToolsDelegate::GetDebugFrontendDir() { - return base::FilePath(); -} - -std::string DevToolsDelegate::GetPageThumbnailData(const GURL&) { - return std::string(); -} - -content::RenderViewHost* DevToolsDelegate::CreateNewTarget() { - return nullptr; -} - -content::DevToolsHttpHandlerDelegate::TargetType DevToolsDelegate::GetTargetType(content::RenderViewHost*) { - return kTargetTypeTab; -} - -std::string DevToolsDelegate::GetViewDescription(content::RenderViewHost*) { - return std::string(); -} - -scoped_refptr DevToolsDelegate::CreateSocketForTethering( - net::StreamListenSocket::Delegate*, - std::string* name) { - return nullptr; -} - -} diff --git a/brightray/browser/devtools_delegate.h b/brightray/browser/devtools_delegate.h deleted file mode 100644 index 12dd2087ee73..000000000000 --- a/brightray/browser/devtools_delegate.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2012 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 BRIGHTRAY_BROWSER_DEVTOOLS_DELEGATE_H_ -#define BRIGHTRAY_BROWSER_DEVTOOLS_DELEGATE_H_ - -#include "content/public/browser/devtools_http_handler_delegate.h" - -namespace brightray { - -class DevToolsDelegate : public content::DevToolsHttpHandlerDelegate { -public: - DevToolsDelegate(); - ~DevToolsDelegate(); - -private: - virtual std::string GetDiscoveryPageHTML() OVERRIDE; - virtual bool BundlesFrontendResources() OVERRIDE; - virtual base::FilePath GetDebugFrontendDir() OVERRIDE; - virtual std::string GetPageThumbnailData(const GURL&) OVERRIDE; - virtual content::RenderViewHost* CreateNewTarget() OVERRIDE; - virtual TargetType GetTargetType(content::RenderViewHost*) OVERRIDE; - virtual std::string GetViewDescription(content::RenderViewHost*) OVERRIDE; - virtual scoped_refptr CreateSocketForTethering( - net::StreamListenSocket::Delegate*, - std::string* name) OVERRIDE; -}; - -} - -#endif diff --git a/brightray/browser/devtools_ui.cc b/brightray/browser/devtools_ui.cc new file mode 100644 index 000000000000..571dc8adb626 --- /dev/null +++ b/brightray/browser/devtools_ui.cc @@ -0,0 +1,102 @@ +// Copyright (c) 2012 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/devtools_ui.h" + +#include + +#include "browser/browser_context.h" + +#include "base/memory/ref_counted_memory.h" +#include "base/strings/string_util.h" +#include "base/strings/stringprintf.h" +#include "content/public/browser/devtools_http_handler.h" +#include "content/public/browser/url_data_source.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui.h" +#include "ui/base/resource/resource_bundle.h" + +using content::WebContents; + +namespace brightray { + +namespace { + +const char kChromeUIDevToolsBundledHost[] = "devtools"; + +std::string PathWithoutParams(const std::string& path) { + return GURL(std::string("chrome-devtools://devtools/") + path) + .path().substr(1); +} + +std::string GetMimeTypeForPath(const std::string& path) { + std::string filename = PathWithoutParams(path); + if (EndsWith(filename, ".html", false)) { + return "text/html"; + } else if (EndsWith(filename, ".css", false)) { + return "text/css"; + } else if (EndsWith(filename, ".js", false)) { + return "application/javascript"; + } else if (EndsWith(filename, ".png", false)) { + return "image/png"; + } else if (EndsWith(filename, ".gif", false)) { + return "image/gif"; + } else if (EndsWith(filename, ".manifest", false)) { + return "text/cache-manifest"; + } + NOTREACHED(); + return "text/plain"; +} + +class BundledDataSource : public content::URLDataSource { + public: + explicit BundledDataSource() { + } + + // content::URLDataSource implementation. + virtual std::string GetSource() const OVERRIDE { + return kChromeUIDevToolsBundledHost; + } + + virtual void StartDataRequest(const std::string& path, + int render_process_id, + int render_view_id, + const GotDataCallback& callback) OVERRIDE { + std::string filename = PathWithoutParams(path); + + int resource_id = + content::DevToolsHttpHandler::GetFrontendResourceId(filename); + + DLOG_IF(WARNING, -1 == resource_id) << "Unable to find dev tool resource: " + << filename << ". If you compiled with debug_devtools=1, try running" + " with --debug-devtools."; + const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + scoped_refptr bytes(rb.LoadDataResourceBytes( + resource_id)); + callback.Run(bytes); + } + + virtual std::string GetMimeType(const std::string& path) const OVERRIDE { + return GetMimeTypeForPath(path); + } + + virtual bool ShouldAddContentSecurityPolicy() const OVERRIDE { + return false; + } + + private: + virtual ~BundledDataSource() {} + DISALLOW_COPY_AND_ASSIGN(BundledDataSource); +}; + +} + +DevToolsUI::DevToolsUI(BrowserContext* browser_context, content::WebUI* web_ui) + : WebUIController(web_ui), + browser_context_(browser_context) { + web_ui->SetBindings(0); + content::URLDataSource::Add(browser_context_, new BundledDataSource()); +} + +} diff --git a/brightray/browser/devtools_ui.h b/brightray/browser/devtools_ui.h new file mode 100644 index 000000000000..6ac205ab5488 --- /dev/null +++ b/brightray/browser/devtools_ui.h @@ -0,0 +1,28 @@ +// Copyright (c) 2011 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 BRIGHTRAY_BROWSER_DEVTOOLS_UI_H_ +#define BRIGHTRAY_BROWSER_DEVTOOLS_UI_H_ + +#include "base/compiler_specific.h" +#include "content/public/browser/web_ui_controller.h" + +namespace brightray { + +class BrowserContext; + +class DevToolsUI : public content::WebUIController { + public: + explicit DevToolsUI(BrowserContext* browser_context, content::WebUI* web_ui); + + private: + // Weak reference to the browser context. + BrowserContext* browser_context_; + + DISALLOW_COPY_AND_ASSIGN(DevToolsUI); +}; + +} + +#endif diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 935026df3198..f143768ec348 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -25,8 +25,13 @@ namespace brightray { namespace { +const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html"; const char kDockSidePref[] = "brightray.devtools.dockside"; +GURL GetDevToolsURL() { + return GURL(kChromeUIDevToolsURL); +} + } // Implemented separately on each platform. @@ -70,9 +75,7 @@ void InspectableWebContentsImpl::ShowDevTools() { agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_->GetRenderViewHost()); frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost(devtools_web_contents_.get(), this)); - auto handler = BrowserClient::Get()->browser_main_parts()->devtools_http_handler(); - auto url = handler->GetFrontendURL(nullptr); - devtools_web_contents_->GetController().LoadURL(url, content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); + devtools_web_contents_->GetController().LoadURL(GetDevToolsURL(), content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); } view_->SetDockSide(dock_side_); diff --git a/brightray/browser/web_ui_controller_factory.cc b/brightray/browser/web_ui_controller_factory.cc new file mode 100644 index 000000000000..61f6bf993c5a --- /dev/null +++ b/brightray/browser/web_ui_controller_factory.cc @@ -0,0 +1,59 @@ +// Copyright (c) 2013 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/web_ui_controller_factory.h" + +#include "browser/browser_context.h" +#include "browser/devtools_ui.h" + +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_ui.h" +#include "content/public/common/url_constants.h" + +namespace brightray { + +namespace { + +const char kChromeUIDevToolsBundledHost[] = "devtools"; + +} + +WebUIControllerFactory::WebUIControllerFactory(BrowserContext* browser_context) + : browser_context_(browser_context) { + DCHECK(browser_context_); +} + +WebUIControllerFactory::~WebUIControllerFactory() { +} + +content::WebUI::TypeID WebUIControllerFactory::GetWebUIType( + content::BrowserContext* browser_context, const GURL& url) const { + if (url.host() == kChromeUIDevToolsBundledHost) { + return const_cast(this); + } + + return content::WebUI::kNoWebUI; +} + +bool WebUIControllerFactory::UseWebUIForURL( + content::BrowserContext* browser_context, const GURL& url) const { + return GetWebUIType(browser_context, url) != content::WebUI::kNoWebUI; +} + +bool WebUIControllerFactory::UseWebUIBindingsForURL( + content::BrowserContext* browser_context, const GURL& url) const { + return UseWebUIForURL(browser_context, url); +} + +content::WebUIController* WebUIControllerFactory::CreateWebUIControllerForURL( + content::WebUI* web_ui, const GURL& url) const { + DCHECK(browser_context_); + + if (url.host() == kChromeUIDevToolsBundledHost) + return new DevToolsUI(browser_context_, web_ui); + + return NULL; +} + +} diff --git a/brightray/browser/web_ui_controller_factory.h b/brightray/browser/web_ui_controller_factory.h new file mode 100644 index 000000000000..1ee3f9b2dfd0 --- /dev/null +++ b/brightray/browser/web_ui_controller_factory.h @@ -0,0 +1,42 @@ +// Copyright (c) 2013 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 BRIGHTRAY_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_ +#define BRIGHTRAY_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_ + +#include "base/basictypes.h" +#include "content/public/browser/web_ui.h" +#include "content/public/browser/web_ui_controller_factory.h" + +namespace brightray { + +class BrowserContext; + +class WebUIControllerFactory : public content::WebUIControllerFactory { + public: + WebUIControllerFactory(BrowserContext* browser_context); + virtual ~WebUIControllerFactory(); + + virtual content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context, + const GURL& url) const OVERRIDE; + virtual bool UseWebUIForURL(content::BrowserContext* browser_context, + const GURL& url) const OVERRIDE; + virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, + const GURL& url) const OVERRIDE; + virtual content::WebUIController* CreateWebUIControllerForURL( + content::WebUI* web_ui, + const GURL& url) const OVERRIDE; + + static WebUIControllerFactory* GetInstance(); + + private: + // Weak reference to the browser context. + BrowserContext* browser_context_; + + DISALLOW_COPY_AND_ASSIGN(WebUIControllerFactory); +}; + +} + +#endif From 2cd6dd791eca7bcecfddfdbce3f8aa2829c4d426 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 14 May 2013 15:17:17 +0800 Subject: [PATCH 26/28] Setup devtools in the correct phase. * RegisterDevToolsClientHostFor should be called right after the agent_host and the frontend host are created. * SetupDevToolsFrontendClient should be called before the devtools window is going to start navigation. --- brightray/browser/inspectable_web_contents_impl.cc | 5 ++++- brightray/browser/inspectable_web_contents_impl.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index f143768ec348..48da9f1fb005 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -74,6 +74,7 @@ void InspectableWebContentsImpl::ShowDevTools() { agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_->GetRenderViewHost()); frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost(devtools_web_contents_.get(), this)); + content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, frontend_host_.get()); devtools_web_contents_->GetController().LoadURL(GetDevToolsURL(), content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); } @@ -145,8 +146,10 @@ void InspectableWebContentsImpl::InspectedContentsClosing() { } void InspectableWebContentsImpl::RenderViewCreated(content::RenderViewHost* render_view_host) { +} + +void InspectableWebContentsImpl::AboutToNavigateRenderView(content::RenderViewHost* render_view_host) { content::DevToolsClientHost::SetupDevToolsFrontendClient(web_contents()->GetRenderViewHost()); - content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, frontend_host_.get()); } void InspectableWebContentsImpl::DidFinishLoad(int64, const GURL&, bool is_main_frame, content::RenderViewHost*) { diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index b2a772047207..c47eb871cd6e 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -70,6 +70,7 @@ private: // content::WebContentsObserver virtual void RenderViewCreated(content::RenderViewHost*) OVERRIDE; + virtual void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) OVERRIDE; virtual void DidFinishLoad(int64 frame_id, const GURL& validated_url, bool is_main_frame, From f623ddf7fc7ed00ac1ab16c6f72a4c4c73999bfd Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 14 May 2013 15:36:40 +0800 Subject: [PATCH 27/28] Cleanup unused headers, data members and functions. --- brightray/browser/browser_main_parts.cc | 2 -- brightray/browser/devtools_ui.cc | 5 ++--- brightray/browser/devtools_ui.h | 3 --- brightray/browser/inspectable_web_contents_impl.cc | 10 ++-------- brightray/browser/inspectable_web_contents_impl.h | 1 - 5 files changed, 4 insertions(+), 17 deletions(-) diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index 15a7192d0093..8bcaf3621b11 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -7,8 +7,6 @@ #include "browser/browser_context.h" #include "browser/web_ui_controller_factory.h" -#include "net/socket/tcp_listen_socket.h" - namespace brightray { BrowserMainParts::BrowserMainParts() { diff --git a/brightray/browser/devtools_ui.cc b/brightray/browser/devtools_ui.cc index 571dc8adb626..94e581728ab8 100644 --- a/brightray/browser/devtools_ui.cc +++ b/brightray/browser/devtools_ui.cc @@ -93,10 +93,9 @@ class BundledDataSource : public content::URLDataSource { } DevToolsUI::DevToolsUI(BrowserContext* browser_context, content::WebUI* web_ui) - : WebUIController(web_ui), - browser_context_(browser_context) { + : WebUIController(web_ui) { web_ui->SetBindings(0); - content::URLDataSource::Add(browser_context_, new BundledDataSource()); + content::URLDataSource::Add(browser_context, new BundledDataSource()); } } diff --git a/brightray/browser/devtools_ui.h b/brightray/browser/devtools_ui.h index 6ac205ab5488..70ab0f2686da 100644 --- a/brightray/browser/devtools_ui.h +++ b/brightray/browser/devtools_ui.h @@ -17,9 +17,6 @@ class DevToolsUI : public content::WebUIController { explicit DevToolsUI(BrowserContext* browser_context, content::WebUI* web_ui); private: - // Weak reference to the browser context. - BrowserContext* browser_context_; - DISALLOW_COPY_AND_ASSIGN(DevToolsUI); }; diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 48da9f1fb005..08d820d46311 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -28,10 +28,6 @@ namespace { const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html"; const char kDockSidePref[] = "brightray.devtools.dockside"; -GURL GetDevToolsURL() { - return GURL(kChromeUIDevToolsURL); -} - } // Implemented separately on each platform. @@ -76,7 +72,8 @@ void InspectableWebContentsImpl::ShowDevTools() { frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost(devtools_web_contents_.get(), this)); content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, frontend_host_.get()); - devtools_web_contents_->GetController().LoadURL(GetDevToolsURL(), content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); + GURL devtools_url(kChromeUIDevToolsURL); + devtools_web_contents_->GetController().LoadURL(devtools_url, content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); } view_->SetDockSide(dock_side_); @@ -145,9 +142,6 @@ void InspectableWebContentsImpl::SearchInPath(int request_id, const std::string& void InspectableWebContentsImpl::InspectedContentsClosing() { } -void InspectableWebContentsImpl::RenderViewCreated(content::RenderViewHost* render_view_host) { -} - void InspectableWebContentsImpl::AboutToNavigateRenderView(content::RenderViewHost* render_view_host) { content::DevToolsClientHost::SetupDevToolsFrontendClient(web_contents()->GetRenderViewHost()); } diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index c47eb871cd6e..f81ccc0185a6 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -69,7 +69,6 @@ private: // content::WebContentsObserver - virtual void RenderViewCreated(content::RenderViewHost*) OVERRIDE; virtual void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) OVERRIDE; virtual void DidFinishLoad(int64 frame_id, const GURL& validated_url, From ae1e26bdddfb8a249d78f2fd0f0f469c96165a88 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Wed, 23 Oct 2013 12:13:24 -0400 Subject: [PATCH 28/28] Fix a hang on quit when application cache is used If you navigated to a page that used the HTML Application Cache, you'd see a hang on quit with a backtrace like so: + 2825 content::ContentMain(int, char const**, content::ContentMainDelegate*) (in libchromiumcontent.dylib) + 64 [0xb33190] + 2825 ??? (in libchromiumcontent.dylib) load address 0x1c9000 + 0x96b261 [0xb34261] + 2825 ??? (in libchromiumcontent.dylib) load address 0x1c9000 + 0x96a409 [0xb33409] + 2825 content::BrowserMain(content::MainFunctionParams const&) (in libchromiumcontent.dylib) + 200 [0x14290b8] + 2825 ??? (in libchromiumcontent.dylib) load address 0x1c9000 + 0x1265426 [0x142e426] + 2825 content::BrowserMainLoop::~BrowserMainLoop() (in libchromiumcontent.dylib) + 17 [0x14294a1] + 2825 content::BrowserMainLoop::~BrowserMainLoop() (in libchromiumcontent.dylib) + 357 [0x1429625] + 2825 brightray::BrowserMainParts::~BrowserMainParts() (in ) + 70 [0x68df6] + 2825 scoped_ptr >::~scoped_ptr() (in ) + 23 [0x68ff7] + 2825 scoped_ptr >::~scoped_ptr() (in ) + 23 [0x69297] + 2825 base::internal::scoped_ptr_impl >::~scoped_ptr_impl() (in ) + 23 [0x692b7] + 2825 base::internal::scoped_ptr_impl >::~scoped_ptr_impl() (in ) + 50 [0x692f2] + 2825 base::DefaultDeleter::operator()(brightray::BrowserContext*) const (in ) + 46 [0x6916e] + 2825 brightray::BrowserContext::~BrowserContext() (in ) + 127 [0x672bf] + 2825 base::SupportsUserData::~SupportsUserData() (in libchromiumcontent.dylib) + 57 [0xccc019] + 2825 ??? (in libchromiumcontent.dylib) load address 0x1c9000 + 0xb03230 [0xccc230] + 2825 ??? (in libchromiumcontent.dylib) load address 0x1c9000 + 0xb0324e [0xccc24e] + 2825 ??? (in libchromiumcontent.dylib) load address 0x1c9000 + 0x14c4239 [0x168d239] + 2825 content::StoragePartitionImpl::~StoragePartitionImpl() (in libchromiumcontent.dylib) + 17 [0x16899a1] + 2825 content::StoragePartitionImpl::~StoragePartitionImpl() (in libchromiumcontent.dylib) + 491 [0x1689bab] + 2825 content::ChromeAppCacheService::DeleteOnCorrectThread() const (in libchromiumcontent.dylib) + 66 [0x1424f32] + 2825 content::ChromeAppCacheService::~ChromeAppCacheService() (in libchromiumcontent.dylib) + 50 [0x1424e32] + 2825 appcache::AppCacheService::~AppCacheService() (in libchromiumcontent.dylib) + 301 [0x2b8ad2d] + 2825 ??? (in libchromiumcontent.dylib) load address 0x1c9000 + 0x29c9b81 [0x2b92b81] + 2825 ??? (in libchromiumcontent.dylib) load address 0x1c9000 + 0x29c9da4 [0x2b92da4] + 2825 appcache::AppCacheDiskCache::~AppCacheDiskCache() (in libchromiumcontent.dylib) + 17 [0x2b78c71] + 2825 appcache::AppCacheDiskCache::~AppCacheDiskCache() (in libchromiumcontent.dylib) + 135 [0x2b78d17] + 2825 disk_cache::BackendImpl::~BackendImpl() (in libchromiumcontent.dylib) + 17 [0x25979a1] + 2825 disk_cache::BackendImpl::~BackendImpl() (in libchromiumcontent.dylib) + 305 [0x2597af1] + 2825 base::WaitableEvent::Wait() (in libchromiumcontent.dylib) + 50 [0xccd942] + 2825 base::WaitableEvent::TimedWait(base::TimeDelta const&) (in libchromiumcontent.dylib) + 347 [0xccdb3b] + 2825 base::ConditionVariable::Wait() (in libchromiumcontent.dylib) + 35 [0xcccbb3] + 2825 pthread_cond_wait$UNIX2003 (in libsystem_c.dylib) + 71 [0x964d3089] + 2825 _pthread_cond_wait (in libsystem_c.dylib) + 833 [0x9644d280] + 2825 __psynch_cvwait (in libsystem_kernel.dylib) + 10 [0x94b8e8e2] BackendImpl was waiting on BrowserThread::CACHE, but that thread had already been stopped. The solution is to destroy the BrowserContext before threads have been stopped. We now do this in BrowserMainParts::PostMainMessageLoopRun, which matches content_shell. --- brightray/browser/browser_main_parts.cc | 4 ++++ brightray/browser/browser_main_parts.h | 1 + 2 files changed, 5 insertions(+) diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index 8bcaf3621b11..c41a6a3a6f37 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -23,6 +23,10 @@ void BrowserMainParts::PreMainMessageLoopRun() { content::WebUIControllerFactory::RegisterFactory(web_ui_controller_factory_.get()); } +void BrowserMainParts::PostMainMessageLoopRun() { + browser_context_.reset(); +} + BrowserContext* BrowserMainParts::CreateBrowserContext() { return new BrowserContext; } diff --git a/brightray/browser/browser_main_parts.h b/brightray/browser/browser_main_parts.h index ca80e557654f..210ff7e31ba0 100644 --- a/brightray/browser/browser_main_parts.h +++ b/brightray/browser/browser_main_parts.h @@ -31,6 +31,7 @@ protected: #endif virtual void PreMainMessageLoopRun() OVERRIDE; + virtual void PostMainMessageLoopRun() OVERRIDE; private: scoped_ptr browser_context_;