Merge branch 'master' into linux

This commit is contained in:
Patrick Reynolds 2013-11-08 20:53:43 -06:00
commit 6053911bd2
30 changed files with 550 additions and 248 deletions

View file

@ -1,3 +1,6 @@
[submodule "vendor/libchromiumcontent"] [submodule "vendor/libchromiumcontent"]
path = vendor/libchromiumcontent path = vendor/libchromiumcontent
url = https://github.com/brightray/libchromiumcontent url = https://github.com/brightray/libchromiumcontent
[submodule "vendor/gyp"]
path = vendor/gyp
url = https://github.com/svn2github/gyp

View file

@ -14,7 +14,6 @@ sample application written using Brightray.
### Prerequisites ### Prerequisites
* Python 2.7 * Python 2.7
* gyp
* Linux: * Linux:
* Clang 3.0 * Clang 3.0
* Mac: * Mac:

View file

@ -21,7 +21,7 @@
'<(libchromiumcontent_include_dir)/third_party/skia/include/config', '<(libchromiumcontent_include_dir)/third_party/skia/include/config',
# For SkMatrix.h. # For SkMatrix.h.
'<(libchromiumcontent_include_dir)/third_party/skia/include/core', '<(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': [ 'sources': [
@ -35,8 +35,8 @@
'browser/default_web_contents_delegate.cc', 'browser/default_web_contents_delegate.cc',
'browser/default_web_contents_delegate.h', 'browser/default_web_contents_delegate.h',
'browser/default_web_contents_delegate_mac.mm', 'browser/default_web_contents_delegate_mac.mm',
'browser/devtools_delegate.cc', 'browser/devtools_ui.cc',
'browser/devtools_delegate.h', 'browser/devtools_ui.h',
'browser/download_manager_delegate.cc', 'browser/download_manager_delegate.cc',
'browser/download_manager_delegate.h', 'browser/download_manager_delegate.h',
'browser/inspectable_web_contents.cc', 'browser/inspectable_web_contents.cc',
@ -68,6 +68,8 @@
'browser/win/devtools_window.h', 'browser/win/devtools_window.h',
'browser/win/inspectable_web_contents_view_win.cc', 'browser/win/inspectable_web_contents_view_win.cc',
'browser/win/inspectable_web_contents_view_win.h', '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.h',
'common/application_info_mac.mm', 'common/application_info_mac.mm',
'common/application_info_win.cc', 'common/application_info_win.cc',

View file

@ -44,10 +44,35 @@ private:
return getter_->GetURLRequestContext(); 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_; URLRequestContextGetter* getter_;
}; };
BrowserContext::BrowserContext() : resource_context_(new ResourceContext) { BrowserContext::BrowserContext() : resource_context_(new ResourceContext) {
}
void BrowserContext::Initialize() {
base::FilePath path;
#if defined(OS_LINUX)
scoped_ptr<base::Environment> 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")); auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences"));
PrefServiceBuilder builder; PrefServiceBuilder builder;
builder.WithUserFilePrefs(prefs_path, builder.WithUserFilePrefs(prefs_path,
@ -83,21 +108,7 @@ scoped_ptr<NetworkDelegate> BrowserContext::CreateNetworkDelegate() {
return make_scoped_ptr(new NetworkDelegate).Pass(); return make_scoped_ptr(new NetworkDelegate).Pass();
} }
base::FilePath BrowserContext::GetPath() { base::FilePath BrowserContext::GetPath() const {
if (!path_.empty())
return path_;
base::FilePath path;
#if defined(OS_LINUX)
scoped_ptr<base::Environment> 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()));
return path_; return path_;
} }
@ -125,6 +136,10 @@ net::URLRequestContextGetter* BrowserContext::GetMediaRequestContextForStoragePa
return GetRequestContext(); 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() { content::ResourceContext* BrowserContext::GetResourceContext() {
return resource_context_.get(); return resource_context_.get();
} }
@ -139,10 +154,6 @@ content::GeolocationPermissionContext* BrowserContext::GetGeolocationPermissionC
return nullptr; return nullptr;
} }
content::SpeechRecognitionPreferences* BrowserContext::GetSpeechRecognitionPreferences() {
return nullptr;
}
quota::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() { quota::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() {
return nullptr; return nullptr;
} }

View file

@ -22,6 +22,8 @@ public:
BrowserContext(); BrowserContext();
~BrowserContext(); ~BrowserContext();
void Initialize();
net::URLRequestContextGetter* CreateRequestContext(content::ProtocolHandlerMap*); net::URLRequestContextGetter* CreateRequestContext(content::ProtocolHandlerMap*);
PrefService* prefs() { return prefs_.get(); } PrefService* prefs() { return prefs_.get(); }
@ -33,7 +35,7 @@ protected:
// Subclasses should override this to provide a custom NetworkDelegate implementation. // Subclasses should override this to provide a custom NetworkDelegate implementation.
virtual scoped_ptr<NetworkDelegate> CreateNetworkDelegate(); virtual scoped_ptr<NetworkDelegate> CreateNetworkDelegate();
virtual base::FilePath GetPath() OVERRIDE; virtual base::FilePath GetPath() const OVERRIDE;
private: private:
class ResourceContext; class ResourceContext;
@ -46,10 +48,10 @@ private:
virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(int renderer_child_id) OVERRIDE; virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(int renderer_child_id) OVERRIDE;
virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory); 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::ResourceContext* GetResourceContext() OVERRIDE;
virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE; virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE;
virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE; virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE;
virtual content::SpeechRecognitionPreferences* GetSpeechRecognitionPreferences() OVERRIDE;
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
base::FilePath path_; base::FilePath path_;

View file

@ -5,10 +5,7 @@
#include "browser/browser_main_parts.h" #include "browser/browser_main_parts.h"
#include "browser/browser_context.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 { namespace brightray {
@ -16,18 +13,18 @@ BrowserMainParts::BrowserMainParts() {
} }
BrowserMainParts::~BrowserMainParts() { BrowserMainParts::~BrowserMainParts() {
devtools_http_handler_->Stop();
devtools_http_handler_ = nullptr;
} }
void BrowserMainParts::PreMainMessageLoopRun() { void BrowserMainParts::PreMainMessageLoopRun() {
browser_context_.reset(CreateBrowserContext()); browser_context_.reset(CreateBrowserContext());
browser_context_->Initialize();
// These two objects are owned by devtools_http_handler_. web_ui_controller_factory_.reset(new WebUIControllerFactory(browser_context_.get()));
auto delegate = new DevToolsDelegate; content::WebUIControllerFactory::RegisterFactory(web_ui_controller_factory_.get());
auto factory = new net::TCPListenSocketFactory("127.0.0.1", 0); }
devtools_http_handler_ = content::DevToolsHttpHandler::Start(factory, std::string(), delegate); void BrowserMainParts::PostMainMessageLoopRun() {
browser_context_.reset();
} }
BrowserContext* BrowserMainParts::CreateBrowserContext() { BrowserContext* BrowserMainParts::CreateBrowserContext() {

View file

@ -9,13 +9,10 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "content/public/browser/browser_main_parts.h" #include "content/public/browser/browser_main_parts.h"
namespace content {
class DevToolsHttpHandler;
}
namespace brightray { namespace brightray {
class BrowserContext; class BrowserContext;
class WebUIControllerFactory;
class BrowserMainParts : public content::BrowserMainParts { class BrowserMainParts : public content::BrowserMainParts {
public: public:
@ -23,7 +20,6 @@ public:
~BrowserMainParts(); ~BrowserMainParts();
BrowserContext* browser_context() { return browser_context_.get(); } BrowserContext* browser_context() { return browser_context_.get(); }
content::DevToolsHttpHandler* devtools_http_handler() { return devtools_http_handler_; }
protected: protected:
// Subclasses should override this to provide their own BrowserContxt implementation. The caller // Subclasses should override this to provide their own BrowserContxt implementation. The caller
@ -35,10 +31,11 @@ protected:
#endif #endif
virtual void PreMainMessageLoopRun() OVERRIDE; virtual void PreMainMessageLoopRun() OVERRIDE;
virtual void PostMainMessageLoopRun() OVERRIDE;
private: private:
scoped_ptr<BrowserContext> browser_context_; scoped_ptr<BrowserContext> browser_context_;
content::DevToolsHttpHandler* devtools_http_handler_; scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
DISALLOW_COPY_AND_ASSIGN(BrowserMainParts); DISALLOW_COPY_AND_ASSIGN(BrowserMainParts);
}; };

View file

@ -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<net::StreamListenSocket> DevToolsDelegate::CreateSocketForTethering(
net::StreamListenSocket::Delegate*,
std::string* name) {
return nullptr;
}
}

View file

@ -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<net::StreamListenSocket> CreateSocketForTethering(
net::StreamListenSocket::Delegate*,
std::string* name) OVERRIDE;
};
}
#endif

View file

@ -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 <string>
#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<base::RefCountedStaticMemory> 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());
}
}

View file

@ -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

View file

@ -2,10 +2,18 @@
#include "browser/inspectable_web_contents_impl.h" #include "browser/inspectable_web_contents_impl.h"
#include "content/public/browser/web_contents_view.h"
namespace brightray { namespace brightray {
InspectableWebContents* InspectableWebContents::Create(const content::WebContents::CreateParams& create_params) { 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) { InspectableWebContents* InspectableWebContents::Create(content::WebContents* web_contents) {

View file

@ -12,8 +12,8 @@
#include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "base/stringprintf.h" #include "base/strings/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_agent_host.h"
#include "content/public/browser/devtools_client_host.h" #include "content/public/browser/devtools_client_host.h"
#include "content/public/browser/devtools_http_handler.h" #include "content/public/browser/devtools_http_handler.h"
@ -25,6 +25,7 @@ namespace brightray {
namespace { namespace {
const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html";
const char kDockSidePref[] = "brightray.devtools.dockside"; const char kDockSidePref[] = "brightray.devtools.dockside";
} }
@ -58,15 +59,21 @@ content::WebContents* InspectableWebContentsImpl::GetWebContents() const {
void InspectableWebContentsImpl::ShowDevTools() { void InspectableWebContentsImpl::ShowDevTools() {
if (!devtools_web_contents_) { if (!devtools_web_contents_) {
devtools_web_contents_.reset(content::WebContents::Create(content::WebContents::CreateParams(web_contents_->GetBrowserContext()))); 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()); Observe(devtools_web_contents_.get());
devtools_web_contents_->SetDelegate(this); devtools_web_contents_->SetDelegate(this);
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_->GetRenderViewHost()); agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_->GetRenderViewHost());
frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost(devtools_web_contents_.get(), this)); 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(); GURL devtools_url(kChromeUIDevToolsURL);
auto url = handler->GetFrontendURL(nullptr); devtools_web_contents_->GetController().LoadURL(devtools_url, content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
devtools_web_contents_->GetController().LoadURL(url, content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
} }
view_->SetDockSide(dock_side_); view_->SetDockSide(dock_side_);
@ -123,12 +130,20 @@ void InspectableWebContentsImpl::AddFileSystem() {
void InspectableWebContentsImpl::RemoveFileSystem(const std::string& file_system_path) { 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::InspectedContentsClosing() {
} }
void InspectableWebContentsImpl::RenderViewCreated(content::RenderViewHost* render_view_host) { void InspectableWebContentsImpl::AboutToNavigateRenderView(content::RenderViewHost* render_view_host) {
content::DevToolsClientHost::SetupDevToolsFrontendClient(web_contents()->GetRenderViewHost()); 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*) { void InspectableWebContentsImpl::DidFinishLoad(int64, const GURL&, bool is_main_frame, content::RenderViewHost*) {

View file

@ -60,11 +60,16 @@ private:
virtual void RequestFileSystems() OVERRIDE; virtual void RequestFileSystems() OVERRIDE;
virtual void AddFileSystem() OVERRIDE; virtual void AddFileSystem() OVERRIDE;
virtual void RemoveFileSystem(const std::string& file_system_path) 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; virtual void InspectedContentsClosing() OVERRIDE;
// content::WebContentsObserver // content::WebContentsObserver
virtual void RenderViewCreated(content::RenderViewHost*) OVERRIDE; virtual void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) OVERRIDE;
virtual void DidFinishLoad(int64 frame_id, virtual void DidFinishLoad(int64 frame_id,
const GURL& validated_url, const GURL& validated_url,
bool is_main_frame, bool is_main_frame,

View file

@ -3,7 +3,7 @@
#import "browser/inspectable_web_contents_view.h" #import "browser/inspectable_web_contents_view.h"
#import "base/memory/scoped_nsobject.h" #import "base/mac/scoped_nsobject.h"
@class BRYInspectableWebContentsView; @class BRYInspectableWebContentsView;
@ -26,7 +26,7 @@ private:
// Owns us. // Owns us.
InspectableWebContentsImpl* inspectable_web_contents_; InspectableWebContentsImpl* inspectable_web_contents_;
scoped_nsobject<BRYInspectableWebContentsView> view_; base::scoped_nsobject<BRYInspectableWebContentsView> view_;
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewMac); DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewMac);
}; };

View file

@ -4,9 +4,10 @@
#include "browser/media/media_capture_devices_dispatcher.h" #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/browser_thread.h"
#include "content/public/browser/media_devices_monitor.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" #include "content/public/common/media_stream_request.h"
namespace brightray { namespace brightray {
@ -16,41 +17,40 @@ using content::MediaStreamDevices;
namespace { 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 content::MediaStreamDevices& devices,
const std::string& device_id) { const std::string& device_id) {
if (devices.empty())
return NULL;
content::MediaStreamDevices::const_iterator iter = devices.begin(); content::MediaStreamDevices::const_iterator iter = devices.begin();
for (; iter != devices.end(); ++iter) { for (; iter != devices.end(); ++iter) {
if (iter->id == device_id) { if (iter->id == device_id) {
return &(*iter); return &(*iter);
} }
} }
return NULL;
return &(*devices.begin());
}; };
} // namespace } // namespace
MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() { MediaCaptureDevicesDispatcher* MediaCaptureDevicesDispatcher::GetInstance() {
return Singleton<MediaCaptureDevicesDispatcher>::get(); return Singleton<MediaCaptureDevicesDispatcher>::get();
} }
MediaCaptureDevicesDispatcher::MediaCaptureDevicesDispatcher() 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() {} MediaCaptureDevicesDispatcher::~MediaCaptureDevicesDispatcher() {}
const MediaStreamDevices& const MediaStreamDevices&
MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() { MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!devices_enumerated_) { if (!is_device_enumeration_disabled_ && !devices_enumerated_) {
BrowserThread::PostTask( content::EnsureMonitorCaptureDevices();
BrowserThread::IO, FROM_HERE,
base::Bind(&content::EnsureMonitorCaptureDevices));
devices_enumerated_ = true; devices_enumerated_ = true;
} }
return audio_devices_; return audio_devices_;
@ -59,17 +59,14 @@ MediaCaptureDevicesDispatcher::GetAudioCaptureDevices() {
const MediaStreamDevices& const MediaStreamDevices&
MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() { MediaCaptureDevicesDispatcher::GetVideoCaptureDevices() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!devices_enumerated_) { if (!is_device_enumeration_disabled_ && !devices_enumerated_) {
BrowserThread::PostTask( content::EnsureMonitorCaptureDevices();
BrowserThread::IO, FROM_HERE,
base::Bind(&content::EnsureMonitorCaptureDevices));
devices_enumerated_ = true; devices_enumerated_ = true;
} }
return video_devices_; return video_devices_;
} }
void MediaCaptureDevicesDispatcher::GetRequestedDevice( void MediaCaptureDevicesDispatcher::GetDefaultDevices(
const std::string& requested_device_id,
bool audio, bool audio,
bool video, bool video,
content::MediaStreamDevices* devices) { content::MediaStreamDevices* devices) {
@ -77,32 +74,58 @@ void MediaCaptureDevicesDispatcher::GetRequestedDevice(
DCHECK(audio || video); DCHECK(audio || video);
if (audio) { if (audio) {
const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices(); const content::MediaStreamDevice* device = GetFirstAvailableAudioDevice();
const content::MediaStreamDevice* const device =
FindDefaultDeviceWithId(audio_devices, requested_device_id);
if (device) if (device)
devices->push_back(*device); devices->push_back(*device);
} }
if (video) { if (video) {
const content::MediaStreamDevices& video_devices = GetVideoCaptureDevices(); const content::MediaStreamDevice* device = GetFirstAvailableVideoDevice();
const content::MediaStreamDevice* const device =
FindDefaultDeviceWithId(video_devices, requested_device_id);
if (device) if (device)
devices->push_back(*device); devices->push_back(*device);
} }
} }
void MediaCaptureDevicesDispatcher::GetDefaultDevices( const content::MediaStreamDevice*
bool audio, MediaCaptureDevicesDispatcher::GetRequestedAudioDevice(
bool video, const std::string& requested_audio_device_id) {
content::MediaStreamDevices* devices) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (audio) { const content::MediaStreamDevices& audio_devices = GetAudioCaptureDevices();
GetRequestedDevice(std::string(), true, false, devices); const content::MediaStreamDevice* const device =
} FindDeviceWithId(audio_devices, requested_audio_device_id);
return device;
}
if (video) { const content::MediaStreamDevice*
GetRequestedDevice(std::string(), false, true, devices); 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( void MediaCaptureDevicesDispatcher::OnAudioCaptureDevicesChanged(
@ -126,15 +149,22 @@ void MediaCaptureDevicesDispatcher::OnVideoCaptureDevicesChanged(
void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged( void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
int render_process_id, int render_process_id,
int render_view_id, int render_view_id,
int page_request_id,
const content::MediaStreamDevice& device, const content::MediaStreamDevice& device,
content::MediaRequestState state) { content::MediaRequestState state) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, }
base::Bind(
&MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread, void MediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged(
base::Unretained(this), render_process_id, render_view_id, device, int render_process_id, int render_view_id, int stream_id,
state)); 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( void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread(
@ -145,17 +175,10 @@ void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread(
} }
void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread( void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread(
const content::MediaStreamDevices& devices) { const content::MediaStreamDevices& devices){
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
devices_enumerated_ = true; devices_enumerated_ = true;
video_devices_ = devices; video_devices_ = devices;
} }
void MediaCaptureDevicesDispatcher::UpdateMediaRequestStateOnUIThread( } // namespace brightray
int render_process_id,
int render_view_id,
const content::MediaStreamDevice& device,
content::MediaRequestState state) {
}
}

View file

@ -8,8 +8,8 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/observer_list.h"
#include "content/public/browser/media_observer.h" #include "content/public/browser/media_observer.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/media_stream_request.h" #include "content/public/common/media_stream_request.h"
namespace brightray { namespace brightray {
@ -20,20 +20,35 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
public: public:
static MediaCaptureDevicesDispatcher* GetInstance(); static MediaCaptureDevicesDispatcher* GetInstance();
// Helper for picking the device that was requested for an OpenDevice request. // Methods for observers. Called on UI thread.
// If the device requested is not available it will revert to using the first const content::MediaStreamDevices& GetAudioCaptureDevices();
// available one instead or will return an empty list if no devices of the const content::MediaStreamDevices& GetVideoCaptureDevices();
// requested kind are present.
void GetRequestedDevice(const std::string& requested_device_id, // Helper to get the default devices which can be used by the media request.
bool audio, // Uses the first available devices if the default devices are not available.
bool video, // If the return list is empty, it means there is no available device on the
content::MediaStreamDevices* devices); // OS.
// Called on the UI thread.
void GetDefaultDevices(bool audio, void GetDefaultDevices(bool audio,
bool video, bool video,
content::MediaStreamDevices* devices); content::MediaStreamDevices* devices);
const content::MediaStreamDevices& GetAudioCaptureDevices(); // Helpers for picking particular requested devices, identified by raw id.
const content::MediaStreamDevices& GetVideoCaptureDevices(); // 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: // Overridden from content::MediaObserver:
virtual void OnAudioCaptureDevicesChanged( virtual void OnAudioCaptureDevicesChanged(
@ -43,13 +58,18 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
virtual void OnMediaRequestStateChanged( virtual void OnMediaRequestStateChanged(
int render_process_id, int render_process_id,
int render_view_id, int render_view_id,
int page_request_id,
const content::MediaStreamDevice& device, const content::MediaStreamDevice& device,
content::MediaRequestState state) OVERRIDE; content::MediaRequestState state) OVERRIDE;
virtual void OnAudioStreamPlayingChanged( virtual void OnAudioStreamPlayingChanged(
int render_process_id, int render_process_id,
int render_view_id, int render_view_id,
int stream_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: private:
friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>; friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>;
@ -60,11 +80,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
// Called by the MediaObserver() functions, executed on UI thread. // Called by the MediaObserver() functions, executed on UI thread.
void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices); void UpdateAudioDevicesOnUIThread(const content::MediaStreamDevices& devices);
void UpdateVideoDevicesOnUIThread(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. // A list of cached audio capture devices.
content::MediaStreamDevices audio_devices_; content::MediaStreamDevices audio_devices_;
@ -75,8 +90,13 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
// Flag to indicate if device enumeration has been done/doing. // Flag to indicate if device enumeration has been done/doing.
// Only accessed on UI thread. // Only accessed on UI thread.
bool devices_enumerated_; 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_ #endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_

View file

@ -4,9 +4,8 @@
#include "browser/media/media_stream_devices_controller.h" #include "browser/media/media_stream_devices_controller.h"
#include "base/values.h"
#include "browser/media/media_capture_devices_dispatcher.h" #include "browser/media/media_capture_devices_dispatcher.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/media_stream_request.h" #include "content/public/common/media_stream_request.h"
namespace brightray { namespace brightray {
@ -20,7 +19,7 @@ bool HasAnyAvailableDevice() {
MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices(); MediaCaptureDevicesDispatcher::GetInstance()->GetVideoCaptureDevices();
return !audio_devices.empty() || !video_devices.empty(); return !audio_devices.empty() || !video_devices.empty();
}; }
} // namespace } // namespace
@ -29,15 +28,39 @@ MediaStreamDevicesController::MediaStreamDevicesController(
const content::MediaResponseCallback& callback) const content::MediaResponseCallback& callback)
: request_(request), : request_(request),
callback_(callback), callback_(callback),
// For MEDIA_OPEN_DEVICE requests (Pepper) we always request both webcam
// and microphone to avoid popping two infobars.
microphone_requested_( 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_( 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<content::MediaStreamUI>());
}
}
bool MediaStreamDevicesController::TakeAction() { 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. // Deny the request if there is no device attached to the OS.
if (!HasAnyAvailableDevice()) { if (!HasAnyAvailableDevice()) {
Deny(); Deny();
@ -53,34 +76,87 @@ void MediaStreamDevicesController::Accept() {
content::MediaStreamDevices devices; content::MediaStreamDevices devices;
if (microphone_requested_ || webcam_requested_) { if (microphone_requested_ || webcam_requested_) {
switch (request_.request_type) { 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 // For open device request pick the desired device or fall back to the
// first available of the given type. // first available of the given type.
MediaCaptureDevicesDispatcher::GetInstance()->GetRequestedDevice( if (request_.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE) {
request_.requested_device_id, device = MediaCaptureDevicesDispatcher::GetInstance()->
microphone_requested_, GetRequestedAudioDevice(request_.requested_audio_device_id);
webcam_requested_, // TODO(wjia): Confirm this is the intended behavior.
&devices); 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; break;
case content::MEDIA_DEVICE_ACCESS: } case content::MEDIA_GENERATE_STREAM: {
case content::MEDIA_GENERATE_STREAM: bool needs_audio_device = microphone_requested_;
case content::MEDIA_ENUMERATE_DEVICES: 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. // Get the default devices for the request.
MediaCaptureDevicesDispatcher::GetInstance()-> MediaCaptureDevicesDispatcher::GetInstance()->
GetDefaultDevices(microphone_requested_, GetDefaultDevices(microphone_requested_,
webcam_requested_, webcam_requested_,
&devices); &devices);
break; break;
case content::MEDIA_ENUMERATE_DEVICES:
// Do nothing.
NOTREACHED();
break;
} }
} }
LOG(ERROR) << "Accept"; content::MediaResponseCallback cb = callback_;
callback_.Run(devices, scoped_ptr<content::MediaStreamUI>()); callback_.Reset();
cb.Run(devices, scoped_ptr<content::MediaStreamUI>());
} }
void MediaStreamDevicesController::Deny() { void MediaStreamDevicesController::Deny() {
callback_.Run(content::MediaStreamDevices(), content::MediaResponseCallback cb = callback_;
scoped_ptr<content::MediaStreamUI>()); callback_.Reset();
cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>());
} }
} // namespace brightray } // namespace brightray

View file

@ -5,6 +5,8 @@
#ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ #ifndef BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
#define BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ #define BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
#include <string>
#include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_delegate.h"
namespace brightray { namespace brightray {
@ -16,14 +18,10 @@ class MediaStreamDevicesController {
virtual ~MediaStreamDevicesController(); virtual ~MediaStreamDevicesController();
// Public method to be called before creating the MediaStreamInfoBarDelegate. // Accept or deny the request based on the default policy.
// This function will check the content settings exceptions and take the
// corresponding action on exception which matches the request.
bool TakeAction(); bool TakeAction();
// Public methods to be called by MediaStreamInfoBarDelegate; // Explicitly accept or deny the request.
bool has_audio() const { return microphone_requested_; }
bool has_video() const { return webcam_requested_; }
void Accept(); void Accept();
void Deny(); void Deny();
@ -41,6 +39,6 @@ class MediaStreamDevicesController {
DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController); DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController);
}; };
} // namespace brightray } // namespace brightray
#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_ #endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_

View file

@ -8,7 +8,7 @@
#import "browser/notification_presenter.h" #import "browser/notification_presenter.h"
#import "base/memory/scoped_nsobject.h" #import "base/mac/scoped_nsobject.h"
#import <map> #import <map>
@class BRYUserNotificationCenterDelegate; @class BRYUserNotificationCenterDelegate;
@ -30,8 +30,8 @@ class NotificationPresenterMac : public NotificationPresenter {
int notification_id) OVERRIDE; int notification_id) OVERRIDE;
private: private:
std::map<std::string, scoped_nsobject<NSUserNotification>> notification_map_; std::map<std::string, base::scoped_nsobject<NSUserNotification>> notification_map_;
scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_; base::scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_;
}; };
} }

View file

@ -5,7 +5,7 @@
#import "browser/notification_presenter_mac.h" #import "browser/notification_presenter_mac.h"
#import "base/stringprintf.h" #import "base/strings/stringprintf.h"
#import "base/strings/sys_string_conversions.h" #import "base/strings/sys_string_conversions.h"
#import "content/public/browser/render_view_host.h" #import "content/public/browser/render_view_host.h"
#import "content/public/common/show_desktop_notification_params.h" #import "content/public/common/show_desktop_notification_params.h"
@ -56,7 +56,7 @@ struct NotificationID {
int notification_id; int notification_id;
}; };
scoped_nsobject<NSUserNotification> CreateUserNotification( base::scoped_nsobject<NSUserNotification> CreateUserNotification(
const content::ShowDesktopNotificationHostMsgParams& params, const content::ShowDesktopNotificationHostMsgParams& params,
int render_process_id, int render_process_id,
int render_view_id) { int render_view_id) {
@ -65,7 +65,7 @@ scoped_nsobject<NSUserNotification> CreateUserNotification(
notification.informativeText = base::SysUTF16ToNSString(params.body); notification.informativeText = base::SysUTF16ToNSString(params.body);
notification.userInfo = NotificationID(render_process_id, render_view_id, params.notification_id).GetUserInfo(); notification.userInfo = NotificationID(render_process_id, render_view_id, params.notification_id).GetUserInfo();
return scoped_nsobject<NSUserNotification>(notification); return base::scoped_nsobject<NSUserNotification>(notification);
} }
} }

View file

@ -5,7 +5,7 @@
#include "browser/url_request_context_getter.h" #include "browser/url_request_context_getter.h"
#include "network_delegate.h" #include "network_delegate.h"
#include "base/string_util.h" #include "base/strings/string_util.h"
#include "base/threading/worker_pool.h" #include "base/threading/worker_pool.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/cookie_store_factory.h" #include "content/public/browser/cookie_store_factory.h"
@ -30,8 +30,8 @@ namespace brightray {
URLRequestContextGetter::URLRequestContextGetter( URLRequestContextGetter::URLRequestContextGetter(
const base::FilePath& base_path, const base::FilePath& base_path,
MessageLoop* io_loop, base::MessageLoop* io_loop,
MessageLoop* file_loop, base::MessageLoop* file_loop,
scoped_ptr<NetworkDelegate> network_delegate, scoped_ptr<NetworkDelegate> network_delegate,
content::ProtocolHandlerMap* protocol_handlers) content::ProtocolHandlerMap* protocol_handlers)
: base_path_(base_path), : base_path_(base_path),
@ -87,7 +87,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext()
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
storage_->set_http_auth_handler_factory( storage_->set_http_auth_handler_factory(
net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
storage_->set_http_server_properties(new net::HttpServerPropertiesImpl); scoped_ptr<net::HttpServerProperties> server_properties(new net::HttpServerPropertiesImpl);
storage_->set_http_server_properties(server_properties.Pass());
base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache")); base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
net::HttpCache::DefaultBackend* main_backend = net::HttpCache::DefaultBackend* main_backend =

View file

@ -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<WebUIControllerFactory*>(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;
}
}

View file

@ -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

View file

@ -2,7 +2,7 @@
#include "base/file_version_info.h" #include "base/file_version_info.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
namespace brightray { namespace brightray {

View file

@ -6,10 +6,10 @@
#include "common/application_info.h" #include "common/application_info.h"
#include "base/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/string_util.h" #include "base/strings/string_util.h"
#include "ui/base/resource/resource_bundle.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 { namespace brightray {

View file

@ -13,7 +13,7 @@
#include "base/mac/bundle_locations.h" #include "base/mac/bundle_locations.h"
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "content/public/common/content_paths.h" #include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"

View file

@ -6,9 +6,7 @@ import sys
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
GYP = { GYP = os.path.join(SOURCE_ROOT, 'vendor', 'gyp', 'gyp_main.py')
'win32': 'gyp.bat',
}.get(sys.platform, 'gyp')
def main(): def main():
@ -17,7 +15,7 @@ def main():
def run_gyp(): def run_gyp():
return subprocess.call([GYP, '--depth', '.', 'brightray.gyp']) return subprocess.call([sys.executable, GYP, '--depth', '.', 'brightray.gyp'])
def build(): def build():

1
brightray/vendor/gyp vendored Submodule

@ -0,0 +1 @@
Subproject commit 6633baab29b60f27e3dca607ffbef689ccdd82b8

@ -1 +1 @@
Subproject commit 5ffcb396d64df97a2d0220101e1e52598a661fc8 Subproject commit 21d99bd412dda76aca6bcc722134d24d8ea17746