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/brightray.gyp b/brightray/brightray.gyp index 7b5f88a3e988..b40bcd8006bc 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': [ @@ -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', @@ -68,6 +68,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_context.cc b/brightray/browser/browser_context.cc index 31c00b8d6aa0..e43607a196c8 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -44,10 +44,35 @@ 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_; }; 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, @@ -83,21 +108,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_; } @@ -125,6 +136,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(); } @@ -139,10 +154,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 85f00148c9c0..f18cfdadced6 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(); } @@ -33,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; @@ -46,10 +48,10 @@ 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; - virtual content::SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; base::FilePath path_; diff --git a/brightray/browser/browser_main_parts.cc b/brightray/browser/browser_main_parts.cc index 04e67f24fb18..c41a6a3a6f37 100644 --- a/brightray/browser/browser_main_parts.cc +++ b/brightray/browser/browser_main_parts.cc @@ -5,10 +5,7 @@ #include "browser/browser_main_parts.h" #include "browser/browser_context.h" -#include "browser/devtools_delegate.h" - -#include "content/public/browser/devtools_http_handler.h" -#include "net/socket/tcp_listen_socket.h" +#include "browser/web_ui_controller_factory.h" namespace brightray { @@ -16,18 +13,18 @@ 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); + web_ui_controller_factory_.reset(new WebUIControllerFactory(browser_context_.get())); + content::WebUIControllerFactory::RegisterFactory(web_ui_controller_factory_.get()); +} - devtools_http_handler_ = content::DevToolsHttpHandler::Start(factory, std::string(), delegate); +void BrowserMainParts::PostMainMessageLoopRun() { + browser_context_.reset(); } BrowserContext* BrowserMainParts::CreateBrowserContext() { diff --git a/brightray/browser/browser_main_parts.h b/brightray/browser/browser_main_parts.h index 7120c619b0b3..210ff7e31ba0 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 @@ -35,10 +31,11 @@ protected: #endif virtual void PreMainMessageLoopRun() OVERRIDE; + virtual void PostMainMessageLoopRun() OVERRIDE; 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..94e581728ab8 --- /dev/null +++ b/brightray/browser/devtools_ui.cc @@ -0,0 +1,101 @@ +// 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) { + 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..70ab0f2686da --- /dev/null +++ b/brightray/browser/devtools_ui.h @@ -0,0 +1,25 @@ +// 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: + DISALLOW_COPY_AND_ASSIGN(DevToolsUI); +}; + +} + +#endif 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) { diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 7f694ad54ff5..08d820d46311 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -12,8 +12,8 @@ #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/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" #include "content/public/browser/devtools_http_handler.h" @@ -25,6 +25,7 @@ namespace brightray { namespace { +const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html"; const char kDockSidePref[] = "brightray.devtools.dockside"; } @@ -58,15 +59,21 @@ 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); 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()); - 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()); + GURL devtools_url(kChromeUIDevToolsURL); + devtools_web_contents_->GetController().LoadURL(devtools_url, content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); } view_->SetDockSide(dock_side_); @@ -123,12 +130,20 @@ 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() { } -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 95293e062bd8..f81ccc0185a6 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -60,11 +60,16 @@ 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 - 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, 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/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..820c87213653 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,14 +18,10 @@ 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. + // Accept or deny the request based on the default policy. bool TakeAction(); - // Public methods to be called by MediaStreamInfoBarDelegate; - bool has_audio() const { return microphone_requested_; } - bool has_video() const { return webcam_requested_; } + // Explicitly accept or deny the request. void Accept(); void Deny(); @@ -41,6 +39,6 @@ class MediaStreamDevicesController { DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); }; -} // namespace brightray +} // namespace brightray #endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ 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 02ca2927fe38..dc2ad9231fba 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" @@ -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); } } diff --git a/brightray/browser/url_request_context_getter.cc b/brightray/browser/url_request_context_getter.cc index e6d73a608f36..4fe6d3f1b94f 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" @@ -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), @@ -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 = 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 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 { diff --git a/brightray/common/content_client.cc b/brightray/common/content_client.cc index 87cc07abfeee..a518cc026ca9 100644 --- a/brightray/common/content_client.cc +++ b/brightray/common/content_client.cc @@ -6,10 +6,10 @@ #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/user_agent/user_agent_util.h" +#include "webkit/common/user_agent/user_agent_util.h" namespace brightray { 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" 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 diff --git a/brightray/vendor/libchromiumcontent b/brightray/vendor/libchromiumcontent index 5ffcb396d64d..21d99bd412dd 160000 --- a/brightray/vendor/libchromiumcontent +++ b/brightray/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 5ffcb396d64df97a2d0220101e1e52598a661fc8 +Subproject commit 21d99bd412dda76aca6bcc722134d24d8ea17746