summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2015-01-14 12:19:41 +0100
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>2015-01-22 16:22:03 +0100
commit9d9268ae1ce34a853b48d3b7189dba6448c38033 (patch)
tree57a070c5b8d9653bdff472b9b98aa5ceacc7909e
parent9c852a048ebce776fba08a668e4e45251f987d10 (diff)
Fix the inspector after the 40 update
Update our copy of the DevTools code according to the modifications in Chromium 40. Add a DevToolsManagerDelegate subclass to re-add the target enumeration code and import the new shell Target code. Change-Id: I8c56faaf4dd77ca8f4129fcdc80690c7a117464b Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
-rw-r--r--src/core/content_browser_client_qt.cpp5
-rw-r--r--src/core/content_browser_client_qt.h3
-rw-r--r--src/core/dev_tools_http_handler_delegate_qt.cpp83
-rw-r--r--src/core/dev_tools_http_handler_delegate_qt.h15
4 files changed, 72 insertions, 34 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 232e2d9df..ef034efbc 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -436,3 +436,8 @@ std::string ContentBrowserClientQt::GetApplicationLocale()
{
return QLocale().name().toStdString();
}
+
+content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDelegate()
+{
+ return new DevToolsManagerDelegateQt;
+}
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 7b5ca49af..0a3acd9cf 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -51,6 +51,7 @@ class URLRequestContextGetter;
namespace content {
class BrowserContext;
class BrowserMainParts;
+class DevToolsManagerDelegate;
class RenderProcessHost;
class RenderViewHostDelegateView;
class ResourceContext;
@@ -103,7 +104,7 @@ public:
bool user_gesture,
const base::Callback<void(bool)>& result_callback) Q_DECL_OVERRIDE;
content::LocationProvider* OverrideSystemLocationProvider() Q_DECL_OVERRIDE;
-
+ content::DevToolsManagerDelegate *GetDevToolsManagerDelegate() Q_DECL_OVERRIDE;
virtual net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *browser_context, content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptorss) Q_DECL_OVERRIDE;
virtual blink::WebNotificationPermission CheckDesktopNotificationPermission(const GURL& source_origin, content::ResourceContext* context, int render_process_id) Q_DECL_OVERRIDE;
diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/dev_tools_http_handler_delegate_qt.cpp
index ba3e6d5b1..561a86f2a 100644
--- a/src/core/dev_tools_http_handler_delegate_qt.cpp
+++ b/src/core/dev_tools_http_handler_delegate_qt.cpp
@@ -64,6 +64,8 @@ using namespace content;
namespace {
const char kTargetTypePage[] = "page";
+const char kTargetTypeServiceWorker[] = "service_worker";
+const char kTargetTypeOther[] = "other";
class TCPServerSocketFactory
: public DevToolsHttpHandler::ServerSocketFactory {
@@ -79,14 +81,24 @@ private:
class Target : public content::DevToolsTarget {
public:
- explicit Target(WebContents* web_contents);
+ explicit Target(scoped_refptr<DevToolsAgentHost> agent_host);
- virtual std::string GetId() const override { return id_; }
+ virtual std::string GetId() const override { return agent_host_->GetId(); }
virtual std::string GetParentId() const override { return std::string(); }
- virtual std::string GetType() const override { return kTargetTypePage; }
- virtual std::string GetTitle() const override { return title_; }
+ virtual std::string GetType() const override {
+ switch (agent_host_->GetType()) {
+ case DevToolsAgentHost::TYPE_WEB_CONTENTS:
+ return kTargetTypePage;
+ case DevToolsAgentHost::TYPE_SERVICE_WORKER:
+ return kTargetTypeServiceWorker;
+ default:
+ break;
+ }
+ return kTargetTypeOther;
+ }
+ virtual std::string GetTitle() const override { return agent_host_->GetTitle(); }
virtual std::string GetDescription() const override { return std::string(); }
- virtual GURL GetURL() const override { return url_; }
+ virtual GURL GetURL() const override { return agent_host_->GetURL(); }
virtual GURL GetFaviconURL() const override { return favicon_url_; }
virtual base::TimeTicks GetLastActivityTime() const override {
return last_activity_time_;
@@ -102,42 +114,28 @@ public:
private:
scoped_refptr<DevToolsAgentHost> agent_host_;
- std::string id_;
- std::string title_;
- GURL url_;
GURL favicon_url_;
base::TimeTicks last_activity_time_;
};
-Target::Target(WebContents* web_contents) {
- agent_host_ = DevToolsAgentHost::GetOrCreateFor(web_contents);
- id_ = agent_host_->GetId();
- title_ = base::UTF16ToUTF8(web_contents->GetTitle());
- url_ = web_contents->GetURL();
- content::NavigationController& controller = web_contents->GetController();
- content::NavigationEntry* entry = controller.GetActiveEntry();
- if (entry != NULL && entry->GetURL().is_valid())
- favicon_url_ = entry->GetFavicon().url;
- last_activity_time_ = web_contents->GetLastActiveTime();
+Target::Target(scoped_refptr<DevToolsAgentHost> agent_host)
+ : agent_host_(agent_host)
+{
+ if (WebContents* web_contents = agent_host_->GetWebContents()) {
+ NavigationController& controller = web_contents->GetController();
+ NavigationEntry* entry = controller.GetActiveEntry();
+ if (entry != NULL && entry->GetURL().is_valid())
+ favicon_url_ = entry->GetFavicon().url;
+ last_activity_time_ = web_contents->GetLastActiveTime();
+ }
}
bool Target::Activate() const {
- WebContents *web_contents = agent_host_->GetWebContents();
- if (!web_contents)
- return false;
- web_contents->GetDelegate()->ActivateContents(web_contents);
- return true;
+ return agent_host_->Activate();
}
bool Target::Close() const {
- WebContents *web_contents = agent_host_->GetWebContents();
- if (!web_contents)
- return false;
- RenderViewHost* rvh = web_contents->GetRenderViewHost();
- if (!rvh)
- return false;
- rvh->ClosePage();
- return true;
+ return agent_host_->Close();
}
} // namespace
@@ -190,3 +188,26 @@ scoped_ptr<net::StreamListenSocket> DevToolsHttpHandlerDelegateQt::CreateSocketF
{
return scoped_ptr<net::StreamListenSocket>();
}
+
+base::DictionaryValue* DevToolsManagerDelegateQt::HandleCommand(DevToolsAgentHost *, base::DictionaryValue *) {
+ return 0;
+}
+
+std::string DevToolsManagerDelegateQt::GetPageThumbnailData(const GURL& url)
+{
+ return std::string();
+}
+
+scoped_ptr<DevToolsTarget> DevToolsManagerDelegateQt::CreateNewTarget(const GURL &)
+{
+ return scoped_ptr<DevToolsTarget>();
+}
+
+void DevToolsManagerDelegateQt::EnumerateTargets(TargetCallback callback)
+{
+ TargetList targets;
+ for (const auto& agent_host : DevToolsAgentHost::GetOrCreateAll()) {
+ targets.push_back(new Target(agent_host));
+ }
+ callback.Run(targets);
+}
diff --git a/src/core/dev_tools_http_handler_delegate_qt.h b/src/core/dev_tools_http_handler_delegate_qt.h
index 0a28cf5c6..bbee613a2 100644
--- a/src/core/dev_tools_http_handler_delegate_qt.h
+++ b/src/core/dev_tools_http_handler_delegate_qt.h
@@ -38,6 +38,7 @@
#define DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H
#include "content/public/browser/devtools_http_handler_delegate.h"
+#include "content/public/browser/devtools_manager_delegate.h"
#include <QtCore/qcompilerdetection.h> // needed for Q_DECL_OVERRIDE
@@ -63,11 +64,21 @@ public:
virtual base::FilePath GetDebugFrontendDir() Q_DECL_OVERRIDE;
// Requests the list of all inspectable targets.
// The caller gets the ownership of the returned targets.
- virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(net::StreamListenSocket::Delegate* delegate, std::string* name) Q_DECL_OVERRIDE;
+ virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(net::StreamListenSocket::Delegate *delegate, std::string *name) Q_DECL_OVERRIDE;
private:
content::BrowserContext* m_browserContext;
- content::DevToolsHttpHandler* m_devtoolsHttpHandler;
+ content::DevToolsHttpHandler *m_devtoolsHttpHandler;
+};
+
+class DevToolsManagerDelegateQt : public content::DevToolsManagerDelegate {
+public:
+ void Inspect(content::BrowserContext *browser_context, content::DevToolsAgentHost *agent_host) Q_DECL_OVERRIDE { }
+ void DevToolsAgentStateChanged(content::DevToolsAgentHost *agent_host, bool attached) Q_DECL_OVERRIDE { }
+ base::DictionaryValue *HandleCommand(content::DevToolsAgentHost *agent_host, base::DictionaryValue *command) Q_DECL_OVERRIDE;
+ scoped_ptr<content::DevToolsTarget> CreateNewTarget(const GURL &url) Q_DECL_OVERRIDE;
+ void EnumerateTargets(TargetCallback callback) Q_DECL_OVERRIDE;
+ std::string GetPageThumbnailData(const GURL &url) Q_DECL_OVERRIDE;
};
#endif // DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H