Merge branch 'master' into linux
This commit is contained in:
commit
6053911bd2
30 changed files with 550 additions and 248 deletions
3
brightray/.gitmodules
vendored
3
brightray/.gitmodules
vendored
|
@ -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
|
||||
|
|
|
@ -14,7 +14,6 @@ sample application written using Brightray.
|
|||
### Prerequisites
|
||||
|
||||
* Python 2.7
|
||||
* gyp
|
||||
* Linux:
|
||||
* Clang 3.0
|
||||
* Mac:
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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<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"));
|
||||
PrefServiceBuilder builder;
|
||||
builder.WithUserFilePrefs(prefs_path,
|
||||
|
@ -83,21 +108,7 @@ scoped_ptr<NetworkDelegate> 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<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()));
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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<NetworkDelegate> 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_;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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<BrowserContext> browser_context_;
|
||||
content::DevToolsHttpHandler* devtools_http_handler_;
|
||||
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BrowserMainParts);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
101
brightray/browser/devtools_ui.cc
Normal file
101
brightray/browser/devtools_ui.cc
Normal 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());
|
||||
}
|
||||
|
||||
}
|
25
brightray/browser/devtools_ui.h
Normal file
25
brightray/browser/devtools_ui.h
Normal 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
|
|
@ -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) {
|
||||
|
|
|
@ -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*) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<BRYInspectableWebContentsView> view_;
|
||||
base::scoped_nsobject<BRYInspectableWebContentsView> view_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewMac);
|
||||
};
|
||||
|
|
|
@ -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<MediaCaptureDevicesDispatcher>::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
|
||||
|
|
|
@ -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<MediaCaptureDevicesDispatcher>;
|
||||
|
@ -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_
|
||||
|
|
|
@ -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<content::MediaStreamUI>());
|
||||
}
|
||||
}
|
||||
|
||||
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::MediaStreamUI>());
|
||||
content::MediaResponseCallback cb = callback_;
|
||||
callback_.Reset();
|
||||
cb.Run(devices, scoped_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
void MediaStreamDevicesController::Deny() {
|
||||
callback_.Run(content::MediaStreamDevices(),
|
||||
scoped_ptr<content::MediaStreamUI>());
|
||||
content::MediaResponseCallback cb = callback_;
|
||||
callback_.Reset();
|
||||
cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace brightray
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef 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"
|
||||
|
||||
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_
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#import "browser/notification_presenter.h"
|
||||
|
||||
#import "base/memory/scoped_nsobject.h"
|
||||
#import "base/mac/scoped_nsobject.h"
|
||||
#import <map>
|
||||
|
||||
@class BRYUserNotificationCenterDelegate;
|
||||
|
@ -30,8 +30,8 @@ class NotificationPresenterMac : public NotificationPresenter {
|
|||
int notification_id) OVERRIDE;
|
||||
|
||||
private:
|
||||
std::map<std::string, scoped_nsobject<NSUserNotification>> notification_map_;
|
||||
scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_;
|
||||
std::map<std::string, base::scoped_nsobject<NSUserNotification>> notification_map_;
|
||||
base::scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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<NSUserNotification> CreateUserNotification(
|
||||
base::scoped_nsobject<NSUserNotification> CreateUserNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams& params,
|
||||
int render_process_id,
|
||||
int render_view_id) {
|
||||
|
@ -65,7 +65,7 @@ scoped_nsobject<NSUserNotification> CreateUserNotification(
|
|||
notification.informativeText = base::SysUTF16ToNSString(params.body);
|
||||
notification.userInfo = NotificationID(render_process_id, render_view_id, params.notification_id).GetUserInfo();
|
||||
|
||||
return scoped_nsobject<NSUserNotification>(notification);
|
||||
return base::scoped_nsobject<NSUserNotification>(notification);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<NetworkDelegate> 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<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"));
|
||||
net::HttpCache::DefaultBackend* main_backend =
|
||||
|
|
59
brightray/browser/web_ui_controller_factory.cc
Normal file
59
brightray/browser/web_ui_controller_factory.cc
Normal 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;
|
||||
}
|
||||
|
||||
}
|
42
brightray/browser/web_ui_controller_factory.h
Normal file
42
brightray/browser/web_ui_controller_factory.h
Normal 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
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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():
|
||||
|
|
1
brightray/vendor/gyp
vendored
Submodule
1
brightray/vendor/gyp
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 6633baab29b60f27e3dca607ffbef689ccdd82b8
|
2
brightray/vendor/libchromiumcontent
vendored
2
brightray/vendor/libchromiumcontent
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 5ffcb396d64df97a2d0220101e1e52598a661fc8
|
||||
Subproject commit 21d99bd412dda76aca6bcc722134d24d8ea17746
|
Loading…
Add table
Add a link
Reference in a new issue