summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/devtools/devtools_window.cc67
-rw-r--r--chrome/browser/devtools/devtools_window.h5
-rw-r--r--content/renderer/devtools/devtools_agent.cc8
-rw-r--r--content/renderer/devtools/devtools_agent.h1
-rw-r--r--content/renderer/devtools/devtools_client.cc3
-rw-r--r--webkit/appcache/appcache_interfaces.cc20
-rw-r--r--webkit/appcache/appcache_interfaces.h2
7 files changed, 74 insertions, 32 deletions
diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc
index 0d9552c..e152129 100644
--- a/chrome/browser/devtools/devtools_window.cc
+++ b/chrome/browser/devtools/devtools_window.cc
@@ -98,15 +98,29 @@ const int kMinContentsSize = 50;
const int kMinimizedDevToolsHeight = 24;
class DevToolsWindow::InspectedWebContentsObserver
- : public content::WebContentsObserver {
+ : public content::WebContentsObserver {
public:
explicit InspectedWebContentsObserver(content::WebContents* web_contents)
: WebContentsObserver(web_contents) {
- }
+ }
content::WebContents* Get() { return web_contents(); }
};
+class DevToolsWindow::FrontendWebContentsObserver
+ : public content::WebContentsObserver {
+ public:
+ explicit FrontendWebContentsObserver(content::WebContents* web_contents)
+ : WebContentsObserver(web_contents) {
+ }
+ private:
+ // Overriden from contents::WebContentsObserver.
+ virtual void AboutToNavigateRenderView(
+ RenderViewHost* render_view_host) OVERRIDE {
+ content::DevToolsClientHost::SetupDevToolsFrontendClient(render_view_host);
+ }
+};
+
// static
std::string DevToolsWindow::GetDevToolsWindowPlacementPrefKey() {
std::string wp_key;
@@ -230,34 +244,16 @@ DevToolsWindow* DevToolsWindow::Create(
DevToolsDockSide dock_side,
bool shared_worker_frontend) {
// Create WebContents with devtools.
- WebContents* web_contents =
- WebContents::Create(WebContents::CreateParams(profile));
GURL url = GetDevToolsURL(profile, frontend_url, dock_side,
shared_worker_frontend);
- web_contents->GetController().LoadURL(url, content::Referrer(),
- content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
-
- RenderViewHost* render_view_host = web_contents->GetRenderViewHost();
- content::DevToolsClientHost::SetupDevToolsFrontendClient(render_view_host);
-
- if (url.host() == chrome::kChromeUIDevToolsBundledHost) {
- // Only allow file scheme in embedded front-end by default.
- int process_id = render_view_host->GetProcess()->GetID();
- content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
- process_id, chrome::kFileScheme);
- }
-
- return new DevToolsWindow(web_contents, profile, frontend_url, inspected_rvh,
- dock_side);
+ return new DevToolsWindow(profile, url, inspected_rvh, dock_side);
}
-DevToolsWindow::DevToolsWindow(WebContents* web_contents,
- Profile* profile,
- const GURL& frontend_url,
+DevToolsWindow::DevToolsWindow(Profile* profile,
+ const GURL& url,
RenderViewHost* inspected_rvh,
DevToolsDockSide dock_side)
: profile_(profile),
- web_contents_(web_contents),
browser_(NULL),
dock_side_(dock_side),
is_loaded_(false),
@@ -266,13 +262,28 @@ DevToolsWindow::DevToolsWindow(WebContents* web_contents,
width_(-1),
height_(-1),
dock_side_before_minimized_(dock_side) {
+ web_contents_ = WebContents::Create(WebContents::CreateParams(profile));
+ frontend_contents_observer_.reset(
+ new FrontendWebContentsObserver(web_contents_));
+
+ web_contents_->GetController().LoadURL(url, content::Referrer(),
+ content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
+
+ RenderViewHost* render_view_host = web_contents_->GetRenderViewHost();
+ if (url.host() == chrome::kChromeUIDevToolsBundledHost) {
+ // Only allow file scheme in embedded front-end by default.
+ int process_id = render_view_host->GetProcess()->GetID();
+ content::ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
+ process_id, chrome::kFileScheme);
+ }
+
frontend_host_.reset(
- DevToolsClientHost::CreateDevToolsFrontendHost(web_contents, this));
- file_helper_.reset(new DevToolsFileHelper(web_contents, profile));
+ DevToolsClientHost::CreateDevToolsFrontendHost(web_contents_, this));
+ file_helper_.reset(new DevToolsFileHelper(web_contents_, profile));
g_instances.Get().push_back(this);
// Wipe out page icon so that the default application icon is used.
- NavigationEntry* entry = web_contents->GetController().GetActiveEntry();
+ NavigationEntry* entry = web_contents_->GetController().GetActiveEntry();
entry->GetFavicon().image = gfx::Image();
entry->GetFavicon().valid = true;
@@ -280,11 +291,11 @@ DevToolsWindow::DevToolsWindow(WebContents* web_contents,
registrar_.Add(
this,
content::NOTIFICATION_LOAD_STOP,
- content::Source<NavigationController>(&web_contents->GetController()));
+ content::Source<NavigationController>(&web_contents_->GetController()));
registrar_.Add(
this,
chrome::NOTIFICATION_TAB_CLOSING,
- content::Source<NavigationController>(&web_contents->GetController()));
+ content::Source<NavigationController>(&web_contents_->GetController()));
registrar_.Add(
this,
chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
diff --git a/chrome/browser/devtools/devtools_window.h b/chrome/browser/devtools/devtools_window.h
index 93aae72..29e93d9 100644
--- a/chrome/browser/devtools/devtools_window.h
+++ b/chrome/browser/devtools/devtools_window.h
@@ -128,8 +128,7 @@ class DevToolsWindow : private content::NotificationObserver,
content::RenderViewHost* inspected_rvh,
DevToolsDockSide dock_side,
bool shared_worker_frontend);
- DevToolsWindow(content::WebContents* web_contents,
- Profile* profile,
+ DevToolsWindow(Profile* profile,
const GURL& frontend_url,
content::RenderViewHost* inspected_rvh,
DevToolsDockSide dock_side);
@@ -220,6 +219,8 @@ class DevToolsWindow : private content::NotificationObserver,
class InspectedWebContentsObserver;
scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_;
+ class FrontendWebContentsObserver;
+ scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_;
Profile* profile_;
content::WebContents* web_contents_;
diff --git a/content/renderer/devtools/devtools_agent.cc b/content/renderer/devtools/devtools_agent.cc
index 868f5ec..e959641 100644
--- a/content/renderer/devtools/devtools_agent.cc
+++ b/content/renderer/devtools/devtools_agent.cc
@@ -69,7 +69,9 @@ base::LazyInstance<IdToAgentMap>::Leaky
} // namespace
DevToolsAgent::DevToolsAgent(RenderViewImpl* render_view)
- : RenderViewObserver(render_view), is_attached_(false) {
+ : RenderViewObserver(render_view),
+ is_attached_(false),
+ is_devtools_client_(false) {
g_agent_for_routing_id.Get()[routing_id()] = this;
render_view->webview()->setDevToolsAgentClient(this);
@@ -237,6 +239,10 @@ void DevToolsAgent::ContinueProgram() {
}
void DevToolsAgent::OnSetupDevToolsClient() {
+ // We only want to register once per render view.
+ if (is_devtools_client_)
+ return;
+ is_devtools_client_ = true;
new DevToolsClient(static_cast<RenderViewImpl*>(render_view()));
}
diff --git a/content/renderer/devtools/devtools_agent.h b/content/renderer/devtools/devtools_agent.h
index e3a3bdd..7926f44 100644
--- a/content/renderer/devtools/devtools_agent.h
+++ b/content/renderer/devtools/devtools_agent.h
@@ -65,6 +65,7 @@ class DevToolsAgent : public RenderViewObserver,
void OnSetupDevToolsClient();
bool is_attached_;
+ bool is_devtools_client_;
DISALLOW_COPY_AND_ASSIGN(DevToolsAgent);
};
diff --git a/content/renderer/devtools/devtools_client.cc b/content/renderer/devtools/devtools_client.cc
index 7ec522c..5f760e6 100644
--- a/content/renderer/devtools/devtools_client.cc
+++ b/content/renderer/devtools/devtools_client.cc
@@ -9,12 +9,14 @@
#include "base/utf_string_conversions.h"
#include "content/common/devtools_messages.h"
#include "content/public/common/content_switches.h"
+#include "content/public/common/url_constants.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/render_view_impl.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsFrontend.h"
#include "ui/base/ui_base_switches.h"
+#include "webkit/appcache/appcache_interfaces.h"
using WebKit::WebDevToolsFrontend;
using WebKit::WebString;
@@ -35,6 +37,7 @@ DevToolsClient::DevToolsClient(RenderViewImpl* render_view)
render_view->webview(),
this,
ASCIIToUTF16(command_line.GetSwitchValueASCII(switches::kLang))));
+ appcache::AddSupportedScheme(chrome::kChromeDevToolsScheme);
}
DevToolsClient::~DevToolsClient() {
diff --git a/webkit/appcache/appcache_interfaces.cc b/webkit/appcache/appcache_interfaces.cc
index a3b6f31..d7941be 100644
--- a/webkit/appcache/appcache_interfaces.cc
+++ b/webkit/appcache/appcache_interfaces.cc
@@ -4,6 +4,9 @@
#include "webkit/appcache/appcache_interfaces.h"
+#include <set>
+
+#include "base/lazy_instance.h"
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
#include "net/url_request/url_request.h"
@@ -13,6 +16,13 @@
using WebKit::WebApplicationCacheHost;
using WebKit::WebConsoleMessage;
+namespace {
+
+base::LazyInstance<std::set<std::string> >::Leaky g_supported_schemes =
+ LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
namespace appcache {
const char kHttpScheme[] = "http";
@@ -77,8 +87,16 @@ bool Namespace::IsMatch(const GURL& url) const {
return StartsWithASCII(url.spec(), namespace_url.spec(), true);
}
+void AddSupportedScheme(const char* scheme) {
+ g_supported_schemes.Get().insert(scheme);
+}
+
bool IsSchemeSupported(const GURL& url) {
- bool supported = url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme);
+ bool supported = url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme) ||
+ (!(g_supported_schemes == NULL) &&
+ g_supported_schemes.Get().find(url.scheme()) !=
+ g_supported_schemes.Get().end());
+
#ifndef NDEBUG
// TODO(michaeln): It would be really nice if this could optionally work for
// file and filesystem urls too to help web developers experiment and test
diff --git a/webkit/appcache/appcache_interfaces.h b/webkit/appcache/appcache_interfaces.h
index b45ee8f..0dfa4c4 100644
--- a/webkit/appcache/appcache_interfaces.h
+++ b/webkit/appcache/appcache_interfaces.h
@@ -171,6 +171,8 @@ extern const char kHttpsScheme[];
extern const char kHttpGETMethod[];
extern const char kHttpHEADMethod[];
+WEBKIT_STORAGE_EXPORT void AddSupportedScheme(const char* scheme);
+
bool IsSchemeSupported(const GURL& url);
bool IsMethodSupported(const std::string& method);
bool IsSchemeAndMethodSupported(const net::URLRequest* request);