DevToolsClientHost is discarded
This commit is contained in:
parent
f764a449af
commit
8ec5b5ad20
4 changed files with 33 additions and 45 deletions
|
@ -166,7 +166,7 @@ content::BrowserPluginGuestManager* BrowserContext::GetGuestManager() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
quota::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() {
|
storage::SpecialStoragePolicy* BrowserContext::GetSpecialStoragePolicy() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,22 +48,21 @@ class BrowserContext : public content::BrowserContext,
|
||||||
|
|
||||||
void RegisterInternalPrefs(PrefRegistrySimple* pref_registry);
|
void RegisterInternalPrefs(PrefRegistrySimple* pref_registry);
|
||||||
|
|
||||||
virtual bool IsOffTheRecord() const override;
|
bool IsOffTheRecord() const override;
|
||||||
virtual net::URLRequestContextGetter* GetRequestContext() override;
|
net::URLRequestContextGetter* GetRequestContext() override;
|
||||||
virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
|
net::URLRequestContextGetter* GetRequestContextForRenderProcess(
|
||||||
int renderer_child_id);
|
int renderer_child_id);
|
||||||
virtual net::URLRequestContextGetter* GetMediaRequestContext() override;
|
net::URLRequestContextGetter* GetMediaRequestContext() override;
|
||||||
virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
|
net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
|
||||||
int renderer_child_id) override;
|
int renderer_child_id) override;
|
||||||
virtual net::URLRequestContextGetter*
|
net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition(
|
||||||
GetMediaRequestContextForStoragePartition(
|
const base::FilePath& partition_path, bool in_memory) override;
|
||||||
const base::FilePath& partition_path, bool in_memory);
|
content::ResourceContext* GetResourceContext() override;
|
||||||
virtual content::ResourceContext* GetResourceContext() override;
|
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
|
||||||
virtual content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
|
content::BrowserPluginGuestManager* GetGuestManager() override;
|
||||||
virtual content::BrowserPluginGuestManager* GetGuestManager() override;
|
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
|
||||||
virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
|
content::PushMessagingService* GetPushMessagingService() override;
|
||||||
virtual content::PushMessagingService* GetPushMessagingService() override;
|
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
|
||||||
virtual content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
|
|
||||||
|
|
||||||
base::FilePath path_;
|
base::FilePath path_;
|
||||||
scoped_ptr<ResourceContext> resource_context_;
|
scoped_ptr<ResourceContext> resource_context_;
|
||||||
|
|
|
@ -17,10 +17,7 @@
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
#include "content/public/browser/devtools_agent_host.h"
|
|
||||||
#include "content/public/browser/devtools_client_host.h"
|
|
||||||
#include "content/public/browser/devtools_http_handler.h"
|
#include "content/public/browser/devtools_http_handler.h"
|
||||||
#include "content/public/browser/devtools_manager.h"
|
|
||||||
#include "content/public/browser/host_zoom_map.h"
|
#include "content/public/browser/host_zoom_map.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/browser/render_view_host.h"
|
#include "content/public/browser/render_view_host.h"
|
||||||
|
@ -33,8 +30,6 @@ const double kPresetZoomFactors[] = { 0.25, 0.333, 0.5, 0.666, 0.75, 0.9, 1.0,
|
||||||
1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0,
|
1.1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0,
|
||||||
5.0 };
|
5.0 };
|
||||||
|
|
||||||
const char kDevToolsScheme[] = "chrome-devtools";
|
|
||||||
const char kDevToolsHost[] = "devtools";
|
|
||||||
const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html?"
|
const char kChromeUIDevToolsURL[] = "chrome-devtools://devtools/devtools.html?"
|
||||||
"can_dock=%s&"
|
"can_dock=%s&"
|
||||||
"toolbarColor=rgba(223,223,223,1)&"
|
"toolbarColor=rgba(223,223,223,1)&"
|
||||||
|
@ -91,15 +86,11 @@ bool ParseMessage(const std::string& message,
|
||||||
}
|
}
|
||||||
|
|
||||||
double GetZoomLevelForWebContents(content::WebContents* web_contents) {
|
double GetZoomLevelForWebContents(content::WebContents* web_contents) {
|
||||||
content::HostZoomMap* host_zoom_map = content::HostZoomMap::GetForBrowserContext(
|
return content::HostZoomMap::GetZoomLevel(web_contents);
|
||||||
web_contents->GetBrowserContext());
|
|
||||||
return host_zoom_map->GetZoomLevelForHostAndScheme(kDevToolsScheme, kDevToolsHost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetZoomLevelForWebContents(content::WebContents* web_contents, double level) {
|
void SetZoomLevelForWebContents(content::WebContents* web_contents, double level) {
|
||||||
content::HostZoomMap* host_zoom_map = content::HostZoomMap::GetForBrowserContext(
|
content::HostZoomMap::SetZoomLevel(web_contents, level);
|
||||||
web_contents->GetBrowserContext());
|
|
||||||
return host_zoom_map->SetZoomLevelForHostAndScheme(kDevToolsScheme, kDevToolsHost, level);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double GetNextZoomLevel(double level, bool out) {
|
double GetNextZoomLevel(double level, bool out) {
|
||||||
|
@ -172,13 +163,13 @@ void InspectableWebContentsImpl::ShowDevTools() {
|
||||||
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get());
|
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get());
|
||||||
frontend_host_.reset(content::DevToolsFrontendHost::Create(
|
frontend_host_.reset(content::DevToolsFrontendHost::Create(
|
||||||
web_contents_->GetRenderViewHost(), this));
|
web_contents_->GetRenderViewHost(), this));
|
||||||
content::DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor(agent_host_, this);
|
agent_host_->AttachClient(this);
|
||||||
|
|
||||||
GURL devtools_url(base::StringPrintf(kChromeUIDevToolsURL, can_dock_ ? "true" : ""));
|
GURL devtools_url(base::StringPrintf(kChromeUIDevToolsURL, can_dock_ ? "true" : ""));
|
||||||
devtools_web_contents_->GetController().LoadURL(
|
devtools_web_contents_->GetController().LoadURL(
|
||||||
devtools_url,
|
devtools_url,
|
||||||
content::Referrer(),
|
content::Referrer(),
|
||||||
content::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
|
||||||
std::string());
|
std::string());
|
||||||
} else {
|
} else {
|
||||||
view_->ShowDevTools();
|
view_->ShowDevTools();
|
||||||
|
@ -312,21 +303,18 @@ void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontend(const std::st
|
||||||
|
|
||||||
void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontendToBackend(
|
void InspectableWebContentsImpl::HandleMessageFromDevToolsFrontendToBackend(
|
||||||
const std::string& message) {
|
const std::string& message) {
|
||||||
content::DevToolsManager::GetInstance()->DispatchOnInspectorBackend(
|
agent_host_->DispatchProtocolMessage(message);
|
||||||
this, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::DispatchOnInspectorFrontend(
|
void InspectableWebContentsImpl::DispatchProtocolMessage(
|
||||||
const std::string& message) {
|
content::DevToolsAgentHost* agent_host, const std::string& message) {
|
||||||
std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");";
|
std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");";
|
||||||
base::string16 javascript = base::UTF8ToUTF16(code);
|
base::string16 javascript = base::UTF8ToUTF16(code);
|
||||||
devtools_web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
|
web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::InspectedContentsClosing() {
|
void InspectableWebContentsImpl::AgentHostClosed(
|
||||||
}
|
content::DevToolsAgentHost* agent_host, bool replaced) {
|
||||||
|
|
||||||
void InspectableWebContentsImpl::ReplacedWithAnotherClient() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::AboutToNavigateRenderView(
|
void InspectableWebContentsImpl::AboutToNavigateRenderView(
|
||||||
|
@ -348,7 +336,7 @@ void InspectableWebContentsImpl::DidFinishLoad(content::RenderFrameHost* render_
|
||||||
}
|
}
|
||||||
|
|
||||||
void InspectableWebContentsImpl::WebContentsDestroyed() {
|
void InspectableWebContentsImpl::WebContentsDestroyed() {
|
||||||
content::DevToolsManager::GetInstance()->ClientHostClosing(this);
|
agent_host_->DetachClient();
|
||||||
Observe(nullptr);
|
Observe(nullptr);
|
||||||
agent_host_ = nullptr;
|
agent_host_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "browser/devtools_contents_resizing_strategy.h"
|
#include "browser/devtools_contents_resizing_strategy.h"
|
||||||
#include "browser/devtools_embedder_message_dispatcher.h"
|
#include "browser/devtools_embedder_message_dispatcher.h"
|
||||||
|
|
||||||
#include "content/public/browser/devtools_client_host.h"
|
#include "content/public/browser/devtools_agent_host.h"
|
||||||
#include "content/public/browser/devtools_frontend_host.h"
|
#include "content/public/browser/devtools_frontend_host.h"
|
||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
|
@ -31,7 +31,7 @@ class InspectableWebContentsView;
|
||||||
class InspectableWebContentsImpl :
|
class InspectableWebContentsImpl :
|
||||||
public InspectableWebContents,
|
public InspectableWebContents,
|
||||||
public content::DevToolsFrontendHost::Delegate,
|
public content::DevToolsFrontendHost::Delegate,
|
||||||
public content::DevToolsClientHost,
|
public content::DevToolsAgentHostClient,
|
||||||
public content::WebContentsObserver,
|
public content::WebContentsObserver,
|
||||||
public content::WebContentsDelegate,
|
public content::WebContentsDelegate,
|
||||||
public DevToolsEmbedderMessageDispatcher::Delegate {
|
public DevToolsEmbedderMessageDispatcher::Delegate {
|
||||||
|
@ -93,15 +93,16 @@ class InspectableWebContentsImpl :
|
||||||
void ZoomOut() override;
|
void ZoomOut() override;
|
||||||
void ResetZoom() override;
|
void ResetZoom() override;
|
||||||
|
|
||||||
// content::DevToolsClientHost:
|
|
||||||
void DispatchOnInspectorFrontend(const std::string& message) override;
|
|
||||||
void InspectedContentsClosing() override;
|
|
||||||
void ReplacedWithAnotherClient() override;
|
|
||||||
|
|
||||||
// content::DevToolsFrontendHostDelegate:
|
// content::DevToolsFrontendHostDelegate:
|
||||||
void HandleMessageFromDevToolsFrontend(const std::string& message) override;
|
void HandleMessageFromDevToolsFrontend(const std::string& message) override;
|
||||||
void HandleMessageFromDevToolsFrontendToBackend(const std::string& message) override;
|
void HandleMessageFromDevToolsFrontendToBackend(const std::string& message) override;
|
||||||
|
|
||||||
|
// content::DevToolsAgentHostClient:
|
||||||
|
void DispatchProtocolMessage(content::DevToolsAgentHost* agent_host,
|
||||||
|
const std::string& message) override;
|
||||||
|
void AgentHostClosed(content::DevToolsAgentHost* agent_host,
|
||||||
|
bool replaced) override;
|
||||||
|
|
||||||
// content::WebContentsObserver:
|
// content::WebContentsObserver:
|
||||||
void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) override;
|
void AboutToNavigateRenderView(content::RenderViewHost* render_view_host) override;
|
||||||
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
void DidFinishLoad(content::RenderFrameHost* render_frame_host,
|
||||||
|
|
Loading…
Reference in a new issue