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"]
|
||||
path = vendor/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();
|
||||
}
|
||||
|
||||
BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts(const content::MainFunctionParams&) {
|
||||
BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) {
|
||||
return new BrowserMainParts;
|
||||
}
|
||||
|
||||
content::BrowserMainParts* BrowserClient::CreateBrowserMainParts(const content::MainFunctionParams& parameters) {
|
||||
content::BrowserMainParts* BrowserClient::CreateBrowserMainParts(
|
||||
const content::MainFunctionParams& parameters) {
|
||||
DCHECK(!browser_main_parts_);
|
||||
browser_main_parts_ = OverrideCreateBrowserMainParts(parameters);
|
||||
return browser_main_parts_;
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* BrowserClient::CreateRequestContext(content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers) {
|
||||
return static_cast<BrowserContext*>(browser_context)->CreateRequestContext(protocol_handlers);
|
||||
net::URLRequestContextGetter* BrowserClient::CreateRequestContext(
|
||||
content::BrowserContext* browser_context,
|
||||
content::ProtocolHandlerMap* protocol_handlers) {
|
||||
auto context = static_cast<BrowserContext*>(browser_context);
|
||||
return context->CreateRequestContext(protocol_handlers);
|
||||
}
|
||||
|
||||
void BrowserClient::ShowDesktopNotification(
|
||||
|
@ -74,11 +79,12 @@ void BrowserClient::CancelDesktopNotification(
|
|||
auto presenter = notification_presenter();
|
||||
if (!presenter)
|
||||
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() {
|
||||
return MediaCaptureDevicesDispatcher::GetInstance();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -14,7 +14,7 @@ class BrowserMainParts;
|
|||
class NotificationPresenter;
|
||||
|
||||
class BrowserClient : public content::ContentBrowserClient {
|
||||
public:
|
||||
public:
|
||||
static BrowserClient* Get();
|
||||
|
||||
BrowserClient();
|
||||
|
@ -24,17 +24,21 @@ public:
|
|||
BrowserMainParts* browser_main_parts() { return browser_main_parts_; }
|
||||
NotificationPresenter* notification_presenter();
|
||||
|
||||
protected:
|
||||
// Subclasses should override this to provide their own BrowserMainParts implementation. The
|
||||
// lifetime of the returned instance is managed by the caller.
|
||||
virtual BrowserMainParts* OverrideCreateBrowserMainParts(const content::MainFunctionParams&);
|
||||
protected:
|
||||
// Subclasses should override this to provide their own BrowserMainParts
|
||||
// implementation. The lifetime of the returned instance is managed by the
|
||||
// caller.
|
||||
virtual BrowserMainParts* OverrideCreateBrowserMainParts(
|
||||
const content::MainFunctionParams&);
|
||||
|
||||
// Subclasses that override this (e.g., to provide their own protocol handlers) should call this
|
||||
// implementation after doing their own work.
|
||||
virtual net::URLRequestContextGetter* CreateRequestContext(content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE;
|
||||
// Subclasses that override this (e.g., to provide their own protocol
|
||||
// handlers) should call this implementation after doing their own work.
|
||||
virtual net::URLRequestContextGetter* CreateRequestContext(
|
||||
content::BrowserContext*, content::ProtocolHandlerMap*) OVERRIDE;
|
||||
|
||||
private:
|
||||
virtual content::BrowserMainParts* CreateBrowserMainParts(const content::MainFunctionParams&) OVERRIDE;
|
||||
private:
|
||||
virtual content::BrowserMainParts* CreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) OVERRIDE;
|
||||
virtual void ShowDesktopNotification(
|
||||
const content::ShowDesktopNotificationHostMsgParams&,
|
||||
int render_process_id,
|
||||
|
@ -52,6 +56,6 @@ private:
|
|||
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE-CHROMIUM file.
|
||||
|
||||
#include "browser_context.h"
|
||||
#include "browser/browser_context.h"
|
||||
|
||||
#include "browser/download_manager_delegate.h"
|
||||
#include "browser/inspectable_web_contents_impl.h"
|
||||
#include "browser/network_delegate.h"
|
||||
#include "browser/url_request_context_getter.h"
|
||||
#include "common/application_info.h"
|
||||
|
||||
#include "base/environment.h"
|
||||
|
@ -19,7 +20,6 @@
|
|||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/resource_context.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "url_request_context_getter.h"
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
#include "base/nix/xdg_util.h"
|
||||
|
@ -28,28 +28,30 @@
|
|||
namespace brightray {
|
||||
|
||||
class BrowserContext::ResourceContext : public content::ResourceContext {
|
||||
public:
|
||||
public:
|
||||
ResourceContext() : getter_(nullptr) {}
|
||||
|
||||
void set_url_request_context_getter(URLRequestContextGetter* getter) {
|
||||
getter_ = getter;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
virtual net::HostResolver* GetHostResolver() OVERRIDE {
|
||||
return getter_->host_resolver();
|
||||
}
|
||||
|
||||
|
||||
virtual net::URLRequestContext* GetRequestContext() OVERRIDE {
|
||||
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 {
|
||||
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 {
|
||||
return true;
|
||||
}
|
||||
|
@ -76,7 +78,8 @@ void BrowserContext::Initialize() {
|
|||
auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences"));
|
||||
PrefServiceBuilder builder;
|
||||
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);
|
||||
RegisterInternalPrefs(registry);
|
||||
|
@ -92,12 +95,17 @@ void BrowserContext::RegisterInternalPrefs(PrefRegistrySimple* registry) {
|
|||
InspectableWebContentsImpl::RegisterPrefs(registry);
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* BrowserContext::CreateRequestContext(content::ProtocolHandlerMap* protocol_handlers) {
|
||||
net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers) {
|
||||
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(
|
||||
GetPath(),
|
||||
content::BrowserThread::UnsafeGetMessageLoopForThread(content::BrowserThread::IO),
|
||||
content::BrowserThread::UnsafeGetMessageLoopForThread(content::BrowserThread::FILE),
|
||||
io_loop,
|
||||
file_loop,
|
||||
CreateNetworkDelegate().Pass(),
|
||||
protocol_handlers);
|
||||
resource_context_->set_url_request_context_getter(url_request_getter_.get());
|
||||
|
@ -120,7 +128,8 @@ net::URLRequestContextGetter* BrowserContext::GetRequestContext() {
|
|||
return GetDefaultStoragePartition(this)->GetURLRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* BrowserContext::GetRequestContextForRenderProcess(int renderer_child_id) {
|
||||
net::URLRequestContextGetter* BrowserContext::GetRequestContextForRenderProcess(
|
||||
int renderer_child_id) {
|
||||
return GetRequestContext();
|
||||
}
|
||||
|
||||
|
@ -128,15 +137,24 @@ net::URLRequestContextGetter* BrowserContext::GetMediaRequestContext() {
|
|||
return GetRequestContext();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter* BrowserContext::GetMediaRequestContextForRenderProcess(int renderer_child_id) {
|
||||
net::URLRequestContextGetter*
|
||||
BrowserContext::GetMediaRequestContextForRenderProcess(
|
||||
int renderer_child_id) {
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -150,7 +168,8 @@ content::DownloadManagerDelegate* BrowserContext::GetDownloadManagerDelegate() {
|
|||
return download_manager_delegate_.get();
|
||||
}
|
||||
|
||||
content::GeolocationPermissionContext* BrowserContext::GetGeolocationPermissionContext() {
|
||||
content::GeolocationPermissionContext*
|
||||
BrowserContext::GetGeolocationPermissionContext() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -158,4 +177,4 @@ quota::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -18,41 +18,54 @@ class NetworkDelegate;
|
|||
class URLRequestContextGetter;
|
||||
|
||||
class BrowserContext : public content::BrowserContext {
|
||||
public:
|
||||
public:
|
||||
BrowserContext();
|
||||
~BrowserContext();
|
||||
|
||||
void Initialize();
|
||||
|
||||
net::URLRequestContextGetter* CreateRequestContext(content::ProtocolHandlerMap*);
|
||||
net::URLRequestContextGetter* CreateRequestContext(
|
||||
content::ProtocolHandlerMap*);
|
||||
|
||||
PrefService* prefs() { return prefs_.get(); }
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// 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 base::FilePath GetPath() const OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
class ResourceContext;
|
||||
|
||||
void RegisterInternalPrefs(PrefRegistrySimple*);
|
||||
void RegisterInternalPrefs(PrefRegistrySimple* pref_registry);
|
||||
|
||||
virtual bool IsOffTheRecord() const 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* GetMediaRequestContextForRenderProcess(int renderer_child_id) OVERRIDE;
|
||||
virtual net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(const base::FilePath& partition_path, bool in_memory);
|
||||
virtual void RequestMIDISysExPermission(int render_process_id, int render_view_id, const GURL& requesting_frame, const MIDISysExPermissionCallback&) OVERRIDE;
|
||||
virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
|
||||
int renderer_child_id) OVERRIDE;
|
||||
virtual net::URLRequestContextGetter*
|
||||
GetMediaRequestContextForStoragePartition(
|
||||
const base::FilePath& partition_path, bool in_memory);
|
||||
virtual void RequestMIDISysExPermission(
|
||||
int render_process_id,
|
||||
int render_view_id,
|
||||
const GURL& requesting_frame,
|
||||
const MIDISysExPermissionCallback&) OVERRIDE;
|
||||
virtual content::ResourceContext* GetResourceContext() OVERRIDE;
|
||||
virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() OVERRIDE;
|
||||
virtual content::GeolocationPermissionContext* GetGeolocationPermissionContext() OVERRIDE;
|
||||
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE;
|
||||
virtual content::DownloadManagerDelegate*
|
||||
GetDownloadManagerDelegate() OVERRIDE;
|
||||
virtual content::GeolocationPermissionContext*
|
||||
GetGeolocationPermissionContext() OVERRIDE;
|
||||
virtual quota::SpecialStoragePolicy*
|
||||
GetSpecialStoragePolicy() OVERRIDE;
|
||||
|
||||
base::FilePath path_;
|
||||
scoped_ptr<ResourceContext> resource_context_;
|
||||
|
@ -63,6 +76,6 @@ private:
|
|||
DISALLOW_COPY_AND_ASSIGN(BrowserContext);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,8 +19,10 @@ void BrowserMainParts::PreMainMessageLoopRun() {
|
|||
browser_context_.reset(CreateBrowserContext());
|
||||
browser_context_->Initialize();
|
||||
|
||||
web_ui_controller_factory_.reset(new WebUIControllerFactory(browser_context_.get()));
|
||||
content::WebUIControllerFactory::RegisterFactory(web_ui_controller_factory_.get());
|
||||
web_ui_controller_factory_.reset(
|
||||
new WebUIControllerFactory(browser_context_.get()));
|
||||
content::WebUIControllerFactory::RegisterFactory(
|
||||
web_ui_controller_factory_.get());
|
||||
}
|
||||
|
||||
void BrowserMainParts::PostMainMessageLoopRun() {
|
||||
|
@ -31,4 +33,4 @@ BrowserContext* BrowserMainParts::CreateBrowserContext() {
|
|||
return new BrowserContext;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -15,15 +15,15 @@ class BrowserContext;
|
|||
class WebUIControllerFactory;
|
||||
|
||||
class BrowserMainParts : public content::BrowserMainParts {
|
||||
public:
|
||||
public:
|
||||
BrowserMainParts();
|
||||
~BrowserMainParts();
|
||||
|
||||
BrowserContext* browser_context() { return browser_context_.get(); }
|
||||
|
||||
protected:
|
||||
// Subclasses should override this to provide their own BrowserContxt implementation. The caller
|
||||
// takes ownership of the returned object.
|
||||
protected:
|
||||
// Subclasses should override this to provide their own BrowserContxt
|
||||
// implementation. The caller takes ownership of the returned object.
|
||||
virtual BrowserContext* CreateBrowserContext();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
@ -33,13 +33,13 @@ protected:
|
|||
virtual void PreMainMessageLoopRun() OVERRIDE;
|
||||
virtual void PostMainMessageLoopRun() OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
scoped_ptr<BrowserContext> browser_context_;
|
||||
scoped_ptr<WebUIControllerFactory> web_ui_controller_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BrowserMainParts);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,4 +18,4 @@ void DefaultWebContentsDelegate::RequestMediaAccessPermission(
|
|||
controller.TakeAction();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -5,22 +5,24 @@
|
|||
|
||||
namespace brightray {
|
||||
|
||||
// This class provides some sane default behaviors to any content::WebContents instance (e.g.,
|
||||
// keyboard shortcut handling on Mac).
|
||||
// This class provides some sane default behaviors to any content::WebContents
|
||||
// instance (e.g., keyboard shortcut handling on Mac).
|
||||
class DefaultWebContentsDelegate : public content::WebContentsDelegate {
|
||||
public:
|
||||
public:
|
||||
DefaultWebContentsDelegate();
|
||||
~DefaultWebContentsDelegate();
|
||||
|
||||
protected:
|
||||
virtual void RequestMediaAccessPermission(content::WebContents*,
|
||||
const content::MediaStreamRequest&,
|
||||
const content::MediaResponseCallback&) OVERRIDE;
|
||||
protected:
|
||||
virtual void RequestMediaAccessPermission(
|
||||
content::WebContents*,
|
||||
const content::MediaStreamRequest&,
|
||||
const content::MediaResponseCallback&) OVERRIDE;
|
||||
#if defined(OS_MACOSX)
|
||||
virtual void HandleKeyboardEvent(content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
|
||||
virtual void HandleKeyboardEvent(
|
||||
content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -90,12 +90,12 @@ class BundledDataSource : public content::URLDataSource {
|
|||
DISALLOW_COPY_AND_ASSIGN(BundledDataSource);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DevToolsUI::DevToolsUI(BrowserContext* browser_context, content::WebUI* web_ui)
|
||||
: WebUIController(web_ui) {
|
||||
: WebUIController(web_ui) {
|
||||
web_ui->SetBindings(0);
|
||||
content::URLDataSource::Add(browser_context, new BundledDataSource());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -20,6 +20,6 @@ class DevToolsUI : public content::WebUIController {
|
|||
DISALLOW_COPY_AND_ASSIGN(DevToolsUI);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,6 @@ class DownloadManagerDelegate : public content::DownloadManagerDelegate {
|
|||
DISALLOW_COPY_AND_ASSIGN(DownloadManagerDelegate);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
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);
|
||||
#if defined(OS_MACOSX)
|
||||
// Work around http://crbug.com/279472.
|
||||
|
@ -16,8 +17,9 @@ InspectableWebContents* InspectableWebContents::Create(const content::WebContent
|
|||
return Create(contents);
|
||||
}
|
||||
|
||||
InspectableWebContents* InspectableWebContents::Create(content::WebContents* web_contents) {
|
||||
InspectableWebContents* InspectableWebContents::Create(
|
||||
content::WebContents* web_contents) {
|
||||
return new InspectableWebContentsImpl(web_contents);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -8,10 +8,12 @@ namespace brightray {
|
|||
class InspectableWebContentsView;
|
||||
|
||||
class InspectableWebContents {
|
||||
public:
|
||||
static InspectableWebContents* Create(const content::WebContents::CreateParams&);
|
||||
public:
|
||||
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*);
|
||||
|
||||
virtual ~InspectableWebContents() {}
|
||||
|
@ -22,6 +24,6 @@ public:
|
|||
virtual void ShowDevTools() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,15 +31,18 @@ const char kDockSidePref[] = "brightray.devtools.dockside";
|
|||
}
|
||||
|
||||
// Implemented separately on each platform.
|
||||
InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl*);
|
||||
InspectableWebContentsView* CreateInspectableContentsView(
|
||||
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||
|
||||
void InspectableWebContentsImpl::RegisterPrefs(PrefRegistrySimple* registry) {
|
||||
registry->RegisterStringPref(kDockSidePref, "bottom");
|
||||
}
|
||||
|
||||
InspectableWebContentsImpl::InspectableWebContentsImpl(content::WebContents* web_contents)
|
||||
InspectableWebContentsImpl::InspectableWebContentsImpl(
|
||||
content::WebContents* 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);
|
||||
|
||||
view_.reset(CreateInspectableContentsView(this));
|
||||
|
@ -58,7 +61,9 @@ content::WebContents* InspectableWebContentsImpl::GetWebContents() const {
|
|||
|
||||
void InspectableWebContentsImpl::ShowDevTools() {
|
||||
if (!devtools_web_contents_) {
|
||||
devtools_web_contents_.reset(content::WebContents::Create(content::WebContents::CreateParams(web_contents_->GetBrowserContext())));
|
||||
auto create_params = content::WebContents::CreateParams(
|
||||
web_contents_->GetBrowserContext());
|
||||
devtools_web_contents_.reset(content::WebContents::Create(create_params));
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Work around http://crbug.com/279472.
|
||||
|
@ -68,12 +73,20 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
|||
Observe(devtools_web_contents_.get());
|
||||
devtools_web_contents_->SetDelegate(this);
|
||||
|
||||
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_->GetRenderViewHost());
|
||||
frontend_host_.reset(content::DevToolsClientHost::CreateDevToolsFrontendHost(devtools_web_contents_.get(), this));
|
||||
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, frontend_host_.get());
|
||||
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(
|
||||
web_contents_->GetRenderViewHost());
|
||||
frontend_host_.reset(
|
||||
content::DevToolsClientHost::CreateDevToolsFrontendHost(
|
||||
devtools_web_contents_.get(), this));
|
||||
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
|
||||
agent_host_, frontend_host_.get());
|
||||
|
||||
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_);
|
||||
|
@ -81,8 +94,10 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
|||
}
|
||||
|
||||
void InspectableWebContentsImpl::UpdateFrontendDockSide() {
|
||||
auto javascript = base::StringPrintf("InspectorFrontendAPI.setDockSide(\"%s\")", dock_side_.c_str());
|
||||
devtools_web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16(javascript));
|
||||
auto javascript = base::StringPrintf(
|
||||
"InspectorFrontendAPI.setDockSide(\"%s\")", dock_side_.c_str());
|
||||
devtools_web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
|
||||
string16(), ASCIIToUTF16(javascript));
|
||||
}
|
||||
|
||||
void InspectableWebContentsImpl::ActivateWindow() {
|
||||
|
@ -106,7 +121,8 @@ void InspectableWebContentsImpl::SetDockSide(const std::string& 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);
|
||||
|
||||
UpdateFrontendDockSide();
|
||||
|
@ -115,10 +131,12 @@ void InspectableWebContentsImpl::SetDockSide(const std::string& side) {
|
|||
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() {
|
||||
|
@ -127,26 +145,36 @@ void InspectableWebContentsImpl::RequestFileSystems() {
|
|||
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::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::AboutToNavigateRenderView(content::RenderViewHost* render_view_host) {
|
||||
content::DevToolsClientHost::SetupDevToolsFrontendClient(web_contents()->GetRenderViewHost());
|
||||
void InspectableWebContentsImpl::AboutToNavigateRenderView(
|
||||
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)
|
||||
return;
|
||||
|
||||
|
@ -154,16 +182,19 @@ void InspectableWebContentsImpl::DidFinishLoad(int64, const GURL&, bool is_main_
|
|||
}
|
||||
|
||||
void InspectableWebContentsImpl::WebContentsDestroyed(content::WebContents*) {
|
||||
content::DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_.get());
|
||||
content::DevToolsManager::GetInstance()->ClientHostClosing(
|
||||
frontend_host_.get());
|
||||
Observe(nullptr);
|
||||
agent_host_ = nullptr;
|
||||
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();
|
||||
if (delegate)
|
||||
delegate->HandleKeyboardEvent(source, event);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -28,10 +28,10 @@ class InspectableWebContentsImpl :
|
|||
content::DevToolsFrontendHostDelegate,
|
||||
content::WebContentsObserver,
|
||||
content::WebContentsDelegate {
|
||||
public:
|
||||
static void RegisterPrefs(PrefRegistrySimple*);
|
||||
public:
|
||||
static void RegisterPrefs(PrefRegistrySimple* pref_registry);
|
||||
|
||||
InspectableWebContentsImpl(content::WebContents*);
|
||||
explicit InspectableWebContentsImpl(content::WebContents*);
|
||||
virtual ~InspectableWebContentsImpl();
|
||||
|
||||
virtual InspectableWebContentsView* GetView() const OVERRIDE;
|
||||
|
@ -39,13 +39,15 @@ public:
|
|||
|
||||
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();
|
||||
|
||||
// content::DevToolsFrontendHostDelegate
|
||||
|
||||
|
||||
virtual void ActivateWindow() OVERRIDE;
|
||||
virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE;
|
||||
virtual void CloseWindow() OVERRIDE;
|
||||
|
@ -60,16 +62,18 @@ private:
|
|||
virtual void RequestFileSystems() OVERRIDE;
|
||||
virtual void AddFileSystem() OVERRIDE;
|
||||
virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
|
||||
virtual void IndexPath(int request_id, const std::string& file_system_path) OVERRIDE;
|
||||
virtual void IndexPath(int request_id,
|
||||
const std::string& file_system_path) OVERRIDE;
|
||||
virtual void StopIndexing(int request_id) OVERRIDE;
|
||||
virtual void SearchInPath(int request_id,
|
||||
const std::string& file_system_path,
|
||||
const std::string& query) OVERRIDE;
|
||||
virtual void InspectedContentsClosing() OVERRIDE;
|
||||
|
||||
|
||||
// content::WebContentsObserver
|
||||
|
||||
virtual void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) OVERRIDE;
|
||||
|
||||
virtual void AboutToNavigateRenderView(
|
||||
content::RenderViewHost* render_view_host) OVERRIDE;
|
||||
virtual void DidFinishLoad(int64 frame_id,
|
||||
const GURL& validated_url,
|
||||
bool is_main_frame,
|
||||
|
@ -77,9 +81,10 @@ private:
|
|||
virtual void WebContentsDestroyed(content::WebContents*) OVERRIDE;
|
||||
|
||||
// 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::DevToolsClientHost> frontend_host_;
|
||||
scoped_ptr<content::WebContents> devtools_web_contents_;
|
||||
|
@ -90,6 +95,6 @@ private:
|
|||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsImpl);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
namespace brightray {
|
||||
|
||||
class InspectableWebContentsView {
|
||||
public:
|
||||
public:
|
||||
virtual ~InspectableWebContentsView() {}
|
||||
|
||||
virtual gfx::NativeView GetNativeView() const = 0;
|
||||
|
@ -16,6 +16,6 @@ public:
|
|||
virtual bool SetDockSide(const std::string& side) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef 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;
|
||||
|
||||
|
@ -12,25 +12,28 @@ namespace brightray {
|
|||
class InspectableWebContentsImpl;
|
||||
|
||||
class InspectableWebContentsViewMac : public InspectableWebContentsView {
|
||||
public:
|
||||
InspectableWebContentsViewMac(InspectableWebContentsImpl*);
|
||||
|
||||
public:
|
||||
explicit InspectableWebContentsViewMac(
|
||||
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||
|
||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||
virtual void ShowDevTools() OVERRIDE;
|
||||
virtual void CloseDevTools() 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.
|
||||
InspectableWebContentsImpl* inspectable_web_contents_;
|
||||
|
||||
|
||||
base::scoped_nsobject<BRYInspectableWebContentsView> view_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewMac);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#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 <gtk/gtk.h>
|
||||
|
||||
|
@ -10,12 +10,15 @@
|
|||
|
||||
namespace brightray {
|
||||
|
||||
InspectableWebContentsView* CreateInspectableContentsView(InspectableWebContentsImpl* inspectable_web_contents) {
|
||||
InspectableWebContentsView* CreateInspectableContentsView(
|
||||
InspectableWebContentsImpl* inspectable_web_contents) {
|
||||
return new InspectableWebContentsViewLinux(inspectable_web_contents);
|
||||
}
|
||||
|
||||
InspectableWebContentsViewLinux::InspectableWebContentsViewLinux(InspectableWebContentsImpl* inspectable_web_contents)
|
||||
: inspectable_web_contents_(inspectable_web_contents), devtools_window_(NULL) {
|
||||
InspectableWebContentsViewLinux::InspectableWebContentsViewLinux(
|
||||
InspectableWebContentsImpl* inspectable_web_contents)
|
||||
: inspectable_web_contents_(inspectable_web_contents),
|
||||
devtools_window_(NULL) {
|
||||
}
|
||||
|
||||
InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() {
|
||||
|
@ -26,11 +29,13 @@ InspectableWebContentsViewLinux::~InspectableWebContentsViewLinux() {
|
|||
static void dump_one(GtkWidget *wat, int indent) {
|
||||
GtkAllocation 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,
|
||||
g_type_name_from_instance((GTypeInstance*)wat),
|
||||
g_type_name_from_instance(reinterpret_cast<GTypeInstance*>(wat)),
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -41,21 +46,24 @@ static void dump_the_whole_tree(GtkWidget *wat, int indent) {
|
|||
}
|
||||
dump_one(wat, indent);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_parents(GtkWidget *wat) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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() {
|
||||
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);
|
||||
|
||||
DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::ShowDevTools - parent=%s@%p window=%p dockside=\"%s\"",
|
||||
g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window_, dockside_.c_str());
|
||||
DLOG(INFO) << base::StringPrintf(
|
||||
"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 (dockside_ == "undocked") ShowDevToolsInWindow();
|
||||
else if (dockside_ == "bottom") ShowDevToolsInPane(true);
|
||||
else if (dockside_ == "right") ShowDevToolsInPane(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
DCHECK(parent == devtools_window_);
|
||||
if (dockside_ == "undocked") gtk_widget_show_all(parent);
|
||||
else if (dockside_ == "bottom") ShowDevToolsInPane(true);
|
||||
|
@ -110,16 +124,22 @@ void InspectableWebContentsViewLinux::ShowDevTools() {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
DLOG(INFO) << base::StringPrintf("InspectableWebContentsViewLinux::CloseDevTools - parent=%s@%p window=%p dockside=\"%s\"",
|
||||
g_type_name_from_instance((GTypeInstance*)parent), parent, devtools_window_, dockside_.c_str());
|
||||
DLOG(INFO) << base::StringPrintf(
|
||||
"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) {
|
||||
return; // Not visible -> nothing to do
|
||||
}
|
||||
else if (GTK_IS_PANED(parent)) {
|
||||
} else if (GTK_IS_PANED(parent)) {
|
||||
GtkWidget *browser = GetBrowserWindow();
|
||||
GtkWidget *view = GetNativeView();
|
||||
|
||||
|
@ -129,22 +149,26 @@ void InspectableWebContentsViewLinux::CloseDevTools() {
|
|||
gtk_container_remove(GTK_CONTAINER(browser), parent);
|
||||
gtk_widget_reparent(view, browser);
|
||||
g_object_unref(parent);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
DCHECK(parent == devtools_window_);
|
||||
gtk_widget_hide(parent);
|
||||
}
|
||||
}
|
||||
|
||||
bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) {
|
||||
DLOG(INFO) << "InspectableWebContentsViewLinux::SetDockSide: \"" << side << "\"";
|
||||
if (side != "undocked" && side != "bottom" && side != "right") return false; // unsupported display location
|
||||
if (dockside_ == side) return true; // no change from current location
|
||||
DLOG(INFO) <<
|
||||
"InspectableWebContentsViewLinux::SetDockSide: \"" << side << "\"";
|
||||
if (side != "undocked" && side != "bottom" && side != "right")
|
||||
return false; // unsupported display location
|
||||
if (dockside_ == side)
|
||||
return true; // no change from current location
|
||||
|
||||
dockside_ = side;
|
||||
|
||||
// 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)) {
|
||||
ShowDevTools();
|
||||
}
|
||||
|
@ -153,14 +177,16 @@ bool InspectableWebContentsViewLinux::SetDockSide(const std::string& side) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!devtools_window_) MakeDevToolsWindow();
|
||||
if (!devtools_window_)
|
||||
MakeDevToolsWindow();
|
||||
if (!parent) {
|
||||
gtk_container_add(GTK_CONTAINER(devtools_window_), devtools);
|
||||
}
|
||||
else if (parent != devtools_window_) {
|
||||
} else if (parent != devtools_window_) {
|
||||
DCHECK(GTK_IS_PANED(parent));
|
||||
gtk_widget_reparent(devtools, devtools_window_);
|
||||
|
||||
|
@ -181,11 +207,16 @@ void InspectableWebContentsViewLinux::MakeDevToolsWindow() {
|
|||
devtools_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(devtools_window_), "Developer Tools");
|
||||
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) {
|
||||
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 *pane = on_bottom ? gtk_vpaned_new() : gtk_hpaned_new();
|
||||
GtkWidget *view = GetNativeView();
|
||||
|
@ -193,15 +224,15 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) {
|
|||
|
||||
GtkAllocation 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) {
|
||||
g_object_ref(view);
|
||||
gtk_container_remove(GTK_CONTAINER(browser), view);
|
||||
gtk_paned_add1(GTK_PANED(pane), view);
|
||||
gtk_paned_add2(GTK_PANED(pane), devtools);
|
||||
g_object_unref(view);
|
||||
}
|
||||
else if (GTK_IS_PANED(parent)) {
|
||||
} else if (GTK_IS_PANED(parent)) {
|
||||
g_object_ref(view);
|
||||
g_object_ref(devtools);
|
||||
gtk_container_remove(GTK_CONTAINER(parent), view);
|
||||
|
@ -211,8 +242,7 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) {
|
|||
g_object_unref(view);
|
||||
g_object_unref(devtools);
|
||||
gtk_container_remove(GTK_CONTAINER(browser), parent);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
DCHECK(parent == devtools_window_);
|
||||
g_object_ref(view);
|
||||
gtk_container_remove(GTK_CONTAINER(devtools_window_), devtools);
|
||||
|
@ -229,9 +259,10 @@ void InspectableWebContentsViewLinux::ShowDevToolsInPane(bool on_bottom) {
|
|||
GtkWidget *InspectableWebContentsViewLinux::GetBrowserWindow() {
|
||||
GtkWidget *view = GetNativeView();
|
||||
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));
|
||||
return browser;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -10,8 +10,9 @@ namespace brightray {
|
|||
class InspectableWebContentsImpl;
|
||||
|
||||
class InspectableWebContentsViewLinux : public InspectableWebContentsView {
|
||||
public:
|
||||
InspectableWebContentsViewLinux(InspectableWebContentsImpl*);
|
||||
public:
|
||||
explicit InspectableWebContentsViewLinux(
|
||||
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||
~InspectableWebContentsViewLinux();
|
||||
|
||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||
|
@ -19,9 +20,11 @@ public:
|
|||
virtual void CloseDevTools() 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
|
||||
// somewhere else, remove them cleanly and take any GtkPaned out of the
|
||||
// window.
|
||||
|
@ -49,6 +52,6 @@ private:
|
|||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewLinux);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#import "base/mac/scoped_sending_event.h"
|
||||
|
||||
@interface BRYApplication : NSApplication <CrAppProtocol, CrAppControlProtocol> {
|
||||
@interface BRYApplication : NSApplication<CrAppProtocol, CrAppControlProtocol> {
|
||||
BOOL _handlingSendEvent;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ const content::MediaStreamDevice* FindDeviceWithId(
|
|||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -153,7 +153,6 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged(
|
|||
const content::MediaStreamDevice& device,
|
||||
content::MediaRequestState state) {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
||||
|
||||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::OnAudioStreamPlayingChanged(
|
||||
|
@ -175,10 +174,10 @@ void MediaCaptureDevicesDispatcher::UpdateAudioDevicesOnUIThread(
|
|||
}
|
||||
|
||||
void MediaCaptureDevicesDispatcher::UpdateVideoDevicesOnUIThread(
|
||||
const content::MediaStreamDevices& devices){
|
||||
const content::MediaStreamDevices& devices) {
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
devices_enumerated_ = true;
|
||||
video_devices_ = devices;
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace brightray
|
||||
|
|
|
@ -97,6 +97,6 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver {
|
|||
DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher);
|
||||
};
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace brightray
|
||||
|
||||
#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
|
||||
|
|
|
@ -159,4 +159,4 @@ void MediaStreamDevicesController::Deny() {
|
|||
cb.Run(content::MediaStreamDevices(), scoped_ptr<content::MediaStreamUI>());
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace brightray
|
||||
|
|
|
@ -39,6 +39,6 @@ class MediaStreamDevicesController {
|
|||
DISALLOW_COPY_AND_ASSIGN(MediaStreamDevicesController);
|
||||
};
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace brightray
|
||||
|
||||
#endif // BRIGHTRAY_BROWSER_MEDIA_MEDIA_STREAM_DEVICES_CONTROLLER_H_
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE-CHROMIUM file.
|
||||
|
||||
#include "network_delegate.h"
|
||||
#include "browser/network_delegate.h"
|
||||
|
||||
#include "net/base/net_errors.h"
|
||||
|
||||
|
@ -102,4 +102,4 @@ void NetworkDelegate::OnRequestWaitStateChange(
|
|||
RequestWaitState waiting) {
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -15,28 +15,53 @@ class NetworkDelegate : public net::NetworkDelegate {
|
|||
virtual ~NetworkDelegate();
|
||||
|
||||
protected:
|
||||
virtual int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* new_url) OVERRIDE;
|
||||
virtual int OnBeforeSendHeaders(net::URLRequest* request, 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 int OnBeforeURLRequest(net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
GURL* new_url) OVERRIDE;
|
||||
virtual int OnBeforeSendHeaders(net::URLRequest* request,
|
||||
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 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 OnURLRequestDestroyed(net::URLRequest* request) OVERRIDE;
|
||||
virtual void OnPACScriptError(int line_number, const string16& error) OVERRIDE;
|
||||
virtual AuthRequiredResponse OnAuthRequired(net::URLRequest* request, const net::AuthChallengeInfo& auth_info, const AuthCallback& callback, net::AuthCredentials* credentials) 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;
|
||||
virtual void OnPACScriptError(int line_number,
|
||||
const string16& error) OVERRIDE;
|
||||
virtual AuthRequiredResponse OnAuthRequired(
|
||||
net::URLRequest* request,
|
||||
const net::AuthChallengeInfo& auth_info,
|
||||
const AuthCallback& callback,
|
||||
net::AuthCredentials* credentials) 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:
|
||||
DISALLOW_COPY_AND_ASSIGN(NetworkDelegate);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace brightray {
|
|||
|
||||
class NotificationPresenter {
|
||||
public:
|
||||
virtual ~NotificationPresenter() {};
|
||||
virtual ~NotificationPresenter() {}
|
||||
|
||||
static NotificationPresenter* Create();
|
||||
|
||||
|
@ -23,6 +23,6 @@ class NotificationPresenter {
|
|||
int notification_id) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,10 +30,12 @@ class NotificationPresenterMac : public NotificationPresenter {
|
|||
int notification_id) OVERRIDE;
|
||||
|
||||
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_;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
#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/threading/worker_pool.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
@ -43,7 +46,8 @@ URLRequestContextGetter::URLRequestContextGetter(
|
|||
|
||||
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() {
|
||||
|
@ -53,8 +57,7 @@ net::HostResolver* URLRequestContextGetter::host_resolver() {
|
|||
return url_request_context_->host_resolver();
|
||||
}
|
||||
|
||||
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext()
|
||||
{
|
||||
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||
|
||||
if (!url_request_context_.get()) {
|
||||
|
@ -87,7 +90,8 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext()
|
|||
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
|
||||
storage_->set_http_auth_handler_factory(
|
||||
net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
|
||||
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());
|
||||
|
||||
base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
|
||||
|
@ -130,21 +134,25 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext()
|
|||
new net::URLRequestJobFactoryImpl());
|
||||
for (auto it = protocol_handlers_.begin(),
|
||||
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);
|
||||
}
|
||||
protocol_handlers_.clear();
|
||||
job_factory->SetProtocolHandler(chrome::kDataScheme, new net::DataProtocolHandler);
|
||||
job_factory->SetProtocolHandler(chrome::kFileScheme, new net::FileProtocolHandler);
|
||||
job_factory->SetProtocolHandler(
|
||||
chrome::kDataScheme, new net::DataProtocolHandler);
|
||||
job_factory->SetProtocolHandler(
|
||||
chrome::kFileScheme, new net::FileProtocolHandler);
|
||||
storage_->set_job_factory(job_factory.release());
|
||||
}
|
||||
|
||||
return url_request_context_.get();
|
||||
}
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner> URLRequestContextGetter::GetNetworkTaskRunner() const
|
||||
{
|
||||
return content::BrowserThread::GetMessageLoopProxyForThread(content::BrowserThread::IO);
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
URLRequestContextGetter::GetNetworkTaskRunner() const {
|
||||
return content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::IO);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace brightray {
|
|||
class NetworkDelegate;
|
||||
|
||||
class URLRequestContextGetter : public net::URLRequestContextGetter {
|
||||
public:
|
||||
public:
|
||||
URLRequestContextGetter(
|
||||
const base::FilePath& base_path,
|
||||
base::MessageLoop* io_loop,
|
||||
|
@ -37,8 +37,9 @@ public:
|
|||
net::HostResolver* host_resolver();
|
||||
virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE;
|
||||
|
||||
private:
|
||||
virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const OVERRIDE;
|
||||
private:
|
||||
virtual scoped_refptr<base::SingleThreadTaskRunner>
|
||||
GetNetworkTaskRunner() const OVERRIDE;
|
||||
|
||||
base::FilePath base_path_;
|
||||
base::MessageLoop* io_loop_;
|
||||
|
@ -53,6 +54,6 @@ private:
|
|||
DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,4 +56,4 @@ content::WebUIController* WebUIControllerFactory::CreateWebUIControllerForURL(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -15,11 +15,11 @@ class BrowserContext;
|
|||
|
||||
class WebUIControllerFactory : public content::WebUIControllerFactory {
|
||||
public:
|
||||
WebUIControllerFactory(BrowserContext* browser_context);
|
||||
explicit WebUIControllerFactory(BrowserContext* browser_context);
|
||||
virtual ~WebUIControllerFactory();
|
||||
|
||||
virtual content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context,
|
||||
const GURL& url) const OVERRIDE;
|
||||
virtual content::WebUI::TypeID GetWebUIType(
|
||||
content::BrowserContext* browser_context, const GURL& url) const OVERRIDE;
|
||||
virtual bool UseWebUIForURL(content::BrowserContext* browser_context,
|
||||
const GURL& url) const OVERRIDE;
|
||||
virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
|
||||
|
@ -37,6 +37,6 @@ class WebUIControllerFactory : public content::WebUIControllerFactory {
|
|||
DISALLOW_COPY_AND_ASSIGN(WebUIControllerFactory);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
|
||||
namespace brightray {
|
||||
|
||||
DevToolsWindow* DevToolsWindow::Create(InspectableWebContentsViewWin* controller) {
|
||||
DevToolsWindow* DevToolsWindow::Create(
|
||||
InspectableWebContentsViewWin* controller) {
|
||||
return new DevToolsWindow(controller);
|
||||
}
|
||||
|
||||
|
@ -20,13 +21,18 @@ DevToolsWindow::~DevToolsWindow() {
|
|||
}
|
||||
|
||||
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");
|
||||
return 0;
|
||||
}
|
||||
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
|
@ -35,7 +41,9 @@ LRESULT DevToolsWindow::OnSize(UINT, WPARAM, LPARAM, BOOL&) {
|
|||
RECT 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,
|
||||
rect.left, rect.top,
|
||||
rect.right - rect.left, rect.bottom - rect.top,
|
||||
|
@ -44,4 +52,4 @@ LRESULT DevToolsWindow::OnSize(UINT, WPARAM, LPARAM, BOOL&) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -8,9 +8,11 @@ namespace brightray {
|
|||
|
||||
class InspectableWebContentsViewWin;
|
||||
|
||||
class DevToolsWindow : public ui::WindowImpl, public base::SupportsWeakPtr<DevToolsWindow> {
|
||||
class DevToolsWindow : public ui::WindowImpl,
|
||||
public base::SupportsWeakPtr<DevToolsWindow> {
|
||||
public:
|
||||
static DevToolsWindow* Create(InspectableWebContentsViewWin*);
|
||||
static DevToolsWindow* Create(
|
||||
InspectableWebContentsViewWin* inspectable_web_contents_view_win);
|
||||
|
||||
BEGIN_MSG_MAP_EX(DevToolsWindow)
|
||||
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||
|
@ -19,7 +21,8 @@ class DevToolsWindow : public ui::WindowImpl, public base::SupportsWeakPtr<DevTo
|
|||
END_MSG_MAP()
|
||||
|
||||
private:
|
||||
DevToolsWindow(InspectableWebContentsViewWin*);
|
||||
explicit DevToolsWindow(
|
||||
InspectableWebContentsViewWin* inspectable_web_contents_view_win);
|
||||
~DevToolsWindow();
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
InspectableWebContentsViewWin::InspectableWebContentsViewWin(InspectableWebContentsImpl* inspectable_web_contents)
|
||||
InspectableWebContentsViewWin::InspectableWebContentsViewWin(
|
||||
InspectableWebContentsImpl* inspectable_web_contents)
|
||||
: inspectable_web_contents_(inspectable_web_contents) {
|
||||
}
|
||||
|
||||
|
@ -29,7 +31,8 @@ InspectableWebContentsViewWin::~InspectableWebContentsViewWin() {
|
|||
}
|
||||
|
||||
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() {
|
||||
|
@ -41,7 +44,9 @@ void InspectableWebContentsViewWin::ShowDevTools() {
|
|||
auto contents_view = inspectable_web_contents_->GetWebContents()->GetView();
|
||||
auto size = contents_view->GetContainerSize();
|
||||
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);
|
||||
}
|
||||
|
@ -56,4 +61,4 @@ bool InspectableWebContentsViewWin::SetDockSide(const std::string& side) {
|
|||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -12,8 +12,9 @@ class DevToolsWindow;
|
|||
class InspectableWebContentsImpl;
|
||||
|
||||
class InspectableWebContentsViewWin : public InspectableWebContentsView {
|
||||
public:
|
||||
InspectableWebContentsViewWin(InspectableWebContentsImpl*);
|
||||
public:
|
||||
explicit InspectableWebContentsViewWin(
|
||||
InspectableWebContentsImpl* inspectable_web_contents_impl);
|
||||
~InspectableWebContentsViewWin();
|
||||
|
||||
virtual gfx::NativeView GetNativeView() const OVERRIDE;
|
||||
|
@ -21,9 +22,11 @@ public:
|
|||
virtual void CloseDevTools() 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.
|
||||
InspectableWebContentsImpl* inspectable_web_contents_;
|
||||
|
||||
|
@ -32,6 +35,6 @@ private:
|
|||
DISALLOW_COPY_AND_ASSIGN(InspectableWebContentsViewWin);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,13 +7,17 @@
|
|||
namespace brightray {
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -22,19 +22,23 @@ ContentClient::~ContentClient() {
|
|||
std::string ContentClient::GetProduct() const {
|
||||
auto name = GetApplicationName();
|
||||
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 {
|
||||
return webkit_glue::BuildUserAgentFromProduct(GetProduct());
|
||||
}
|
||||
|
||||
base::StringPiece ContentClient::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const {
|
||||
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor);
|
||||
base::StringPiece ContentClient::GetDataResource(
|
||||
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 {
|
||||
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
|
||||
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
|
||||
resource_id);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -11,19 +11,20 @@
|
|||
namespace brightray {
|
||||
|
||||
class ContentClient : public content::ContentClient {
|
||||
public:
|
||||
public:
|
||||
ContentClient();
|
||||
~ContentClient();
|
||||
|
||||
private:
|
||||
private:
|
||||
virtual std::string GetProduct() 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;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ContentClient);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// base/mac/foundation_util.h contains an incompatible declaration of NSSearchPathDirectory,
|
||||
// so here we #define it to be something else.
|
||||
// base/mac/foundation_util.h contains an incompatible declaration of
|
||||
// NSSearchPathDirectory, so here we #define it to be something else.
|
||||
#define NSSearchPathDirectory NSSearchPathDirectory___PRE_10_8
|
||||
#import "base/mac/foundation_util.h"
|
||||
#undef NSSearchPathDirectory
|
||||
|
|
|
@ -9,12 +9,13 @@ class FilePath;
|
|||
|
||||
namespace brightray {
|
||||
|
||||
// The "main" application bundle is the outermost bundle for this logical application. E.g., if you
|
||||
// have MyApp.app and MyApp.app/Contents/Frameworks/MyApp Helper.app, the main application bundle is
|
||||
// MyApp.app, no matter which executable is currently running.
|
||||
// The "main" application bundle is the outermost bundle for this logical
|
||||
// application. E.g., if you have MyApp.app and
|
||||
// MyApp.app/Contents/Frameworks/MyApp Helper.app, the main application bundle
|
||||
// is MyApp.app, no matter which executable is currently running.
|
||||
NSBundle* MainApplicationBundle();
|
||||
base::FilePath MainApplicationBundlePath();
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
||||
#endif
|
||||
|
|
|
@ -53,8 +53,10 @@ void MainDelegate::InitializeResourceBundle() {
|
|||
|
||||
std::vector<base::FilePath> pak_paths;
|
||||
AddPakPaths(&pak_paths);
|
||||
for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it)
|
||||
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(*it, ui::SCALE_FACTOR_NONE);
|
||||
for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it) {
|
||||
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
|
||||
*it, ui::SCALE_FACTOR_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
#ifndef BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
||||
#define BRIGHTRAY_COMMON_MAIN_DELEGATE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "content/public/app/content_main_delegate.h"
|
||||
#include <vector>
|
||||
|
||||
namespace base {
|
||||
class FilePath;
|
||||
|
@ -19,21 +20,23 @@ namespace brightray {
|
|||
class ContentClient;
|
||||
|
||||
class MainDelegate : public content::ContentMainDelegate {
|
||||
public:
|
||||
public:
|
||||
MainDelegate();
|
||||
~MainDelegate();
|
||||
|
||||
protected:
|
||||
// Subclasses can override this to provide their own ContentClient implementation.
|
||||
protected:
|
||||
// Subclasses can override this to provide their own ContentClient
|
||||
// implementation.
|
||||
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 bool BasicStartupComplete(int* exit_code) OVERRIDE;
|
||||
virtual void PreSandboxStartup() OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
void InitializeResourceBundle();
|
||||
#if defined(OS_MACOSX)
|
||||
static base::FilePath GetResourcesPakFilePath();
|
||||
|
@ -47,5 +50,5 @@ private:
|
|||
DISALLOW_COPY_AND_ASSIGN(MainDelegate);
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace brightray
|
||||
#endif
|
||||
|
|
|
@ -18,7 +18,8 @@ def main():
|
|||
|
||||
url = 'https://{0}.s3.amazonaws.com/libchromiumcontent'.format(os.environ['JANKY_ARTIFACTS_S3_BUCKET'])
|
||||
return (run_script('bootstrap', url) or
|
||||
run_script('build'))
|
||||
run_script('build') or
|
||||
run_script('cpplint'))
|
||||
|
||||
|
||||
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…
Reference in a new issue