commit
963e0f1c76
47 changed files with 514 additions and 270 deletions
3
brightray/.gitmodules
vendored
3
brightray/.gitmodules
vendored
|
@ -4,3 +4,6 @@
|
||||||
[submodule "vendor/gyp"]
|
[submodule "vendor/gyp"]
|
||||||
path = vendor/gyp
|
path = vendor/gyp
|
||||||
url = https://github.com/svn2github/gyp
|
url = https://github.com/svn2github/gyp
|
||||||
|
[submodule "vendor/google-styleguide"]
|
||||||
|
path = vendor/google-styleguide
|
||||||
|
url = https://github.com/svn2github/sgss-mirror-google-styleguide
|
||||||
|
|
|
@ -42,18 +42,23 @@ NotificationPresenter* BrowserClient::notification_presenter() {
|
||||||
return notification_presenter_.get();
|
return notification_presenter_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts(const content::MainFunctionParams&) {
|
BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts(
|
||||||
|
const content::MainFunctionParams&) {
|
||||||
return new BrowserMainParts;
|
return new BrowserMainParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
content::BrowserMainParts* BrowserClient::CreateBrowserMainParts(const content::MainFunctionParams& parameters) {
|
content::BrowserMainParts* BrowserClient::CreateBrowserMainParts(
|
||||||
|
const content::MainFunctionParams& parameters) {
|
||||||
DCHECK(!browser_main_parts_);
|
DCHECK(!browser_main_parts_);
|
||||||
browser_main_parts_ = OverrideCreateBrowserMainParts(parameters);
|
browser_main_parts_ = OverrideCreateBrowserMainParts(parameters);
|
||||||
return browser_main_parts_;
|
return browser_main_parts_;
|
||||||
}
|
}
|
||||||
|
|
||||||
net::URLRequestContextGetter* BrowserClient::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers) {
|
net::URLRequestContextGetter* BrowserClient::CreateRequestContext(
|
||||||
return static_cast<BrowserContext*>(browser_context)->CreateRequestContext(protocol_handlers);
|
content::BrowserContext* browser_context,
|
||||||
|
content::ProtocolHandlerMap* protocol_handlers) {
|
||||||
|
auto context = static_cast<BrowserContext*>(browser_context);
|
||||||
|
return context->CreateRequestContext(protocol_handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserClient::ShowDesktopNotification(
|
void BrowserClient::ShowDesktopNotification(
|
||||||
|
@ -74,11 +79,12 @@ void BrowserClient::CancelDesktopNotification(
|
||||||
auto presenter = notification_presenter();
|
auto presenter = notification_presenter();
|
||||||
if (!presenter)
|
if (!presenter)
|
||||||
return;
|
return;
|
||||||
presenter->CancelNotification(render_process_id, render_view_id, notification_id);
|
presenter->CancelNotification(
|
||||||
|
render_process_id, render_view_id, notification_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
content::MediaObserver* BrowserClient::GetMediaObserver() {
|
content::MediaObserver* BrowserClient::GetMediaObserver() {
|
||||||
return MediaCaptureDevicesDispatcher::GetInstance();
|
return MediaCaptureDevicesDispatcher::GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -14,7 +14,7 @@ class BrowserMainParts;
|
||||||
class NotificationPresenter;
|
class NotificationPresenter;
|
||||||
|
|
||||||
class BrowserClient : public content::ContentBrowserClient {
|
class BrowserClient : public content::ContentBrowserClient {
|
||||||
public:
|
public:
|
||||||
static BrowserClient* Get();
|
static BrowserClient* Get();
|
||||||
|
|
||||||
BrowserClient();
|
BrowserClient();
|
||||||
|
@ -24,17 +24,21 @@ public:
|
||||||
BrowserMainParts* browser_main_parts() { return browser_main_parts_; }
|
BrowserMainParts* browser_main_parts() { return browser_main_parts_; }
|
||||||
NotificationPresenter* notification_presenter();
|
NotificationPresenter* notification_presenter();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Subclasses should override this to provide their own BrowserMainParts implementation. The
|
// Subclasses should override this to provide their own BrowserMainParts
|
||||||
// lifetime of the returned instance is managed by the caller.
|
// implementation. The lifetime of the returned instance is managed by the
|
||||||
virtual BrowserMainParts* OverrideCreateBrowserMainParts(const content::MainFunctionParams&);
|
// caller.
|
||||||
|
virtual BrowserMainParts* OverrideCreateBrowserMainParts(
|
||||||
|
const content::MainFunctionParams&);
|
||||||
|
|
||||||
// Subclasses that override this (e.g., to provide their own protocol handlers) should call this
|
// Subclasses that override this (e.g., to provide their own protocol
|
||||||
// implementation after doing their own work.
|
// handlers) should call this implementation after doing their own work.
|
||||||
virtual net::URLRequestContextGetter* CreateRequestContext(content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE;
|
virtual net::URLRequestContextGetter* CreateRequestContext(
|
||||||
|
content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) OVERRIDE;
|
virtual content::BrowserMainParts* CreateBrowserMainParts(
|
||||||
|
const content::MainFunctionParams&) OVERRIDE;
|
||||||
virtual void ShowDesktopNotification(
|
virtual void ShowDesktopNotification(
|
||||||
const content::ShowDesktopNotificationHostMsgParams&,
|
const content::ShowDesktopNotificationHostMsgParams&,
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
|
@ -52,6 +56,6 @@ private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE-CHROMIUM file.
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
#include "browser_context.h"
|
#include "browser/browser_context.h"
|
||||||
|
|
||||||
#include "browser/download_manager_delegate.h"
|
#include "browser/download_manager_delegate.h"
|
||||||
#include "browser/inspectable_web_contents_impl.h"
|
#include "browser/inspectable_web_contents_impl.h"
|
||||||
#include "browser/network_delegate.h"
|
#include "browser/network_delegate.h"
|
||||||
|
#include "browser/url_request_context_getter.h"
|
||||||
#include "common/application_info.h"
|
#include "common/application_info.h"
|
||||||
|
|
||||||
#include "base/environment.h"
|
#include "base/environment.h"
|
||||||
|
@ -19,7 +20,6 @@
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/resource_context.h"
|
#include "content/public/browser/resource_context.h"
|
||||||
#include "content/public/browser/storage_partition.h"
|
#include "content/public/browser/storage_partition.h"
|
||||||
#include "url_request_context_getter.h"
|
|
||||||
|
|
||||||
#if defined(OS_LINUX)
|
#if defined(OS_LINUX)
|
||||||
#include "base/nix/xdg_util.h"
|
#include "base/nix/xdg_util.h"
|
||||||
|
@ -28,14 +28,14 @@
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
class BrowserContext::ResourceContext : public content::ResourceContext {
|
class BrowserContext::ResourceContext : public content::ResourceContext {
|
||||||
public:
|
public:
|
||||||
ResourceContext() : getter_(nullptr) {}
|
ResourceContext() : getter_(nullptr) {}
|
||||||
|
|
||||||
void set_url_request_context_getter(URLRequestContextGetter* getter) {
|
void set_url_request_context_getter(URLRequestContextGetter* getter) {
|
||||||
getter_ = getter;
|
getter_ = getter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual net::HostResolver* GetHostResolver() OVERRIDE {
|
virtual net::HostResolver* GetHostResolver() OVERRIDE {
|
||||||
return getter_->host_resolver();
|
return getter_->host_resolver();
|
||||||
}
|
}
|
||||||
|
@ -44,12 +44,14 @@ private:
|
||||||
return getter_->GetURLRequestContext();
|
return getter_->GetURLRequestContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: We should probably allow clients to override this to implement more restrictive policies.
|
// FIXME: We should probably allow clients to override this to implement more
|
||||||
|
// restrictive policies.
|
||||||
virtual bool AllowMicAccess(const GURL& origin) OVERRIDE {
|
virtual bool AllowMicAccess(const GURL& origin) OVERRIDE {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: We should probably allow clients to override this to implement more restrictive policies.
|
// FIXME: We should probably allow clients to override this to implement more
|
||||||
|
// restrictive policies.
|
||||||
virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE {
|
virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +78,8 @@ void BrowserContext::Initialize() {
|
||||||
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,
|
||||||
JsonPrefStore::GetTaskRunnerForFile(prefs_path, content::BrowserThread::GetBlockingPool()));
|
JsonPrefStore::GetTaskRunnerForFile(
|
||||||
|
prefs_path, content::BrowserThread::GetBlockingPool()));
|
||||||
|
|
||||||
auto registry = make_scoped_refptr(new PrefRegistrySimple);
|
auto registry = make_scoped_refptr(new PrefRegistrySimple);
|
||||||
RegisterInternalPrefs(registry);
|
RegisterInternalPrefs(registry);
|
||||||
|
@ -92,12 +95,17 @@ void BrowserContext::RegisterInternalPrefs(PrefRegistrySimple* registry) {
|
||||||
InspectableWebContentsImpl::RegisterPrefs(registry);
|
InspectableWebContentsImpl::RegisterPrefs(registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
net::URLRequestContextGetter* BrowserContext::CreateRequestContext(content::ProtocolHandlerMap* protocol_handlers) {
|
net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
|
||||||
|
content::ProtocolHandlerMap* protocol_handlers) {
|
||||||
DCHECK(!url_request_getter_);
|
DCHECK(!url_request_getter_);
|
||||||
|
auto io_loop = content::BrowserThread::UnsafeGetMessageLoopForThread(
|
||||||
|
content::BrowserThread::IO);
|
||||||
|
auto file_loop = content::BrowserThread::UnsafeGetMessageLoopForThread(
|
||||||
|
content::BrowserThread::FILE);
|
||||||
url_request_getter_ = new URLRequestContextGetter(
|
url_request_getter_ = new URLRequestContextGetter(
|
||||||
GetPath(),
|
GetPath(),
|
||||||
content::BrowserThread::UnsafeGetMessageLoopForThread(content::BrowserThread::IO),
|
io_loop,
|
||||||
content::BrowserThread::UnsafeGetMessageLoopForThread(content::BrowserThread::FILE),
|
file_loop,
|
||||||
CreateNetworkDelegate().Pass(),
|
CreateNetworkDelegate().Pass(),
|
||||||
protocol_handlers);
|
protocol_handlers);
|
||||||
resource_context_->set_url_request_context_getter(url_request_getter_.get());
|
resource_context_->set_url_request_context_getter(url_request_getter_.get());
|
||||||
|
@ -120,7 +128,8 @@ net::URLRequestContextGetter* BrowserContext::GetRequestContext() {
|
||||||
return GetDefaultStoragePartition(this)->GetURLRequestContext();
|
return GetDefaultStoragePartition(this)->GetURLRequestContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
net::URLRequestContextGetter* BrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
|
net::URLRequestContextGetter* BrowserContext::GetRequestContextForRenderProcess(
|
||||||
|
int renderer_child_id) {
|
||||||
return GetRequestContext();
|
return GetRequestContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,15 +137,24 @@ net::URLRequestContextGetter* BrowserContext::GetMediaRequestContext() {
|
||||||
return GetRequestContext();
|
return GetRequestContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
net::URLRequestContextGetter* BrowserContext::GetMediaRequestContextForRenderProcess(int renderer_child_id) {
|
net::URLRequestContextGetter*
|
||||||
|
BrowserContext::GetMediaRequestContextForRenderProcess(
|
||||||
|
int renderer_child_id) {
|
||||||
return GetRequestContext();
|
return GetRequestContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
net::URLRequestContextGetter* BrowserContext::GetMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory) {
|
net::URLRequestContextGetter*
|
||||||
|
BrowserContext::GetMediaRequestContextForStoragePartition(
|
||||||
|
const base::FilePath& partition_path,
|
||||||
|
bool in_memory) {
|
||||||
return GetRequestContext();
|
return GetRequestContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserContext::RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback& callback) {
|
void BrowserContext::RequestMIDISysExPermission(
|
||||||
|
int render_process_id,
|
||||||
|
int render_view_id,
|
||||||
|
const GURL& requesting_frame,
|
||||||
|
const MIDISysExPermissionCallback& callback) {
|
||||||
callback.Run(false);
|
callback.Run(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +168,8 @@ content::DownloadManagerDelegate* BrowserContext::GetDownloadManagerDelegate() {
|
||||||
return download_manager_delegate_.get();
|
return download_manager_delegate_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
content::GeolocationPermissionContext* BrowserContext::GetGeolocationPermissionContext() {
|
content::GeolocationPermissionContext*
|
||||||
|
BrowserContext::GetGeolocationPermissionContext() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,4 +177,4 @@ quota::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -18,41 +18,54 @@ class NetworkDelegate;
|
||||||
class URLRequestContextGetter;
|
class URLRequestContextGetter;
|
||||||
|
|
||||||
class BrowserContext : public content::BrowserContext {
|
class BrowserContext : public content::BrowserContext {
|
||||||
public:
|
public:
|
||||||
BrowserContext();
|
BrowserContext();
|
||||||
~BrowserContext();
|
~BrowserContext();
|
||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
net::URLRequestContextGetter* CreateRequestContext(content::ProtocolHandlerMap*);
|
net::URLRequestContextGetter* CreateRequestContext(
|
||||||
|
content::ProtocolHandlerMap*);
|
||||||
|
|
||||||
PrefService* prefs() { return prefs_.get(); }
|
PrefService* prefs() { return prefs_.get(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Subclasses should override this to register custom preferences.
|
// Subclasses should override this to register custom preferences.
|
||||||
virtual void RegisterPrefs(PrefRegistrySimple*) {}
|
virtual void RegisterPrefs(PrefRegistrySimple* pref_registry) {}
|
||||||
|
|
||||||
// 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() const OVERRIDE;
|
virtual base::FilePath GetPath() const OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ResourceContext;
|
class ResourceContext;
|
||||||
|
|
||||||
void RegisterInternalPrefs(PrefRegistrySimple*);
|
void RegisterInternalPrefs(PrefRegistrySimple* pref_registry);
|
||||||
|
|
||||||
virtual bool IsOffTheRecord() const OVERRIDE;
|
virtual bool IsOffTheRecord() const OVERRIDE;
|
||||||
virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
|
virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
|
||||||
virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(int renderer_child_id);
|
virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
|
||||||
|
int renderer_child_id);
|
||||||
virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
|
virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
|
||||||
virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(int renderer_child_id) OVERRIDE;
|
virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
|
||||||
virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory);
|
int renderer_child_id) OVERRIDE;
|
||||||
virtual void RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback&) 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::ResourceContext* GetResourceContext() OVERRIDE;
|
||||||
virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE;
|
virtual content::DownloadManagerDelegate*
|
||||||
virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE;
|
GetDownloadManagerDelegate() OVERRIDE;
|
||||||
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
|
virtual content::GeolocationPermissionContext*
|
||||||
|
GetGeolocationPermissionContext() OVERRIDE;
|
||||||
|
virtual quota::SpecialStoragePolicy*
|
||||||
|
GetSpecialStoragePolicy() OVERRIDE;
|
||||||
|
|
||||||
base::FilePath path_;
|
base::FilePath path_;
|
||||||
scoped_ptr<ResourceContext> resource_context_;
|
scoped_ptr<ResourceContext> resource_context_;
|
||||||
|
@ -63,6 +76,6 @@ private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserContext);
|
DISALLOW_COPY_AND_ASSIGN(BrowserContext);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,8 +19,10 @@ void BrowserMainParts::PreMainMessageLoopRun() {
|
||||||
browser_context_.reset(CreateBrowserContext());
|
browser_context_.reset(CreateBrowserContext());
|
||||||
browser_context_->Initialize();
|
browser_context_->Initialize();
|
||||||
|
|
||||||
web_ui_controller_factory_.reset(new WebUIControllerFactory(browser_context_.get()));
|
web_ui_controller_factory_.reset(
|
||||||
content::WebUIControllerFactory::RegisterFactory(web_ui_controller_factory_.get());
|
new WebUIControllerFactory(browser_context_.get()));
|
||||||
|
content::WebUIControllerFactory::RegisterFactory(
|
||||||
|
web_ui_controller_factory_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserMainParts::PostMainMessageLoopRun() {
|
void BrowserMainParts::PostMainMessageLoopRun() {
|
||||||
|
@ -31,4 +33,4 @@ BrowserContext* BrowserMainParts::CreateBrowserContext() {
|
||||||
return new BrowserContext;
|
return new BrowserContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -15,15 +15,15 @@ class BrowserContext;
|
||||||
class WebUIControllerFactory;
|
class WebUIControllerFactory;
|
||||||
|
|
||||||
class BrowserMainParts : public content::BrowserMainParts {
|
class BrowserMainParts : public content::BrowserMainParts {
|
||||||
public:
|
public:
|
||||||
BrowserMainParts();
|
BrowserMainParts();
|
||||||
~BrowserMainParts();
|
~BrowserMainParts();
|
||||||
|
|
||||||
BrowserContext* browser_context() { return browser_context_.get(); }
|
BrowserContext* browser_context() { return browser_context_.get(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Subclasses should override this to provide their own BrowserContxt implementation. The caller
|
// Subclasses should override this to provide their own BrowserContxt
|
||||||
// takes ownership of the returned object.
|
// implementation. The caller takes ownership of the returned object.
|
||||||
virtual BrowserContext* CreateBrowserContext();
|
virtual BrowserContext* CreateBrowserContext();
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
|
@ -33,13 +33,13 @@ protected:
|
||||||
virtual void PreMainMessageLoopRun() OVERRIDE;
|
virtual void PreMainMessageLoopRun() OVERRIDE;
|
||||||
virtual void PostMainMessageLoopRun() OVERRIDE;
|
virtual void PostMainMessageLoopRun() OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
scoped_ptr<BrowserContext> browser_context_;
|
scoped_ptr<BrowserContext> browser_context_;
|
||||||
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
|
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserMainParts);
|
DISALLOW_COPY_AND_ASSIGN(BrowserMainParts);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,4 +18,4 @@ void DefaultWebContentsDelegate::RequestMediaAccessPermission(
|
||||||
controller.TakeAction();
|
controller.TakeAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -5,22 +5,24 @@
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
// This class provides some sane default behaviors to any content::WebContents instance (e.g.,
|
// This class provides some sane default behaviors to any content::WebContents
|
||||||
// keyboard shortcut handling on Mac).
|
// instance (e.g., keyboard shortcut handling on Mac).
|
||||||
class DefaultWebContentsDelegate : public content::WebContentsDelegate {
|
class DefaultWebContentsDelegate : public content::WebContentsDelegate {
|
||||||
public:
|
public:
|
||||||
DefaultWebContentsDelegate();
|
DefaultWebContentsDelegate();
|
||||||
~DefaultWebContentsDelegate();
|
~DefaultWebContentsDelegate();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void RequestMediaAccessPermission(content::WebContents*,
|
virtual void RequestMediaAccessPermission(
|
||||||
|
content::WebContents*,
|
||||||
const content::MediaStreamRequest&,
|
const content::MediaStreamRequest&,
|
||||||
const content::MediaResponseCallback&) OVERRIDE;
|
const content::MediaResponseCallback&) OVERRIDE;
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
virtual void HandleKeyboardEvent(content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
|
virtual void HandleKeyboardEvent(
|
||||||
|
content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -90,7 +90,7 @@ class BundledDataSource : public content::URLDataSource {
|
||||||
DISALLOW_COPY_AND_ASSIGN(BundledDataSource);
|
DISALLOW_COPY_AND_ASSIGN(BundledDataSource);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
DevToolsUI::DevToolsUI(BrowserContext* browser_context, content::WebUI* web_ui)
|
DevToolsUI::DevToolsUI(BrowserContext* browser_context, content::WebUI* web_ui)
|
||||||
: WebUIController(web_ui) {
|
: WebUIController(web_ui) {
|
||||||
|
@ -98,4 +98,4 @@ DevToolsUI::DevToolsUI(BrowserContext* browser_context, content::WebUI* web_ui)
|
||||||
content::URLDataSource::Add(browser_context, new BundledDataSource());
|
content::URLDataSource::Add(browser_context, new BundledDataSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -20,6 +20,6 @@ class DevToolsUI : public content::WebUIController {
|
||||||
DISALLOW_COPY_AND_ASSIGN(DevToolsUI);
|
DISALLOW_COPY_AND_ASSIGN(DevToolsUI);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -14,6 +14,6 @@ class DownloadManagerDelegate : public content::DownloadManagerDelegate {
|
||||||
DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegate);
|
DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegate);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
InspectableWebContents* InspectableWebContents::Create(const content::WebContents::CreateParams& create_params) {
|
InspectableWebContents* InspectableWebContents::Create(
|
||||||
|
const content::WebContents::CreateParams& create_params) {
|
||||||
auto contents = content::WebContents::Create(create_params);
|
auto contents = content::WebContents::Create(create_params);
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
// Work around http://crbug.com/279472.
|
// Work around http://crbug.com/279472.
|
||||||
|
@ -16,8 +17,9 @@ InspectableWebContents* InspectableWebContents::Create(const content::WebContent
|
||||||
return Create(contents);
|
return Create(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectableWebContents* InspectableWebContents::Create(content::WebContents* web_contents) {
|
InspectableWebContents* InspectableWebContents::Create(
|
||||||
|
content::WebContents* web_contents) {
|
||||||
return new InspectableWebContentsImpl(web_contents);
|
return new InspectableWebContentsImpl(web_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -8,10 +8,12 @@ namespace brightray {
|
||||||
class InspectableWebContentsView;
|
class InspectableWebContentsView;
|
||||||
|
|
||||||
class InspectableWebContents {
|
class InspectableWebContents {
|
||||||
public:
|
public:
|
||||||
static InspectableWebContents* Create(const content::WebContents::CreateParams&);
|
static InspectableWebContents* Create(
|
||||||
|
const content::WebContents::CreateParams&);
|
||||||
|
|
||||||
// The returned InspectableWebContents takes ownership of the passed-in WebContents.
|
// The returned InspectableWebContents takes ownership of the passed-in
|
||||||
|
// WebContents.
|
||||||
static InspectableWebContents* Create(content::WebContents*);
|
static InspectableWebContents* Create(content::WebContents*);
|
||||||
|
|
||||||
virtual ~InspectableWebContents() {}
|
virtual ~InspectableWebContents() {}
|
||||||
|
@ -22,6 +24,6 @@ public:
|
||||||
virtual void ShowDevTools() = 0;
|
virtual void ShowDevTools() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,15 +31,18 @@ const char kDockSidePref[] = "brightray.devtools.dockside";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implemented separately on each platform.
|
// Implemented separately on each platform.
|
||||||
InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl*);
|
InspectableWebContentsView* CreateInspectableContentsView(
|
||||||
|
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||||
|
|
||||||
void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) {
|
void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) {
|
||||||
registry->RegisterStringPref(kDockSidePref, "bottom");
|
registry->RegisterStringPref(kDockSidePref, "bottom");
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectableWebContentsImpl::InspectableWebContentsImpl(content::WebContents* web_contents)
|
InspectableWebContentsImpl::InspectableWebContentsImpl(
|
||||||
|
content::WebContents* web_contents)
|
||||||
: web_contents_(web_contents) {
|
: web_contents_(web_contents) {
|
||||||
auto context = static_cast<BrowserContext*>(web_contents_->GetBrowserContext());
|
auto context = static_cast<BrowserContext*>(
|
||||||
|
web_contents_->GetBrowserContext());
|
||||||
dock_side_ = context->prefs()->GetString(kDockSidePref);
|
dock_side_ = context->prefs()->GetString(kDockSidePref);
|
||||||
|
|
||||||
view_.reset(CreateInspectableContentsView(this));
|
view_.reset(CreateInspectableContentsView(this));
|
||||||
|
@ -58,7 +61,9 @@ 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())));
|
auto create_params = content::WebContents::CreateParams(
|
||||||
|
web_contents_->GetBrowserContext());
|
||||||
|
devtools_web_contents_.reset(content::WebContents::Create(create_params));
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
// Work around http://crbug.com/279472.
|
// Work around http://crbug.com/279472.
|
||||||
|
@ -68,12 +73,20 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
||||||
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(
|
||||||
frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost(devtools_web_contents_.get(), this));
|
web_contents_->GetRenderViewHost());
|
||||||
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, frontend_host_.get());
|
frontend_host_.reset(
|
||||||
|
content::DevToolsClientHost::CreateDevToolsFrontendHost(
|
||||||
|
devtools_web_contents_.get(), this));
|
||||||
|
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
|
||||||
|
agent_host_, frontend_host_.get());
|
||||||
|
|
||||||
GURL devtools_url(kChromeUIDevToolsURL);
|
GURL devtools_url(kChromeUIDevToolsURL);
|
||||||
devtools_web_contents_->GetController().LoadURL(devtools_url, content::Referrer(), content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
|
devtools_web_contents_->GetController().LoadURL(
|
||||||
|
devtools_url,
|
||||||
|
content::Referrer(),
|
||||||
|
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
||||||
|
std::string());
|
||||||
}
|
}
|
||||||
|
|
||||||
view_->SetDockSide(dock_side_);
|
view_->SetDockSide(dock_side_);
|
||||||
|
@ -81,8 +94,10 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::UpdateFrontendDockSide() {
|
void InspectableWebContentsImpl::UpdateFrontendDockSide() {
|
||||||
auto javascript = base::StringPrintf("InspectorFrontendAPI.setDockSide(\"%s\")", dock_side_.c_str());
|
auto javascript = base::StringPrintf(
|
||||||
devtools_web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(javascript));
|
"InspectorFrontendAPI.setDockSide(\"%s\")", dock_side_.c_str());
|
||||||
|
devtools_web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
|
||||||
|
string16(), ASCIIToUTF16(javascript));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::ActivateWindow() {
|
void InspectableWebContentsImpl::ActivateWindow() {
|
||||||
|
@ -106,7 +121,8 @@ void InspectableWebContentsImpl::SetDockSide(const std::string& side) {
|
||||||
|
|
||||||
dock_side_ = side;
|
dock_side_ = side;
|
||||||
|
|
||||||
auto context = static_cast<BrowserContext*>(web_contents_->GetBrowserContext());
|
auto context = static_cast<BrowserContext*>(
|
||||||
|
web_contents_->GetBrowserContext());
|
||||||
context->prefs()->SetString(kDockSidePref, side);
|
context->prefs()->SetString(kDockSidePref, side);
|
||||||
|
|
||||||
UpdateFrontendDockSide();
|
UpdateFrontendDockSide();
|
||||||
|
@ -115,10 +131,12 @@ void InspectableWebContentsImpl::SetDockSide(const std::string& side) {
|
||||||
void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) {
|
void InspectableWebContentsImpl::OpenInNewTab(const std::string& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::SaveToFile(const std::string& url, const std::string& content, bool save_as) {
|
void InspectableWebContentsImpl::SaveToFile(
|
||||||
|
const std::string& url, const std::string& content, bool save_as) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::AppendToFile(const std::string& url, const std::string& content) {
|
void InspectableWebContentsImpl::AppendToFile(
|
||||||
|
const std::string& url, const std::string& content) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::RequestFileSystems() {
|
void InspectableWebContentsImpl::RequestFileSystems() {
|
||||||
|
@ -127,26 +145,36 @@ void InspectableWebContentsImpl::RequestFileSystems() {
|
||||||
void InspectableWebContentsImpl::AddFileSystem() {
|
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::IndexPath(
|
||||||
|
int request_id, const std::string& file_system_path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::StopIndexing(int request_id) {
|
void InspectableWebContentsImpl::StopIndexing(int request_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::SearchInPath(int request_id, const std::string& file_system_path, const std::string& query) {
|
void InspectableWebContentsImpl::SearchInPath(
|
||||||
|
int request_id,
|
||||||
|
const std::string& file_system_path,
|
||||||
|
const std::string& query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::InspectedContentsClosing() {
|
void InspectableWebContentsImpl::InspectedContentsClosing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::AboutToNavigateRenderView(content::RenderViewHost* render_view_host) {
|
void InspectableWebContentsImpl::AboutToNavigateRenderView(
|
||||||
content::DevToolsClientHost::SetupDevToolsFrontendClient(web_contents()->GetRenderViewHost());
|
content::RenderViewHost* render_view_host) {
|
||||||
|
content::DevToolsClientHost::SetupDevToolsFrontendClient(
|
||||||
|
web_contents()->GetRenderViewHost());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::DidFinishLoad(int64, const GURL&, bool is_main_frame, content::RenderViewHost*) {
|
void InspectableWebContentsImpl::DidFinishLoad(int64 frame_id,
|
||||||
|
const GURL& validated_url,
|
||||||
|
bool is_main_frame,
|
||||||
|
content::RenderViewHost*) {
|
||||||
if (!is_main_frame)
|
if (!is_main_frame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -154,16 +182,19 @@ void InspectableWebContentsImpl::DidFinishLoad(int64, const GURL&, bool is_main_
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::WebContentsDestroyed(content::WebContents*) {
|
void InspectableWebContentsImpl::WebContentsDestroyed(content::WebContents*) {
|
||||||
content::DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_.get());
|
content::DevToolsManager::GetInstance()->ClientHostClosing(
|
||||||
|
frontend_host_.get());
|
||||||
Observe(nullptr);
|
Observe(nullptr);
|
||||||
agent_host_ = nullptr;
|
agent_host_ = nullptr;
|
||||||
frontend_host_.reset();
|
frontend_host_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::HandleKeyboardEvent(content::WebContents* source, const content::NativeWebKeyboardEvent& event) {
|
void InspectableWebContentsImpl::HandleKeyboardEvent(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
auto delegate = web_contents_->GetDelegate();
|
auto delegate = web_contents_->GetDelegate();
|
||||||
if (delegate)
|
if (delegate)
|
||||||
delegate->HandleKeyboardEvent(source, event);
|
delegate->HandleKeyboardEvent(source, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -28,10 +28,10 @@ class InspectableWebContentsImpl :
|
||||||
content::DevToolsFrontendHostDelegate,
|
content::DevToolsFrontendHostDelegate,
|
||||||
content::WebContentsObserver,
|
content::WebContentsObserver,
|
||||||
content::WebContentsDelegate {
|
content::WebContentsDelegate {
|
||||||
public:
|
public:
|
||||||
static void RegisterPrefs(PrefRegistrySimple*);
|
static void RegisterPrefs(PrefRegistrySimple* pref_registry);
|
||||||
|
|
||||||
InspectableWebContentsImpl(content::WebContents*);
|
explicit InspectableWebContentsImpl(content::WebContents*);
|
||||||
virtual ~InspectableWebContentsImpl();
|
virtual ~InspectableWebContentsImpl();
|
||||||
|
|
||||||
virtual InspectableWebContentsView* GetView() const OVERRIDE;
|
virtual InspectableWebContentsView* GetView() const OVERRIDE;
|
||||||
|
@ -39,9 +39,11 @@ public:
|
||||||
|
|
||||||
virtual void ShowDevTools() OVERRIDE;
|
virtual void ShowDevTools() OVERRIDE;
|
||||||
|
|
||||||
content::WebContents* devtools_web_contents() { return devtools_web_contents_.get(); }
|
content::WebContents* devtools_web_contents() {
|
||||||
|
return devtools_web_contents_.get();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateFrontendDockSide();
|
void UpdateFrontendDockSide();
|
||||||
|
|
||||||
// content::DevToolsFrontendHostDelegate
|
// content::DevToolsFrontendHostDelegate
|
||||||
|
@ -60,7 +62,8 @@ 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 IndexPath(int request_id,
|
||||||
|
const std::string& file_system_path) OVERRIDE;
|
||||||
virtual void StopIndexing(int request_id) OVERRIDE;
|
virtual void StopIndexing(int request_id) OVERRIDE;
|
||||||
virtual void SearchInPath(int request_id,
|
virtual void SearchInPath(int request_id,
|
||||||
const std::string& file_system_path,
|
const std::string& file_system_path,
|
||||||
|
@ -69,7 +72,8 @@ private:
|
||||||
|
|
||||||
// content::WebContentsObserver
|
// content::WebContentsObserver
|
||||||
|
|
||||||
virtual void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) 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,
|
||||||
|
@ -78,7 +82,8 @@ private:
|
||||||
|
|
||||||
// content::WebContentsDelegate
|
// content::WebContentsDelegate
|
||||||
|
|
||||||
virtual void HandleKeyboardEvent(content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
|
virtual void HandleKeyboardEvent(
|
||||||
|
content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
|
||||||
|
|
||||||
scoped_ptr<content::WebContents> web_contents_;
|
scoped_ptr<content::WebContents> web_contents_;
|
||||||
scoped_ptr<content::DevToolsClientHost> frontend_host_;
|
scoped_ptr<content::DevToolsClientHost> frontend_host_;
|
||||||
|
@ -90,6 +95,6 @@ private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl);
|
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
class InspectableWebContentsView {
|
class InspectableWebContentsView {
|
||||||
public:
|
public:
|
||||||
virtual ~InspectableWebContentsView() {}
|
virtual ~InspectableWebContentsView() {}
|
||||||
|
|
||||||
virtual gfx::NativeView GetNativeView() const = 0;
|
virtual gfx::NativeView GetNativeView() const = 0;
|
||||||
|
@ -16,6 +16,6 @@ public:
|
||||||
virtual bool SetDockSide(const std::string& side) = 0;
|
virtual bool SetDockSide(const std::string& side) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef BRIGHTRAY_BROWSER_INSPECTABLE_WEB_CONTENTS_VIEW_MAC_H_
|
#ifndef BRIGHTRAY_BROWSER_INSPECTABLE_WEB_CONTENTS_VIEW_MAC_H_
|
||||||
#define BRIGHTRAY_BROWSER_INSPECTABLE_WEB_CONTENTS_VIEW_MAC_H_
|
#define BRIGHTRAY_BROWSER_INSPECTABLE_WEB_CONTENTS_VIEW_MAC_H_
|
||||||
|
|
||||||
#import "browser/inspectable_web_contents_view.h"
|
#include "browser/inspectable_web_contents_view.h"
|
||||||
|
|
||||||
#import "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
|
|
||||||
@class BRYInspectableWebContentsView;
|
@class BRYInspectableWebContentsView;
|
||||||
|
|
||||||
|
@ -12,17 +12,20 @@ namespace brightray {
|
||||||
class InspectableWebContentsImpl;
|
class InspectableWebContentsImpl;
|
||||||
|
|
||||||
class InspectableWebContentsViewMac : public InspectableWebContentsView {
|
class InspectableWebContentsViewMac : public InspectableWebContentsView {
|
||||||
public:
|
public:
|
||||||
InspectableWebContentsViewMac(InspectableWebContentsImpl*);
|
explicit InspectableWebContentsViewMac(
|
||||||
|
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||||
|
|
||||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||||
virtual void ShowDevTools() OVERRIDE;
|
virtual void ShowDevTools() OVERRIDE;
|
||||||
virtual void CloseDevTools() OVERRIDE;
|
virtual void CloseDevTools() OVERRIDE;
|
||||||
virtual bool SetDockSide(const std::string& side) OVERRIDE;
|
virtual bool SetDockSide(const std::string& side) OVERRIDE;
|
||||||
|
|
||||||
InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; }
|
InspectableWebContentsImpl* inspectable_web_contents() {
|
||||||
|
return inspectable_web_contents_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Owns us.
|
// Owns us.
|
||||||
InspectableWebContentsImpl* inspectable_web_contents_;
|
InspectableWebContentsImpl* inspectable_web_contents_;
|
||||||
|
|
||||||
|
@ -31,6 +34,6 @@ private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewMac);
|
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewMac);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "inspectable_web_contents_view_linux.h"
|
#include "browser/linux/inspectable_web_contents_view_linux.h"
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
@ -10,12 +10,15 @@
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl* inspectable_web_contents) {
|
InspectableWebContentsView* CreateInspectableContentsView(
|
||||||
|
InspectableWebContentsImpl* inspectable_web_contents) {
|
||||||
return new InspectableWebContentsViewLinux(inspectable_web_contents);
|
return new InspectableWebContentsViewLinux(inspectable_web_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectableWebContentsViewLinux::InspectableWebContentsViewLinux(InspectableWebContentsImpl* inspectable_web_contents)
|
InspectableWebContentsViewLinux::InspectableWebContentsViewLinux(
|
||||||
: inspectable_web_contents_(inspectable_web_contents), devtools_window_(NULL) {
|
InspectableWebContentsImpl* inspectable_web_contents)
|
||||||
|
: inspectable_web_contents_(inspectable_web_contents),
|
||||||
|
devtools_window_(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() {
|
InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() {
|
||||||
|
@ -28,9 +31,11 @@ static void dump_one(GtkWidget *wat, int indent) {
|
||||||
gtk_widget_get_allocation(wat, &alloc);
|
gtk_widget_get_allocation(wat, &alloc);
|
||||||
fprintf(stderr, "%*s[%p] %s @%d,%d %dx%d",
|
fprintf(stderr, "%*s[%p] %s @%d,%d %dx%d",
|
||||||
indent, "", wat,
|
indent, "", wat,
|
||||||
g_type_name_from_instance((GTypeInstance*)wat),
|
g_type_name_from_instance(reinterpret_cast<GTypeInstance*>(wat)),
|
||||||
alloc.x, alloc.y, alloc.width, alloc.height);
|
alloc.x, alloc.y, alloc.width, alloc.height);
|
||||||
if (GTK_IS_WINDOW(wat)) fprintf(stderr, " - \"%s\"", gtk_window_get_title(GTK_WINDOW(wat)));
|
if (GTK_IS_WINDOW(wat)) {
|
||||||
|
fprintf(stderr, " - \"%s\"", gtk_window_get_title(GTK_WINDOW(wat)));
|
||||||
|
}
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,21 +46,24 @@ static void dump_the_whole_tree(GtkWidget *wat, int indent) {
|
||||||
}
|
}
|
||||||
dump_one(wat, indent);
|
dump_one(wat, indent);
|
||||||
GList *kids = gtk_container_get_children(GTK_CONTAINER(wat));
|
GList *kids = gtk_container_get_children(GTK_CONTAINER(wat));
|
||||||
for (GList *p=kids; p; p=p->next) {
|
for (GList *p = kids; p; p = p->next) {
|
||||||
dump_the_whole_tree(GTK_WIDGET(p->data), indent+2);
|
dump_the_whole_tree(GTK_WIDGET(p->data), indent+2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_parents(GtkWidget *wat) {
|
static void dump_parents(GtkWidget *wat) {
|
||||||
fprintf(stderr, "Parents:\n");
|
fprintf(stderr, "Parents:\n");
|
||||||
for (GtkWidget *p=gtk_widget_get_parent(wat); p; p=gtk_widget_get_parent(p)) {
|
for (GtkWidget *p = gtk_widget_get_parent(wat);
|
||||||
|
p;
|
||||||
|
p = gtk_widget_get_parent(p)) {
|
||||||
dump_one(p, 2);
|
dump_one(p, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const {
|
gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const {
|
||||||
return inspectable_web_contents_->GetWebContents()->GetView()->GetNativeView();
|
auto web_contents = inspectable_web_contents_->GetWebContents();
|
||||||
|
return web_contents->GetView()->GetNativeView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,18 +98,24 @@ gfx::NativeView InspectableWebContentsViewLinux::GetNativeView() const {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void InspectableWebContentsViewLinux::ShowDevTools() {
|
void InspectableWebContentsViewLinux::ShowDevTools() {
|
||||||
GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView();
|
auto devtools_web_contents =
|
||||||
|
inspectable_web_contents()->devtools_web_contents();
|
||||||
|
GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView();
|
||||||
GtkWidget *parent = gtk_widget_get_parent(devtools);
|
GtkWidget *parent = gtk_widget_get_parent(devtools);
|
||||||
|
|
||||||
DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::ShowDevTools - parent=%s@%p window=%p dockside=\"%s\"",
|
DLOG(INFO) << base::StringPrintf(
|
||||||
g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window_, dockside_.c_str());
|
"InspectableWebContentsViewLinux::ShowDevTools - " \
|
||||||
|
"parent=%s@%p window=%p dockside=\"%s\"",
|
||||||
|
g_type_name_from_instance(reinterpret_cast<GTypeInstance*>(parent)),
|
||||||
|
parent,
|
||||||
|
devtools_window_,
|
||||||
|
dockside_.c_str());
|
||||||
|
|
||||||
if (!parent || GTK_IS_PANED(parent)) {
|
if (!parent || GTK_IS_PANED(parent)) {
|
||||||
if (dockside_ == "undocked") ShowDevToolsInWindow();
|
if (dockside_ == "undocked") ShowDevToolsInWindow();
|
||||||
else if (dockside_ == "bottom") ShowDevToolsInPane(true);
|
else if (dockside_ == "bottom") ShowDevToolsInPane(true);
|
||||||
else if (dockside_ == "right") ShowDevToolsInPane(false);
|
else if (dockside_ == "right") ShowDevToolsInPane(false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
DCHECK(parent == devtools_window_);
|
DCHECK(parent == devtools_window_);
|
||||||
if (dockside_ == "undocked") gtk_widget_show_all(parent);
|
if (dockside_ == "undocked") gtk_widget_show_all(parent);
|
||||||
else if (dockside_ == "bottom") ShowDevToolsInPane(true);
|
else if (dockside_ == "bottom") ShowDevToolsInPane(true);
|
||||||
|
@ -110,16 +124,22 @@ void InspectableWebContentsViewLinux::ShowDevTools() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsViewLinux::CloseDevTools() {
|
void InspectableWebContentsViewLinux::CloseDevTools() {
|
||||||
GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView();
|
auto devtools_web_contents =
|
||||||
|
inspectable_web_contents()->devtools_web_contents();
|
||||||
|
GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView();
|
||||||
GtkWidget *parent = gtk_widget_get_parent(devtools);
|
GtkWidget *parent = gtk_widget_get_parent(devtools);
|
||||||
|
|
||||||
DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::CloseDevTools - parent=%s@%p window=%p dockside=\"%s\"",
|
DLOG(INFO) << base::StringPrintf(
|
||||||
g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window_, dockside_.c_str());
|
"InspectableWebContentsViewLinux::CloseDevTools - " \
|
||||||
|
"parent=%s@%p window=%p dockside=\"%s\"",
|
||||||
|
g_type_name_from_instance(reinterpret_cast<GTypeInstance*>(parent)),
|
||||||
|
parent,
|
||||||
|
devtools_window_,
|
||||||
|
dockside_.c_str());
|
||||||
|
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
return; // Not visible -> nothing to do
|
return; // Not visible -> nothing to do
|
||||||
}
|
} else if (GTK_IS_PANED(parent)) {
|
||||||
else if (GTK_IS_PANED(parent)) {
|
|
||||||
GtkWidget *browser = GetBrowserWindow();
|
GtkWidget *browser = GetBrowserWindow();
|
||||||
GtkWidget *view = GetNativeView();
|
GtkWidget *view = GetNativeView();
|
||||||
|
|
||||||
|
@ -129,22 +149,26 @@ void InspectableWebContentsViewLinux::CloseDevTools() {
|
||||||
gtk_container_remove(GTK_CONTAINER(browser), parent);
|
gtk_container_remove(GTK_CONTAINER(browser), parent);
|
||||||
gtk_widget_reparent(view, browser);
|
gtk_widget_reparent(view, browser);
|
||||||
g_object_unref(parent);
|
g_object_unref(parent);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
DCHECK(parent == devtools_window_);
|
DCHECK(parent == devtools_window_);
|
||||||
gtk_widget_hide(parent);
|
gtk_widget_hide(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) {
|
bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) {
|
||||||
DLOG(INFO) << "InspectableWebContentsViewLinux::SetDockSide: \"" << side << "\"";
|
DLOG(INFO) <<
|
||||||
if (side != "undocked" && side != "bottom" && side != "right") return false; // unsupported display location
|
"InspectableWebContentsViewLinux::SetDockSide: \"" << side << "\"";
|
||||||
if (dockside_ == side) return true; // no change from current location
|
if (side != "undocked" && side != "bottom" && side != "right")
|
||||||
|
return false; // unsupported display location
|
||||||
|
if (dockside_ == side)
|
||||||
|
return true; // no change from current location
|
||||||
|
|
||||||
dockside_ = side;
|
dockside_ = side;
|
||||||
|
|
||||||
// If devtools already has a parent, then we're being asked to move it.
|
// If devtools already has a parent, then we're being asked to move it.
|
||||||
GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView();
|
auto devtools_web_contents =
|
||||||
|
inspectable_web_contents()->devtools_web_contents();
|
||||||
|
GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView();
|
||||||
if (gtk_widget_get_parent(devtools)) {
|
if (gtk_widget_get_parent(devtools)) {
|
||||||
ShowDevTools();
|
ShowDevTools();
|
||||||
}
|
}
|
||||||
|
@ -153,14 +177,16 @@ bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsViewLinux::ShowDevToolsInWindow() {
|
void InspectableWebContentsViewLinux::ShowDevToolsInWindow() {
|
||||||
GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView();
|
auto devtools_web_contents =
|
||||||
|
inspectable_web_contents()->devtools_web_contents();
|
||||||
|
GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView();
|
||||||
GtkWidget *parent = gtk_widget_get_parent(devtools);
|
GtkWidget *parent = gtk_widget_get_parent(devtools);
|
||||||
|
|
||||||
if (!devtools_window_) MakeDevToolsWindow();
|
if (!devtools_window_)
|
||||||
|
MakeDevToolsWindow();
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
gtk_container_add(GTK_CONTAINER(devtools_window_), devtools);
|
gtk_container_add(GTK_CONTAINER(devtools_window_), devtools);
|
||||||
}
|
} else if (parent != devtools_window_) {
|
||||||
else if (parent != devtools_window_) {
|
|
||||||
DCHECK(GTK_IS_PANED(parent));
|
DCHECK(GTK_IS_PANED(parent));
|
||||||
gtk_widget_reparent(devtools, devtools_window_);
|
gtk_widget_reparent(devtools, devtools_window_);
|
||||||
|
|
||||||
|
@ -181,11 +207,16 @@ void InspectableWebContentsViewLinux::MakeDevToolsWindow() {
|
||||||
devtools_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
devtools_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_window_set_title(GTK_WINDOW(devtools_window_), "Developer Tools");
|
gtk_window_set_title(GTK_WINDOW(devtools_window_), "Developer Tools");
|
||||||
gtk_window_set_default_size(GTK_WINDOW(devtools_window_), 800, 600);
|
gtk_window_set_default_size(GTK_WINDOW(devtools_window_), 800, 600);
|
||||||
g_signal_connect(GTK_OBJECT(devtools_window_), "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), this);
|
g_signal_connect(GTK_OBJECT(devtools_window_),
|
||||||
|
"delete-event",
|
||||||
|
G_CALLBACK(gtk_widget_hide_on_delete),
|
||||||
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) {
|
void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) {
|
||||||
GtkWidget *devtools = inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView();
|
auto devtools_web_contents =
|
||||||
|
inspectable_web_contents()->devtools_web_contents();
|
||||||
|
GtkWidget *devtools = devtools_web_contents->GetView()->GetNativeView();
|
||||||
GtkWidget *parent = gtk_widget_get_parent(devtools);
|
GtkWidget *parent = gtk_widget_get_parent(devtools);
|
||||||
GtkWidget *pane = on_bottom ? gtk_vpaned_new() : gtk_hpaned_new();
|
GtkWidget *pane = on_bottom ? gtk_vpaned_new() : gtk_hpaned_new();
|
||||||
GtkWidget *view = GetNativeView();
|
GtkWidget *view = GetNativeView();
|
||||||
|
@ -193,15 +224,15 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) {
|
||||||
|
|
||||||
GtkAllocation alloc;
|
GtkAllocation alloc;
|
||||||
gtk_widget_get_allocation(browser, &alloc);
|
gtk_widget_get_allocation(browser, &alloc);
|
||||||
gtk_paned_set_position(GTK_PANED(pane), on_bottom ? alloc.height*2/3 : alloc.width/2);
|
gtk_paned_set_position(GTK_PANED(pane),
|
||||||
|
on_bottom ? alloc.height * 2 / 3 : alloc.width / 2);
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
g_object_ref(view);
|
g_object_ref(view);
|
||||||
gtk_container_remove(GTK_CONTAINER(browser), view);
|
gtk_container_remove(GTK_CONTAINER(browser), view);
|
||||||
gtk_paned_add1(GTK_PANED(pane), view);
|
gtk_paned_add1(GTK_PANED(pane), view);
|
||||||
gtk_paned_add2(GTK_PANED(pane), devtools);
|
gtk_paned_add2(GTK_PANED(pane), devtools);
|
||||||
g_object_unref(view);
|
g_object_unref(view);
|
||||||
}
|
} else if (GTK_IS_PANED(parent)) {
|
||||||
else if (GTK_IS_PANED(parent)) {
|
|
||||||
g_object_ref(view);
|
g_object_ref(view);
|
||||||
g_object_ref(devtools);
|
g_object_ref(devtools);
|
||||||
gtk_container_remove(GTK_CONTAINER(parent), view);
|
gtk_container_remove(GTK_CONTAINER(parent), view);
|
||||||
|
@ -211,8 +242,7 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) {
|
||||||
g_object_unref(view);
|
g_object_unref(view);
|
||||||
g_object_unref(devtools);
|
g_object_unref(devtools);
|
||||||
gtk_container_remove(GTK_CONTAINER(browser), parent);
|
gtk_container_remove(GTK_CONTAINER(browser), parent);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
DCHECK(parent == devtools_window_);
|
DCHECK(parent == devtools_window_);
|
||||||
g_object_ref(view);
|
g_object_ref(view);
|
||||||
gtk_container_remove(GTK_CONTAINER(devtools_window_), devtools);
|
gtk_container_remove(GTK_CONTAINER(devtools_window_), devtools);
|
||||||
|
@ -229,9 +259,10 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) {
|
||||||
GtkWidget *InspectableWebContentsViewLinux::GetBrowserWindow() {
|
GtkWidget *InspectableWebContentsViewLinux::GetBrowserWindow() {
|
||||||
GtkWidget *view = GetNativeView();
|
GtkWidget *view = GetNativeView();
|
||||||
GtkWidget *parent = gtk_widget_get_parent(view);
|
GtkWidget *parent = gtk_widget_get_parent(view);
|
||||||
GtkWidget *browser = GTK_IS_PANED(parent) ? gtk_widget_get_parent(parent) : parent;
|
GtkWidget *browser =
|
||||||
|
GTK_IS_PANED(parent) ? gtk_widget_get_parent(parent) : parent;
|
||||||
DCHECK(GTK_IS_WINDOW(browser));
|
DCHECK(GTK_IS_WINDOW(browser));
|
||||||
return browser;
|
return browser;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -10,8 +10,9 @@ namespace brightray {
|
||||||
class InspectableWebContentsImpl;
|
class InspectableWebContentsImpl;
|
||||||
|
|
||||||
class InspectableWebContentsViewLinux : public InspectableWebContentsView {
|
class InspectableWebContentsViewLinux : public InspectableWebContentsView {
|
||||||
public:
|
public:
|
||||||
InspectableWebContentsViewLinux(InspectableWebContentsImpl*);
|
explicit InspectableWebContentsViewLinux(
|
||||||
|
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||||
~InspectableWebContentsViewLinux();
|
~InspectableWebContentsViewLinux();
|
||||||
|
|
||||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||||
|
@ -19,9 +20,11 @@ public:
|
||||||
virtual void CloseDevTools() OVERRIDE;
|
virtual void CloseDevTools() OVERRIDE;
|
||||||
virtual bool SetDockSide(const std::string& side) OVERRIDE;
|
virtual bool SetDockSide(const std::string& side) OVERRIDE;
|
||||||
|
|
||||||
InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; }
|
InspectableWebContentsImpl* inspectable_web_contents() {
|
||||||
|
return inspectable_web_contents_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Show the dev tools in their own window. If they're already shown
|
// Show the dev tools in their own window. If they're already shown
|
||||||
// somewhere else, remove them cleanly and take any GtkPaned out of the
|
// somewhere else, remove them cleanly and take any GtkPaned out of the
|
||||||
// window.
|
// window.
|
||||||
|
@ -49,6 +52,6 @@ private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewLinux);
|
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewLinux);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#import "base/mac/scoped_sending_event.h"
|
#import "base/mac/scoped_sending_event.h"
|
||||||
|
|
||||||
@interface BRYApplication : NSApplication <CrAppProtocol, CrAppControlProtocol> {
|
@interface BRYApplication : NSApplication<CrAppProtocol, CrAppControlProtocol> {
|
||||||
BOOL _handlingSendEvent;
|
BOOL _handlingSendEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ const content::MediaStreamDevice* FindDeviceWithId(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -153,7 +153,6 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
|
||||||
const content::MediaStreamDevice& device,
|
const content::MediaStreamDevice& device,
|
||||||
content::MediaRequestState state) {
|
content::MediaRequestState state) {
|
||||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged(
|
void MediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged(
|
||||||
|
@ -175,7 +174,7 @@ 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;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE-CHROMIUM file.
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
#include "network_delegate.h"
|
#include "browser/network_delegate.h"
|
||||||
|
|
||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
|
|
||||||
|
@ -102,4 +102,4 @@ void NetworkDelegate::OnRequestWaitStateChange(
|
||||||
RequestWaitState waiting) {
|
RequestWaitState waiting) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -15,28 +15,53 @@ class NetworkDelegate : public net::NetworkDelegate {
|
||||||
virtual ~NetworkDelegate();
|
virtual ~NetworkDelegate();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* new_url) OVERRIDE;
|
virtual int OnBeforeURLRequest(net::URLRequest* request,
|
||||||
virtual int OnBeforeSendHeaders(net::URLRequest* request, const net::CompletionCallback& callback, net::HttpRequestHeaders* headers) OVERRIDE;
|
const net::CompletionCallback& callback,
|
||||||
virtual void OnSendHeaders(net::URLRequest* request, const net::HttpRequestHeaders& headers) OVERRIDE;
|
GURL* new_url) OVERRIDE;
|
||||||
virtual int OnHeadersReceived(net::URLRequest* request, const net::CompletionCallback& callback, const net::HttpResponseHeaders* original_response_headers, scoped_refptr<net::HttpResponseHeaders>* override_response_headers) OVERRIDE;
|
virtual int OnBeforeSendHeaders(net::URLRequest* request,
|
||||||
virtual void OnBeforeRedirect(net::URLRequest* request, const GURL& new_location) OVERRIDE;
|
const net::CompletionCallback& callback,
|
||||||
|
net::HttpRequestHeaders* headers) OVERRIDE;
|
||||||
|
virtual void OnSendHeaders(net::URLRequest* request,
|
||||||
|
const net::HttpRequestHeaders& headers) OVERRIDE;
|
||||||
|
virtual int OnHeadersReceived(
|
||||||
|
net::URLRequest* request,
|
||||||
|
const net::CompletionCallback& callback,
|
||||||
|
const net::HttpResponseHeaders* original_response_headers,
|
||||||
|
scoped_refptr<net::HttpResponseHeaders>*
|
||||||
|
override_response_headers) OVERRIDE;
|
||||||
|
virtual void OnBeforeRedirect(net::URLRequest* request,
|
||||||
|
const GURL& new_location) OVERRIDE;
|
||||||
virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
|
virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
|
||||||
virtual void OnRawBytesRead(const net::URLRequest& request, int bytes_read) OVERRIDE;
|
virtual void OnRawBytesRead(const net::URLRequest& request,
|
||||||
|
int bytes_read) OVERRIDE;
|
||||||
virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE;
|
virtual void OnCompleted(net::URLRequest* request, bool started) OVERRIDE;
|
||||||
virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE;
|
virtual void OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE;
|
||||||
virtual void OnPACScriptError(int line_number, const string16& error) OVERRIDE;
|
virtual void OnPACScriptError(int line_number,
|
||||||
virtual AuthRequiredResponse OnAuthRequired(net::URLRequest* request, const net::AuthChallengeInfo& auth_info, const AuthCallback& callback, net::AuthCredentials* credentials) OVERRIDE;
|
const string16& error) OVERRIDE;
|
||||||
virtual bool OnCanGetCookies(const net::URLRequest& request, const net::CookieList& cookie_list) OVERRIDE;
|
virtual AuthRequiredResponse OnAuthRequired(
|
||||||
virtual bool OnCanSetCookie(const net::URLRequest& request, const std::string& cookie_line, net::CookieOptions* options) OVERRIDE;
|
net::URLRequest* request,
|
||||||
virtual bool OnCanAccessFile(const net::URLRequest& request, const base::FilePath& path) const OVERRIDE;
|
const net::AuthChallengeInfo& auth_info,
|
||||||
virtual bool OnCanThrottleRequest(const net::URLRequest& request) const OVERRIDE;
|
const AuthCallback& callback,
|
||||||
virtual int OnBeforeSocketStreamConnect(net::SocketStream* stream, const net::CompletionCallback& callback) OVERRIDE;
|
net::AuthCredentials* credentials) OVERRIDE;
|
||||||
virtual void OnRequestWaitStateChange(const net::URLRequest& request, RequestWaitState state) OVERRIDE;
|
virtual bool OnCanGetCookies(const net::URLRequest& request,
|
||||||
|
const net::CookieList& cookie_list) OVERRIDE;
|
||||||
|
virtual bool OnCanSetCookie(const net::URLRequest& request,
|
||||||
|
const std::string& cookie_line,
|
||||||
|
net::CookieOptions* options) OVERRIDE;
|
||||||
|
virtual bool OnCanAccessFile(const net::URLRequest& request,
|
||||||
|
const base::FilePath& path) const OVERRIDE;
|
||||||
|
virtual bool OnCanThrottleRequest(
|
||||||
|
const net::URLRequest& request) const OVERRIDE;
|
||||||
|
virtual int OnBeforeSocketStreamConnect(
|
||||||
|
net::SocketStream* stream,
|
||||||
|
const net::CompletionCallback& callback) OVERRIDE;
|
||||||
|
virtual void OnRequestWaitStateChange(const net::URLRequest& request,
|
||||||
|
RequestWaitState state) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(NetworkDelegate);
|
DISALLOW_COPY_AND_ASSIGN(NetworkDelegate);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace brightray {
|
||||||
|
|
||||||
class NotificationPresenter {
|
class NotificationPresenter {
|
||||||
public:
|
public:
|
||||||
virtual ~NotificationPresenter() {};
|
virtual ~NotificationPresenter() {}
|
||||||
|
|
||||||
static NotificationPresenter* Create();
|
static NotificationPresenter* Create();
|
||||||
|
|
||||||
|
@ -23,6 +23,6 @@ class NotificationPresenter {
|
||||||
int notification_id) = 0;
|
int notification_id) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,10 +30,12 @@ class NotificationPresenterMac : public NotificationPresenter {
|
||||||
int notification_id) OVERRIDE;
|
int notification_id) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, base::scoped_nsobject<NSUserNotification>> notification_map_;
|
typedef std::map<std::string, base::scoped_nsobject<NSUserNotification>>
|
||||||
|
NotificationMap;
|
||||||
|
NotificationMap notification_map_;
|
||||||
base::scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_;
|
base::scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
#include "browser/url_request_context_getter.h"
|
#include "browser/url_request_context_getter.h"
|
||||||
|
|
||||||
#include "network_delegate.h"
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "browser/network_delegate.h"
|
||||||
|
|
||||||
#include "base/strings/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"
|
||||||
|
@ -43,7 +46,8 @@ URLRequestContextGetter::URLRequestContextGetter(
|
||||||
|
|
||||||
std::swap(protocol_handlers_, *protocol_handlers);
|
std::swap(protocol_handlers_, *protocol_handlers);
|
||||||
|
|
||||||
proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(io_loop_->message_loop_proxy(), file_loop_));
|
proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
|
||||||
|
io_loop_->message_loop_proxy(), file_loop_));
|
||||||
}
|
}
|
||||||
|
|
||||||
URLRequestContextGetter::~URLRequestContextGetter() {
|
URLRequestContextGetter::~URLRequestContextGetter() {
|
||||||
|
@ -53,8 +57,7 @@ net::HostResolver* URLRequestContextGetter::host_resolver() {
|
||||||
return url_request_context_->host_resolver();
|
return url_request_context_->host_resolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext()
|
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
||||||
{
|
|
||||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||||
|
|
||||||
if (!url_request_context_.get()) {
|
if (!url_request_context_.get()) {
|
||||||
|
@ -87,7 +90,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()));
|
||||||
scoped_ptr<net::HttpServerProperties> server_properties(new net::HttpServerPropertiesImpl);
|
scoped_ptr<net::HttpServerProperties> server_properties(
|
||||||
|
new net::HttpServerPropertiesImpl);
|
||||||
storage_->set_http_server_properties(server_properties.Pass());
|
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"));
|
||||||
|
@ -130,21 +134,25 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext()
|
||||||
new net::URLRequestJobFactoryImpl());
|
new net::URLRequestJobFactoryImpl());
|
||||||
for (auto it = protocol_handlers_.begin(),
|
for (auto it = protocol_handlers_.begin(),
|
||||||
end = protocol_handlers_.end(); it != end; ++it) {
|
end = protocol_handlers_.end(); it != end; ++it) {
|
||||||
bool set_protocol = job_factory->SetProtocolHandler(it->first, it->second.release());
|
bool set_protocol = job_factory->SetProtocolHandler(
|
||||||
|
it->first, it->second.release());
|
||||||
DCHECK(set_protocol);
|
DCHECK(set_protocol);
|
||||||
}
|
}
|
||||||
protocol_handlers_.clear();
|
protocol_handlers_.clear();
|
||||||
job_factory->SetProtocolHandler(chrome::kDataScheme, new net::DataProtocolHandler);
|
job_factory->SetProtocolHandler(
|
||||||
job_factory->SetProtocolHandler(chrome::kFileScheme, new net::FileProtocolHandler);
|
chrome::kDataScheme, new net::DataProtocolHandler);
|
||||||
|
job_factory->SetProtocolHandler(
|
||||||
|
chrome::kFileScheme, new net::FileProtocolHandler);
|
||||||
storage_->set_job_factory(job_factory.release());
|
storage_->set_job_factory(job_factory.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
return url_request_context_.get();
|
return url_request_context_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> URLRequestContextGetter::GetNetworkTaskRunner() const
|
scoped_refptr<base::SingleThreadTaskRunner>
|
||||||
{
|
URLRequestContextGetter::GetNetworkTaskRunner() const {
|
||||||
return content::BrowserThread::GetMessageLoopProxyForThread(content::BrowserThread::IO);
|
return content::BrowserThread::GetMessageLoopProxyForThread(
|
||||||
|
content::BrowserThread::IO);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace brightray {
|
||||||
class NetworkDelegate;
|
class NetworkDelegate;
|
||||||
|
|
||||||
class URLRequestContextGetter : public net::URLRequestContextGetter {
|
class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||||
public:
|
public:
|
||||||
URLRequestContextGetter(
|
URLRequestContextGetter(
|
||||||
const base::FilePath& base_path,
|
const base::FilePath& base_path,
|
||||||
base::MessageLoop* io_loop,
|
base::MessageLoop* io_loop,
|
||||||
|
@ -37,8 +37,9 @@ public:
|
||||||
net::HostResolver* host_resolver();
|
net::HostResolver* host_resolver();
|
||||||
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
|
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const OVERRIDE;
|
virtual scoped_refptr<base::SingleThreadTaskRunner>
|
||||||
|
GetNetworkTaskRunner() const OVERRIDE;
|
||||||
|
|
||||||
base::FilePath base_path_;
|
base::FilePath base_path_;
|
||||||
base::MessageLoop* io_loop_;
|
base::MessageLoop* io_loop_;
|
||||||
|
@ -53,6 +54,6 @@ private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter);
|
DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,4 +56,4 @@ content::WebUIController* WebUIControllerFactory::CreateWebUIControllerForURL(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -15,11 +15,11 @@ class BrowserContext;
|
||||||
|
|
||||||
class WebUIControllerFactory : public content::WebUIControllerFactory {
|
class WebUIControllerFactory : public content::WebUIControllerFactory {
|
||||||
public:
|
public:
|
||||||
WebUIControllerFactory(BrowserContext* browser_context);
|
explicit WebUIControllerFactory(BrowserContext* browser_context);
|
||||||
virtual ~WebUIControllerFactory();
|
virtual ~WebUIControllerFactory();
|
||||||
|
|
||||||
virtual content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context,
|
virtual content::WebUI::TypeID GetWebUIType(
|
||||||
const GURL& url) const OVERRIDE;
|
content::BrowserContext* browser_context, const GURL& url) const OVERRIDE;
|
||||||
virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
|
virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
|
||||||
const GURL& url) const OVERRIDE;
|
const GURL& url) const OVERRIDE;
|
||||||
virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
|
virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
|
||||||
|
@ -37,6 +37,6 @@ class WebUIControllerFactory : public content::WebUIControllerFactory {
|
||||||
DISALLOW_COPY_AND_ASSIGN(WebUIControllerFactory);
|
DISALLOW_COPY_AND_ASSIGN(WebUIControllerFactory);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
DevToolsWindow* DevToolsWindow::Create(InspectableWebContentsViewWin* controller) {
|
DevToolsWindow* DevToolsWindow::Create(
|
||||||
|
InspectableWebContentsViewWin* controller) {
|
||||||
return new DevToolsWindow(controller);
|
return new DevToolsWindow(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +21,18 @@ DevToolsWindow::~DevToolsWindow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT DevToolsWindow::OnCreate(UINT, WPARAM, LPARAM, BOOL&) {
|
LRESULT DevToolsWindow::OnCreate(UINT, WPARAM, LPARAM, BOOL&) {
|
||||||
SetParent(controller_->inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(), hwnd());
|
auto devtools_web_contents =
|
||||||
|
controller_->inspectable_web_contents()->devtools_web_contents();
|
||||||
|
SetParent(devtools_web_contents->GetView()->GetNativeView(), hwnd());
|
||||||
SetWindowText(hwnd(), L"Developer Tools");
|
SetWindowText(hwnd(), L"Developer Tools");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT DevToolsWindow::OnDestroy(UINT, WPARAM, LPARAM, BOOL&) {
|
LRESULT DevToolsWindow::OnDestroy(UINT, WPARAM, LPARAM, BOOL&) {
|
||||||
SetParent(controller_->inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(), ui::GetHiddenWindow());
|
auto devtools_web_contents =
|
||||||
|
controller_->inspectable_web_contents()->devtools_web_contents();
|
||||||
|
SetParent(
|
||||||
|
devtools_web_contents->GetView()->GetNativeView(), ui::GetHiddenWindow());
|
||||||
delete this;
|
delete this;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +41,9 @@ LRESULT DevToolsWindow::OnSize(UINT, WPARAM, LPARAM, BOOL&) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(hwnd(), &rect);
|
GetClientRect(hwnd(), &rect);
|
||||||
|
|
||||||
SetWindowPos(controller_->inspectable_web_contents()->devtools_web_contents()->GetView()->GetNativeView(),
|
auto devtools_web_contents =
|
||||||
|
controller_->inspectable_web_contents()->devtools_web_contents();
|
||||||
|
SetWindowPos(devtools_web_contents->GetView()->GetNativeView(),
|
||||||
nullptr,
|
nullptr,
|
||||||
rect.left, rect.top,
|
rect.left, rect.top,
|
||||||
rect.right - rect.left, rect.bottom - rect.top,
|
rect.right - rect.left, rect.bottom - rect.top,
|
||||||
|
@ -44,4 +52,4 @@ LRESULT DevToolsWindow::OnSize(UINT, WPARAM, LPARAM, BOOL&) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -8,9 +8,11 @@ namespace brightray {
|
||||||
|
|
||||||
class InspectableWebContentsViewWin;
|
class InspectableWebContentsViewWin;
|
||||||
|
|
||||||
class DevToolsWindow : public ui::WindowImpl, public base::SupportsWeakPtr<DevToolsWindow> {
|
class DevToolsWindow : public ui::WindowImpl,
|
||||||
|
public base::SupportsWeakPtr<DevToolsWindow> {
|
||||||
public:
|
public:
|
||||||
static DevToolsWindow* Create(InspectableWebContentsViewWin*);
|
static DevToolsWindow* Create(
|
||||||
|
InspectableWebContentsViewWin* inspectable_web_contents_view_win);
|
||||||
|
|
||||||
BEGIN_MSG_MAP_EX(DevToolsWindow)
|
BEGIN_MSG_MAP_EX(DevToolsWindow)
|
||||||
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||||
|
@ -19,7 +21,8 @@ class DevToolsWindow : public ui::WindowImpl, public base::SupportsWeakPtr<DevTo
|
||||||
END_MSG_MAP()
|
END_MSG_MAP()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DevToolsWindow(InspectableWebContentsViewWin*);
|
explicit DevToolsWindow(
|
||||||
|
InspectableWebContentsViewWin* inspectable_web_contents_view_win);
|
||||||
~DevToolsWindow();
|
~DevToolsWindow();
|
||||||
|
|
||||||
LRESULT OnCreate(UINT message, WPARAM, LPARAM, BOOL& handled);
|
LRESULT OnCreate(UINT message, WPARAM, LPARAM, BOOL& handled);
|
||||||
|
@ -31,6 +34,6 @@ class DevToolsWindow : public ui::WindowImpl, public base::SupportsWeakPtr<DevTo
|
||||||
DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
|
DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,11 +15,13 @@ const int kWindowInset = 100;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl* inspectable_web_contents) {
|
InspectableWebContentsView* CreateInspectableContentsView(
|
||||||
|
InspectableWebContentsImpl* inspectable_web_contents) {
|
||||||
return new InspectableWebContentsViewWin(inspectable_web_contents);
|
return new InspectableWebContentsViewWin(inspectable_web_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
InspectableWebContentsViewWin::InspectableWebContentsViewWin(InspectableWebContentsImpl* inspectable_web_contents)
|
InspectableWebContentsViewWin::InspectableWebContentsViewWin(
|
||||||
|
InspectableWebContentsImpl* inspectable_web_contents)
|
||||||
: inspectable_web_contents_(inspectable_web_contents) {
|
: inspectable_web_contents_(inspectable_web_contents) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +31,8 @@ InspectableWebContentsViewWin::~InspectableWebContentsViewWin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
|
gfx::NativeView InspectableWebContentsViewWin::GetNativeView() const {
|
||||||
return inspectable_web_contents_->GetWebContents()->GetView()->GetNativeView();
|
auto web_contents = inspectable_web_contents_->GetWebContents();
|
||||||
|
return web_contents->GetView()->GetNativeView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsViewWin::ShowDevTools() {
|
void InspectableWebContentsViewWin::ShowDevTools() {
|
||||||
|
@ -41,7 +44,9 @@ void InspectableWebContentsViewWin::ShowDevTools() {
|
||||||
auto contents_view = inspectable_web_contents_->GetWebContents()->GetView();
|
auto contents_view = inspectable_web_contents_->GetWebContents()->GetView();
|
||||||
auto size = contents_view->GetContainerSize();
|
auto size = contents_view->GetContainerSize();
|
||||||
size.Enlarge(-kWindowInset, -kWindowInset);
|
size.Enlarge(-kWindowInset, -kWindowInset);
|
||||||
ui::CenterAndSizeWindow(contents_view->GetNativeView(), devtools_window_->hwnd(), size);
|
ui::CenterAndSizeWindow(contents_view->GetNativeView(),
|
||||||
|
devtools_window_->hwnd(),
|
||||||
|
size);
|
||||||
|
|
||||||
ShowWindow(devtools_window_->hwnd(), SW_SHOWNORMAL);
|
ShowWindow(devtools_window_->hwnd(), SW_SHOWNORMAL);
|
||||||
}
|
}
|
||||||
|
@ -56,4 +61,4 @@ bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -12,8 +12,9 @@ class DevToolsWindow;
|
||||||
class InspectableWebContentsImpl;
|
class InspectableWebContentsImpl;
|
||||||
|
|
||||||
class InspectableWebContentsViewWin : public InspectableWebContentsView {
|
class InspectableWebContentsViewWin : public InspectableWebContentsView {
|
||||||
public:
|
public:
|
||||||
InspectableWebContentsViewWin(InspectableWebContentsImpl*);
|
explicit InspectableWebContentsViewWin(
|
||||||
|
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||||
~InspectableWebContentsViewWin();
|
~InspectableWebContentsViewWin();
|
||||||
|
|
||||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||||
|
@ -21,9 +22,11 @@ public:
|
||||||
virtual void CloseDevTools() OVERRIDE;
|
virtual void CloseDevTools() OVERRIDE;
|
||||||
virtual bool SetDockSide(const std::string& side) OVERRIDE;
|
virtual bool SetDockSide(const std::string& side) OVERRIDE;
|
||||||
|
|
||||||
InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; }
|
InspectableWebContentsImpl* inspectable_web_contents() {
|
||||||
|
return inspectable_web_contents_;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Owns us.
|
// Owns us.
|
||||||
InspectableWebContentsImpl* inspectable_web_contents_;
|
InspectableWebContentsImpl* inspectable_web_contents_;
|
||||||
|
|
||||||
|
@ -32,6 +35,6 @@ private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewWin);
|
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewWin);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,13 +7,17 @@
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
std::string GetApplicationName() {
|
std::string GetApplicationName() {
|
||||||
auto info = make_scoped_ptr(FileVersionInfo::CreateFileVersionInfoForModule(GetModuleHandle(nullptr)));
|
auto module = GetModuleHandle(nullptr);
|
||||||
|
auto info = make_scoped_ptr(
|
||||||
|
FileVersionInfo::CreateFileVersionInfoForModule(module));
|
||||||
return UTF16ToUTF8(info->product_name());
|
return UTF16ToUTF8(info->product_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetApplicationVersion() {
|
std::string GetApplicationVersion() {
|
||||||
auto info = make_scoped_ptr(FileVersionInfo::CreateFileVersionInfoForModule(GetModuleHandle(nullptr)));
|
auto module = GetModuleHandle(nullptr);
|
||||||
|
auto info = make_scoped_ptr(
|
||||||
|
FileVersionInfo::CreateFileVersionInfoForModule(module));
|
||||||
return UTF16ToUTF8(info->product_version());
|
return UTF16ToUTF8(info->product_version());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -22,19 +22,23 @@ ContentClient::~ContentClient() {
|
||||||
std::string ContentClient::GetProduct() const {
|
std::string ContentClient::GetProduct() const {
|
||||||
auto name = GetApplicationName();
|
auto name = GetApplicationName();
|
||||||
RemoveChars(name, kWhitespaceASCII, &name);
|
RemoveChars(name, kWhitespaceASCII, &name);
|
||||||
return base::StringPrintf("%s/%s", name.c_str(), GetApplicationVersion().c_str());
|
return base::StringPrintf("%s/%s",
|
||||||
|
name.c_str(), GetApplicationVersion().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ContentClient::GetUserAgent() const {
|
std::string ContentClient::GetUserAgent() const {
|
||||||
return webkit_glue::BuildUserAgentFromProduct(GetProduct());
|
return webkit_glue::BuildUserAgentFromProduct(GetProduct());
|
||||||
}
|
}
|
||||||
|
|
||||||
base::StringPiece ContentClient::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const {
|
base::StringPiece ContentClient::GetDataResource(
|
||||||
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor);
|
int resource_id, ui::ScaleFactor scale_factor) const {
|
||||||
|
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
|
||||||
|
resource_id, scale_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Image& ContentClient::GetNativeImageNamed(int resource_id) const {
|
gfx::Image& ContentClient::GetNativeImageNamed(int resource_id) const {
|
||||||
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
|
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
|
||||||
|
resource_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -11,19 +11,20 @@
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
class ContentClient : public content::ContentClient {
|
class ContentClient : public content::ContentClient {
|
||||||
public:
|
public:
|
||||||
ContentClient();
|
ContentClient();
|
||||||
~ContentClient();
|
~ContentClient();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::string GetProduct() const OVERRIDE;
|
virtual std::string GetProduct() const OVERRIDE;
|
||||||
virtual std::string GetUserAgent() const OVERRIDE;
|
virtual std::string GetUserAgent() const OVERRIDE;
|
||||||
virtual base::StringPiece GetDataResource(int resource_id, ui::ScaleFactor) const OVERRIDE;
|
virtual base::StringPiece GetDataResource(int resource_id,
|
||||||
|
ui::ScaleFactor) const OVERRIDE;
|
||||||
virtual gfx::Image& GetNativeImageNamed(int resource_id) const OVERRIDE;
|
virtual gfx::Image& GetNativeImageNamed(int resource_id) const OVERRIDE;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ContentClient);
|
DISALLOW_COPY_AND_ASSIGN(ContentClient);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
// base/mac/foundation_util.h contains an incompatible declaration of NSSearchPathDirectory,
|
// base/mac/foundation_util.h contains an incompatible declaration of
|
||||||
// so here we #define it to be something else.
|
// NSSearchPathDirectory, so here we #define it to be something else.
|
||||||
#define NSSearchPathDirectory NSSearchPathDirectory___PRE_10_8
|
#define NSSearchPathDirectory NSSearchPathDirectory___PRE_10_8
|
||||||
#import "base/mac/foundation_util.h"
|
#import "base/mac/foundation_util.h"
|
||||||
#undef NSSearchPathDirectory
|
#undef NSSearchPathDirectory
|
||||||
|
|
|
@ -9,12 +9,13 @@ class FilePath;
|
||||||
|
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
// The "main" application bundle is the outermost bundle for this logical application. E.g., if you
|
// The "main" application bundle is the outermost bundle for this logical
|
||||||
// have MyApp.app and MyApp.app/Contents/Frameworks/MyApp Helper.app, the main application bundle is
|
// application. E.g., if you have MyApp.app and
|
||||||
// MyApp.app, no matter which executable is currently running.
|
// MyApp.app/Contents/Frameworks/MyApp Helper.app, the main application bundle
|
||||||
|
// is MyApp.app, no matter which executable is currently running.
|
||||||
NSBundle* MainApplicationBundle();
|
NSBundle* MainApplicationBundle();
|
||||||
base::FilePath MainApplicationBundlePath();
|
base::FilePath MainApplicationBundlePath();
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,8 +53,10 @@ void MainDelegate::InitializeResourceBundle() {
|
||||||
|
|
||||||
std::vector<base::FilePath> pak_paths;
|
std::vector<base::FilePath> pak_paths;
|
||||||
AddPakPaths(&pak_paths);
|
AddPakPaths(&pak_paths);
|
||||||
for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it)
|
for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it) {
|
||||||
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(*it, ui::SCALE_FACTOR_NONE);
|
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
|
||||||
|
*it, ui::SCALE_FACTOR_NONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
#ifndef BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
#ifndef BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
||||||
#define BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
#define BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "content/public/app/content_main_delegate.h"
|
#include "content/public/app/content_main_delegate.h"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
class FilePath;
|
class FilePath;
|
||||||
|
@ -19,21 +20,23 @@ namespace brightray {
|
||||||
class ContentClient;
|
class ContentClient;
|
||||||
|
|
||||||
class MainDelegate : public content::ContentMainDelegate {
|
class MainDelegate : public content::ContentMainDelegate {
|
||||||
public:
|
public:
|
||||||
MainDelegate();
|
MainDelegate();
|
||||||
~MainDelegate();
|
~MainDelegate();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Subclasses can override this to provide their own ContentClient implementation.
|
// Subclasses can override this to provide their own ContentClient
|
||||||
|
// implementation.
|
||||||
virtual scoped_ptr<ContentClient> CreateContentClient();
|
virtual scoped_ptr<ContentClient> CreateContentClient();
|
||||||
|
|
||||||
// Subclasses can override this to provide additional .pak files to be included in the ui::ResourceBundle.
|
// Subclasses can override this to provide additional .pak files to be
|
||||||
|
// included in the ui::ResourceBundle.
|
||||||
virtual void AddPakPaths(std::vector<base::FilePath>* pak_paths) {}
|
virtual void AddPakPaths(std::vector<base::FilePath>* pak_paths) {}
|
||||||
|
|
||||||
virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;
|
virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;
|
||||||
virtual void PreSandboxStartup() OVERRIDE;
|
virtual void PreSandboxStartup() OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeResourceBundle();
|
void InitializeResourceBundle();
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
static base::FilePath GetResourcesPakFilePath();
|
static base::FilePath GetResourcesPakFilePath();
|
||||||
|
@ -47,5 +50,5 @@ private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(MainDelegate);
|
DISALLOW_COPY_AND_ASSIGN(MainDelegate);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace brightray
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,7 +18,8 @@ def main():
|
||||||
|
|
||||||
url = 'https://{0}.s3.amazonaws.com/libchromiumcontent'.format(os.environ['JANKY_ARTIFACTS_S3_BUCKET'])
|
url = 'https://{0}.s3.amazonaws.com/libchromiumcontent'.format(os.environ['JANKY_ARTIFACTS_S3_BUCKET'])
|
||||||
return (run_script('bootstrap', url) or
|
return (run_script('bootstrap', url) or
|
||||||
run_script('build'))
|
run_script('build') or
|
||||||
|
run_script('cpplint'))
|
||||||
|
|
||||||
|
|
||||||
def copy_to_environment(credentials_file):
|
def copy_to_environment(credentials_file):
|
||||||
|
|
47
brightray/script/cpplint
Executable file
47
brightray/script/cpplint
Executable file
|
@ -0,0 +1,47 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import fnmatch
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
CPPLINT = os.path.join(SOURCE_ROOT, 'vendor', 'google-styleguide', 'trunk', 'cpplint', 'cpplint.py')
|
||||||
|
|
||||||
|
IGNORED_FILES = [
|
||||||
|
os.path.join('browser', 'mac', 'bry_inspectable_web_contents_view_private.h'),
|
||||||
|
]
|
||||||
|
|
||||||
|
FILTERS = [
|
||||||
|
'-build/header_guard',
|
||||||
|
'-build/include_what_you_use',
|
||||||
|
'-legal/copyright',
|
||||||
|
# cpplint doesn't like the BOOL& parameters that ui::WindowImpl uses.
|
||||||
|
'-runtime/references',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.chdir(SOURCE_ROOT)
|
||||||
|
files = list_files(['browser', 'common'],
|
||||||
|
['*.cc', '*.h'])
|
||||||
|
return cpplint(set(files) - set(IGNORED_FILES))
|
||||||
|
|
||||||
|
|
||||||
|
def list_files(directories, filters):
|
||||||
|
matches = []
|
||||||
|
for directory in directories:
|
||||||
|
for root, _, filenames, in os.walk(directory):
|
||||||
|
for f in filters:
|
||||||
|
for filename in fnmatch.filter(filenames, f):
|
||||||
|
matches.append(os.path.join(root, filename))
|
||||||
|
return matches
|
||||||
|
|
||||||
|
|
||||||
|
def cpplint(files):
|
||||||
|
return subprocess.call([sys.executable, CPPLINT, '--filter=' + ','.join(FILTERS)] + list(files))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
1
brightray/vendor/google-styleguide
vendored
Submodule
1
brightray/vendor/google-styleguide
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 8025f5495c04f1cf9e0d65a0aaa97b58c304faf7
|
Loading…
Add table
Add a link
Reference in a new issue