mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- Support DevTools without remote debugging via CefBrowserHost::ShowDevTools and CloseDevTools methods (issue #659).
- Fix loading of DevTools frontend from chrome-devtools scheme (issue #1095). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1510 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/devtools_delegate.h"
|
||||
#include "libcef/browser/devtools_frontend.h"
|
||||
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
||||
#include "libcef/browser/navigate_params.h"
|
||||
#include "libcef/browser/printing/print_view_manager.h"
|
||||
@@ -79,6 +80,29 @@ void CreateBrowserWithHelper(CreateBrowserHelper* helper) {
|
||||
delete helper;
|
||||
}
|
||||
|
||||
class ShowDevToolsHelper {
|
||||
public:
|
||||
ShowDevToolsHelper(CefRefPtr<CefBrowserHostImpl> browser,
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings)
|
||||
: browser_(browser),
|
||||
window_info_(windowInfo),
|
||||
client_(client),
|
||||
settings_(settings) {}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser_;
|
||||
CefWindowInfo window_info_;
|
||||
CefRefPtr<CefClient> client_;
|
||||
CefBrowserSettings settings_;
|
||||
};
|
||||
|
||||
void ShowDevToolsWithHelper(ShowDevToolsHelper* helper) {
|
||||
helper->browser_->ShowDevTools(helper->window_info_, helper->client_,
|
||||
helper->settings_);
|
||||
delete helper;
|
||||
}
|
||||
|
||||
// Convert a NativeWebKeyboardEvent to a CefKeyEvent.
|
||||
bool GetCefKeyEvent(const content::NativeWebKeyboardEvent& event,
|
||||
CefKeyEvent& cef_event) {
|
||||
@@ -286,6 +310,25 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::Create(windowInfo, client, url, settings, NULL, false,
|
||||
request_context);
|
||||
return browser.get();
|
||||
}
|
||||
|
||||
|
||||
// CefBrowserHostImpl static methods.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefString& url,
|
||||
const CefBrowserSettings& settings,
|
||||
CefWindowHandle opener,
|
||||
bool is_popup,
|
||||
CefRefPtr<CefRequestContext> request_context) {
|
||||
CefBrowserSettings new_settings = settings;
|
||||
|
||||
// Verify that render handler is in place for a windowless browser.
|
||||
@@ -305,14 +348,13 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
||||
CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo));
|
||||
|
||||
scoped_refptr<CefBrowserInfo> info =
|
||||
CefContentBrowserClient::Get()->CreateBrowserInfo();
|
||||
CefContentBrowserClient::Get()->CreateBrowserInfo(is_popup);
|
||||
|
||||
info->set_window_rendering_disabled(
|
||||
CefBrowserHostImpl::IsWindowRenderingDisabled(windowInfo));
|
||||
DCHECK(!info->is_popup());
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::Create(windowInfo, new_settings, client, NULL, info,
|
||||
NULL, request_context);
|
||||
CefBrowserHostImpl::CreateInternal(windowInfo, new_settings, client, NULL,
|
||||
info, opener, request_context);
|
||||
if (!url.empty()) {
|
||||
browser->LoadURL(CefFrameHostImpl::kMainFrameId, url, content::Referrer(),
|
||||
content::PAGE_TRANSITION_TYPED, std::string());
|
||||
@@ -320,15 +362,8 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
||||
return browser.get();
|
||||
}
|
||||
|
||||
|
||||
// CefBrowserHostImpl static methods.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
CefBrowserHostImpl::~CefBrowserHostImpl() {
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::Create(
|
||||
CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::CreateInternal(
|
||||
const CefWindowInfo& window_info,
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
@@ -445,9 +480,35 @@ CefRefPtr<CefBrowserHostImpl> CefBrowserHostImpl::GetBrowserByRoutingID(
|
||||
}
|
||||
|
||||
|
||||
// CefBrowserHost methods.
|
||||
// CefBrowserHostImpl methods.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// WebContentsObserver that will be notified when the frontend WebContents is
|
||||
// destroyed so that the inspected browser can clear its DevTools references.
|
||||
class CefBrowserHostImpl::DevToolsWebContentsObserver :
|
||||
public content::WebContentsObserver {
|
||||
public:
|
||||
DevToolsWebContentsObserver(CefBrowserHostImpl* browser,
|
||||
content::WebContents* frontend_web_contents)
|
||||
: WebContentsObserver(frontend_web_contents),
|
||||
browser_(browser) {
|
||||
}
|
||||
|
||||
// WebContentsObserver methods:
|
||||
virtual void WebContentsDestroyed(
|
||||
content::WebContents* web_contents) OVERRIDE {
|
||||
browser_->OnDevToolsWebContentsDestroyed();
|
||||
}
|
||||
|
||||
private:
|
||||
CefBrowserHostImpl* browser_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DevToolsWebContentsObserver);
|
||||
};
|
||||
|
||||
CefBrowserHostImpl::~CefBrowserHostImpl() {
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> CefBrowserHostImpl::GetBrowser() {
|
||||
return this;
|
||||
}
|
||||
@@ -650,6 +711,43 @@ void CefBrowserHostImpl::StopFinding(bool clearSelection) {
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::ShowDevTools(
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings) {
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
if (!web_contents_)
|
||||
return;
|
||||
|
||||
if (devtools_frontend_) {
|
||||
devtools_frontend_->Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
devtools_frontend_ = CefDevToolsFrontend::Show(
|
||||
this, windowInfo, client, settings);
|
||||
devtools_observer_.reset(new DevToolsWebContentsObserver(
|
||||
this, devtools_frontend_->frontend_browser()->web_contents()));
|
||||
} else {
|
||||
ShowDevToolsHelper* helper =
|
||||
new ShowDevToolsHelper(this, windowInfo, client, settings);
|
||||
CEF_POST_TASK(CEF_UIT, base::Bind(ShowDevToolsWithHelper, helper));
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::CloseDevTools() {
|
||||
if (CEF_CURRENTLY_ON_UIT()) {
|
||||
if (!devtools_frontend_)
|
||||
return;
|
||||
devtools_observer_.reset();
|
||||
devtools_frontend_->Close();
|
||||
devtools_frontend_ = NULL;
|
||||
} else {
|
||||
CEF_POST_TASK(CEF_UIT,
|
||||
base::Bind(&CefBrowserHostImpl::CloseDevTools, this));
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) {
|
||||
base::AutoLock lock_scope(state_lock_);
|
||||
mouse_cursor_change_disabled_ = disabled;
|
||||
@@ -1737,9 +1835,11 @@ void CefBrowserHostImpl::WebContentsCreated(
|
||||
DCHECK(!info->is_popup());
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> browser = CefBrowserHostImpl::Create(
|
||||
pending_popup_info->window_info, pending_popup_info->settings,
|
||||
pending_popup_info->client, new_contents, info, opener, NULL);
|
||||
CefRefPtr<CefBrowserHostImpl> browser =
|
||||
CefBrowserHostImpl::CreateInternal(pending_popup_info->window_info,
|
||||
pending_popup_info->settings,
|
||||
pending_popup_info->client,
|
||||
new_contents, info, opener, NULL);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::DidNavigateMainFramePostCommit(
|
||||
@@ -2136,6 +2236,7 @@ CefBrowserHostImpl::CefBrowserHostImpl(
|
||||
is_in_onsetfocus_(false),
|
||||
focus_on_editable_field_(false),
|
||||
mouse_cursor_change_disabled_(false),
|
||||
devtools_frontend_(NULL),
|
||||
file_chooser_pending_(false) {
|
||||
DCHECK(!browser_info_->browser().get());
|
||||
browser_info_->set_browser(this);
|
||||
@@ -2440,3 +2541,8 @@ void CefBrowserHostImpl::OnRunFileChooserDelegateCallback(
|
||||
// Notify our RenderViewHost in all cases.
|
||||
render_view_host->FilesSelectedInChooser(selected_files, mode);
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::OnDevToolsWebContentsDestroyed() {
|
||||
devtools_observer_.reset();
|
||||
devtools_frontend_ = NULL;
|
||||
}
|
||||
|
@@ -47,6 +47,7 @@ class URLRequest;
|
||||
struct Cef_Request_Params;
|
||||
struct Cef_Response_Params;
|
||||
class CefBrowserInfo;
|
||||
class CefDevToolsFrontend;
|
||||
struct CefNavigateParams;
|
||||
class SiteInstance;
|
||||
|
||||
@@ -81,12 +82,12 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
|
||||
// Create a new CefBrowserHostImpl instance.
|
||||
static CefRefPtr<CefBrowserHostImpl> Create(
|
||||
const CefWindowInfo& window_info,
|
||||
const CefBrowserSettings& settings,
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
content::WebContents* web_contents,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
const CefString& url,
|
||||
const CefBrowserSettings& settings,
|
||||
CefWindowHandle opener,
|
||||
bool is_popup,
|
||||
CefRefPtr<CefRequestContext> request_context);
|
||||
|
||||
// Returns the browser associated with the specified RenderViewHost.
|
||||
@@ -128,6 +129,10 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
virtual void Find(int identifier, const CefString& searchText,
|
||||
bool forward, bool matchCase, bool findNext) OVERRIDE;
|
||||
virtual void StopFinding(bool clearSelection) OVERRIDE;
|
||||
virtual void ShowDevTools(const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings) OVERRIDE;
|
||||
virtual void CloseDevTools() OVERRIDE;
|
||||
virtual void SetMouseCursorChangeDisabled(bool disabled) OVERRIDE;
|
||||
virtual bool IsMouseCursorChangeDisabled() OVERRIDE;
|
||||
virtual bool IsWindowRenderingDisabled() OVERRIDE;
|
||||
@@ -274,6 +279,17 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
DestructionState destruction_state() const { return destruction_state_; }
|
||||
|
||||
private:
|
||||
class DevToolsWebContentsObserver;
|
||||
|
||||
static CefRefPtr<CefBrowserHostImpl> CreateInternal(
|
||||
const CefWindowInfo& window_info,
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefClient> client,
|
||||
content::WebContents* web_contents,
|
||||
scoped_refptr<CefBrowserInfo> browser_info,
|
||||
CefWindowHandle opener,
|
||||
CefRefPtr<CefRequestContext> request_context);
|
||||
|
||||
// content::WebContentsDelegate methods.
|
||||
virtual content::WebContents* OpenURLFromTab(
|
||||
content::WebContents* source,
|
||||
@@ -481,6 +497,8 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
content::FileChooserParams::Mode mode,
|
||||
const std::vector<base::FilePath>& file_paths);
|
||||
|
||||
void OnDevToolsWebContentsDestroyed();
|
||||
|
||||
CefWindowInfo window_info_;
|
||||
CefBrowserSettings settings_;
|
||||
CefRefPtr<CefClient> client_;
|
||||
@@ -551,6 +569,13 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
// Used for creating and managing context menus.
|
||||
scoped_ptr<CefMenuCreator> menu_creator_;
|
||||
|
||||
// Track the lifespan of the frontend WebContents associated with this
|
||||
// browser.
|
||||
scoped_ptr<DevToolsWebContentsObserver> devtools_observer_;
|
||||
// CefDevToolsFrontend will delete itself when the frontend WebContents is
|
||||
// destroyed.
|
||||
CefDevToolsFrontend* devtools_frontend_;
|
||||
|
||||
// True if a file chooser is currently pending.
|
||||
bool file_chooser_pending_;
|
||||
|
||||
|
@@ -301,11 +301,12 @@ CefContentBrowserClient* CefContentBrowserClient::Get() {
|
||||
CefContentClient::Get()->browser());
|
||||
}
|
||||
|
||||
scoped_refptr<CefBrowserInfo> CefContentBrowserClient::CreateBrowserInfo() {
|
||||
scoped_refptr<CefBrowserInfo> CefContentBrowserClient::CreateBrowserInfo(
|
||||
bool is_popup) {
|
||||
base::AutoLock lock_scope(browser_info_lock_);
|
||||
|
||||
scoped_refptr<CefBrowserInfo> browser_info =
|
||||
new CefBrowserInfo(++next_browser_id_, false);
|
||||
new CefBrowserInfo(++next_browser_id_, is_popup);
|
||||
browser_info_list_.push_back(browser_info);
|
||||
return browser_info;
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
// to CefBrowserHostImpl::ShouldCreateWebContents on the UI thread. To resolve
|
||||
// this race CefBrowserInfo may be created when requested for the first time
|
||||
// and before the associated CefBrowserHostImpl is created.
|
||||
scoped_refptr<CefBrowserInfo> CreateBrowserInfo();
|
||||
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(bool is_popup);
|
||||
scoped_refptr<CefBrowserInfo> GetOrCreateBrowserInfo(int render_process_id,
|
||||
int render_view_id);
|
||||
void RemoveBrowserInfo(scoped_refptr<CefBrowserInfo> browser_info);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
// Copyright 2013 the Chromium Embedded Framework Authors. Portions Copyright
|
||||
// 2012 The Chromium Authors. All rights reserved. Use of this source code is
|
||||
// governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/devtools_delegate.h"
|
||||
#include "libcef/browser/devtools_scheme_handler.h"
|
||||
@@ -186,6 +186,11 @@ scoped_ptr<net::StreamListenSocket>
|
||||
return scoped_ptr<net::StreamListenSocket>();
|
||||
}
|
||||
|
||||
std::string CefDevToolsDelegate::GetChromeDevToolsURL() {
|
||||
return base::StringPrintf("%s://%s/devtools.html",
|
||||
chrome::kChromeDevToolsScheme, scheme::kChromeDevToolsHost);
|
||||
}
|
||||
|
||||
std::string CefDevToolsDelegate::GetDevToolsURL(content::RenderViewHost* rvh,
|
||||
bool http_scheme) {
|
||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||
@@ -202,7 +207,7 @@ std::string CefDevToolsDelegate::GetDevToolsURL(content::RenderViewHost* rvh,
|
||||
const std::string& page_id = agent_host->GetId();
|
||||
const std::string& host = http_scheme ?
|
||||
base::StringPrintf("http://localhost:%d/devtools/", port) :
|
||||
base::StringPrintf("%s://%s/devtools/", chrome::kChromeDevToolsScheme,
|
||||
base::StringPrintf("%s://%s/", chrome::kChromeDevToolsScheme,
|
||||
scheme::kChromeDevToolsHost);
|
||||
|
||||
return base::StringPrintf(
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
// Copyright 2013 the Chromium Embedded Framework Authors. Portions Copyright
|
||||
// 2012 The Chromium Authors. All rights reserved. Use of this source code is
|
||||
// governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_DELEGATE_H_
|
||||
#define CEF_LIBCEF_BROWSER_DEVTOOLS_DELEGATE_H_
|
||||
@@ -42,6 +42,9 @@ class CefDevToolsDelegate : public content::DevToolsHttpHandlerDelegate {
|
||||
net::StreamListenSocket::Delegate* delegate,
|
||||
std::string* name) OVERRIDE;
|
||||
|
||||
// Returns the chrome-devtools URL.
|
||||
std::string GetChromeDevToolsURL();
|
||||
|
||||
// Returns the DevTools URL for the specified RenderViewHost.
|
||||
std::string GetDevToolsURL(content::RenderViewHost* rvh, bool http_scheme);
|
||||
|
||||
|
93
libcef/browser/devtools_frontend.cc
Normal file
93
libcef/browser/devtools_frontend.cc
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright 2013 the Chromium Embedded Framework Authors. Portions Copyright
|
||||
// 2012 The Chromium Authors. All rights reserved. Use of this source code is
|
||||
// governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/devtools_frontend.h"
|
||||
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
#include "libcef/browser/devtools_delegate.h"
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/path_service.h"
|
||||
#include "content/public/browser/devtools_http_handler.h"
|
||||
#include "content/public/browser/devtools_manager.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_view.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
#include "net/base/net_util.h"
|
||||
|
||||
// static
|
||||
CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
||||
CefRefPtr<CefBrowserHostImpl> inspected_browser,
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings) {
|
||||
CefRefPtr<CefBrowserHostImpl> frontend_browser =
|
||||
CefBrowserHostImpl::Create(windowInfo, client, CefString(),
|
||||
settings,
|
||||
inspected_browser->GetWindowHandle(), true,
|
||||
inspected_browser->GetRequestContext());
|
||||
|
||||
// CefDevToolsFrontend will delete itself when the frontend WebContents is
|
||||
// destroyed.
|
||||
CefDevToolsFrontend* devtools_frontend = new CefDevToolsFrontend(
|
||||
static_cast<CefBrowserHostImpl*>(frontend_browser.get()),
|
||||
content::DevToolsAgentHost::GetOrCreateFor(
|
||||
inspected_browser->GetWebContents()->GetRenderViewHost()).get());
|
||||
|
||||
// Need to load the URL after creating the DevTools objects.
|
||||
CefDevToolsDelegate* delegate =
|
||||
CefContentBrowserClient::Get()->devtools_delegate();
|
||||
frontend_browser->GetMainFrame()->LoadURL(delegate->GetChromeDevToolsURL());
|
||||
|
||||
devtools_frontend->Activate();
|
||||
devtools_frontend->Focus();
|
||||
|
||||
return devtools_frontend;
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::Activate() {
|
||||
frontend_browser_->ActivateContents(web_contents());
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::Focus() {
|
||||
web_contents()->GetView()->Focus();
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::Close() {
|
||||
frontend_browser_->CloseBrowser(true);
|
||||
}
|
||||
|
||||
CefDevToolsFrontend::CefDevToolsFrontend(
|
||||
CefRefPtr<CefBrowserHostImpl> frontend_browser,
|
||||
content::DevToolsAgentHost* agent_host)
|
||||
: WebContentsObserver(frontend_browser->GetWebContents()),
|
||||
frontend_browser_(frontend_browser),
|
||||
agent_host_(agent_host) {
|
||||
frontend_host_.reset(
|
||||
content::DevToolsClientHost::CreateDevToolsFrontendHost(
|
||||
web_contents(), this));
|
||||
}
|
||||
|
||||
CefDevToolsFrontend::~CefDevToolsFrontend() {
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::RenderViewCreated(
|
||||
content::RenderViewHost* render_view_host) {
|
||||
content::DevToolsClientHost::SetupDevToolsFrontendClient(
|
||||
web_contents()->GetRenderViewHost());
|
||||
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(
|
||||
agent_host_.get(), frontend_host_.get());
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::WebContentsDestroyed(
|
||||
content::WebContents* web_contents) {
|
||||
content::DevToolsManager::GetInstance()->ClientHostClosing(
|
||||
frontend_host_.get());
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CefDevToolsFrontend::InspectedContentsClosing() {
|
||||
Close();
|
||||
}
|
64
libcef/browser/devtools_frontend.h
Normal file
64
libcef/browser/devtools_frontend.h
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright 2013 the Chromium Embedded Framework Authors. Portions Copyright
|
||||
// 2012 The Chromium Authors. All rights reserved. Use of this source code is
|
||||
// governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_DEVTOOLS_FRONTEND_H_
|
||||
#define CEF_LIBCEF_BROWSER_DEVTOOLS_FRONTEND_H_
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "content/public/browser/devtools_agent_host.h"
|
||||
#include "content/public/browser/devtools_client_host.h"
|
||||
#include "content/public/browser/devtools_frontend_host_delegate.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
|
||||
namespace content {
|
||||
class RenderViewHost;
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
class CefDevToolsFrontend : public content::WebContentsObserver,
|
||||
public content::DevToolsFrontendHostDelegate {
|
||||
public:
|
||||
static CefDevToolsFrontend* Show(
|
||||
CefRefPtr<CefBrowserHostImpl> inspected_browser,
|
||||
const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client,
|
||||
const CefBrowserSettings& settings);
|
||||
|
||||
void Activate();
|
||||
void Focus();
|
||||
void Close();
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> frontend_browser() const {
|
||||
return frontend_browser_;
|
||||
}
|
||||
|
||||
private:
|
||||
CefDevToolsFrontend(CefRefPtr<CefBrowserHostImpl> frontend_browser,
|
||||
content::DevToolsAgentHost* agent_host);
|
||||
virtual ~CefDevToolsFrontend();
|
||||
|
||||
// WebContentsObserver overrides
|
||||
virtual void RenderViewCreated(
|
||||
content::RenderViewHost* render_view_host) OVERRIDE;
|
||||
virtual void WebContentsDestroyed(
|
||||
content::WebContents* web_contents) OVERRIDE;
|
||||
|
||||
// DevToolsFrontendHostDelegate implementation
|
||||
virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE {}
|
||||
|
||||
virtual void InspectedContentsClosing() OVERRIDE;
|
||||
|
||||
CefRefPtr<CefBrowserHostImpl> frontend_browser_;
|
||||
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
||||
scoped_ptr<content::DevToolsClientHost> frontend_host_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefDevToolsFrontend);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_DEVTOOLS_FRONTEND_H_
|
@@ -12,7 +12,7 @@ namespace scheme {
|
||||
void AddInternalSchemes(std::vector<std::string>* standard_schemes) {
|
||||
static CefContentClient::SchemeInfo schemes[] = {
|
||||
{ chrome::kChromeUIScheme, true, true, true },
|
||||
{ chrome::kChromeDevToolsScheme, true, true, false }
|
||||
{ chrome::kChromeDevToolsScheme, true, false, true }
|
||||
};
|
||||
|
||||
CefContentClient* client = CefContentClient::Get();
|
||||
|
Reference in New Issue
Block a user