summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/browser/debugger/DEPS3
-rw-r--r--content/browser/debugger/devtools_http_protocol_handler.cc29
-rw-r--r--content/browser/debugger/devtools_http_protocol_handler.h30
-rw-r--r--content/browser/debugger/frontend/devtools_frontend.html142
-rw-r--r--content/browser/debugger/frontend/devtools_frontend_resources.grd21
5 files changed, 33 insertions, 192 deletions
diff --git a/content/browser/debugger/DEPS b/content/browser/debugger/DEPS
index 9199857..2b22ec3 100644
--- a/content/browser/debugger/DEPS
+++ b/content/browser/debugger/DEPS
@@ -11,8 +11,5 @@ include_rules = [
"+chrome/browser/debugger/devtools_window.h",
"+chrome/browser/profiles/profile_manager.h",
- # devtools_http_protocol_handler.cc
- "+ui/base/resource/resource_bundle.h",
-
# DO NOT ADD ANY MORE TO THIS LIST!!! SEE ABOVE COMMENT
]
diff --git a/content/browser/debugger/devtools_http_protocol_handler.cc b/content/browser/debugger/devtools_http_protocol_handler.cc
index 0801906..8540794 100644
--- a/content/browser/debugger/devtools_http_protocol_handler.cc
+++ b/content/browser/debugger/devtools_http_protocol_handler.cc
@@ -15,21 +15,17 @@
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
#include "content/browser/browser_thread.h"
#include "content/browser/debugger/devtools_client_host.h"
#include "content/browser/debugger/devtools_manager.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_observer.h"
#include "content/common/devtools_messages.h"
-#include "grit/devtools_frontend_resources.h"
#include "googleurl/src/gurl.h"
#include "net/base/escape.h"
#include "net/base/io_buffer.h"
#include "net/server/http_server_request_info.h"
#include "net/url_request/url_request_context.h"
-#include "net/url_request/url_request_context_getter.h"
-#include "ui/base/resource/resource_bundle.h"
const int kBufferSize = 16 * 1024;
@@ -141,9 +137,9 @@ scoped_refptr<DevToolsHttpProtocolHandler> DevToolsHttpProtocolHandler::Start(
const std::string& ip,
int port,
const std::string& frontend_url,
- TabContentsProvider* provider) {
+ Delegate* delegate) {
scoped_refptr<DevToolsHttpProtocolHandler> http_handler =
- new DevToolsHttpProtocolHandler(ip, port, frontend_url, provider);
+ new DevToolsHttpProtocolHandler(ip, port, frontend_url, delegate);
http_handler->Start();
return http_handler;
}
@@ -181,16 +177,14 @@ void DevToolsHttpProtocolHandler::OnHttpRequest(
}
// Proxy static files from chrome-devtools://devtools/*.
- if (!Profile::Deprecated::GetDefaultRequestContext()) {
+ net::URLRequestContext* request_context = delegate_->GetURLRequestContext();
+ if (!request_context) {
server_->Send404(connection_id);
return;
}
if (info.path == "" || info.path == "/") {
- const base::StringPiece frontend_html(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_DEVTOOLS_FRONTEND_HTML));
- std::string response(frontend_html.data(), frontend_html.length());
+ std::string response = delegate_->GetDiscoveryPageHTML();
server_->Send200(connection_id, response, "text/html; charset=UTF-8");
return;
}
@@ -207,8 +201,7 @@ void DevToolsHttpProtocolHandler::OnHttpRequest(
}
Bind(request, connection_id);
- request->set_context(
- Profile::Deprecated::GetDefaultRequestContext()->GetURLRequestContext());
+ request->set_context(request_context);
request->Start();
}
@@ -275,11 +268,11 @@ struct PageInfo
typedef std::vector<PageInfo> PageList;
static PageList GeneratePageList(
- DevToolsHttpProtocolHandler::TabContentsProvider* tab_contents_provider,
+ DevToolsHttpProtocolHandler::Delegate* delegate,
int connection_id,
const net::HttpServerRequestInfo& info) {
typedef DevToolsHttpProtocolHandler::InspectableTabs Tabs;
- Tabs inspectable_tabs = tab_contents_provider->GetInspectableTabs();
+ Tabs inspectable_tabs = delegate->GetInspectableTabs();
PageList page_list;
for (Tabs::iterator it = inspectable_tabs.begin();
@@ -309,7 +302,7 @@ static PageList GeneratePageList(
void DevToolsHttpProtocolHandler::OnJsonRequestUI(
int connection_id,
const net::HttpServerRequestInfo& info) {
- PageList page_list = GeneratePageList(tab_contents_provider_.get(),
+ PageList page_list = GeneratePageList(delegate_.get(),
connection_id, info);
ListValue json_pages_list;
std::string host = info.headers["Host"];
@@ -469,11 +462,11 @@ DevToolsHttpProtocolHandler::DevToolsHttpProtocolHandler(
const std::string& ip,
int port,
const std::string& frontend_host,
- TabContentsProvider* provider)
+ Delegate* delegate)
: ip_(ip),
port_(port),
overridden_frontend_url_(frontend_host),
- tab_contents_provider_(provider) {
+ delegate_(delegate) {
if (overridden_frontend_url_.empty())
overridden_frontend_url_ = "/devtools/devtools.html";
}
diff --git a/content/browser/debugger/devtools_http_protocol_handler.h b/content/browser/debugger/devtools_http_protocol_handler.h
index a2409a3..ff09fec 100644
--- a/content/browser/debugger/devtools_http_protocol_handler.h
+++ b/content/browser/debugger/devtools_http_protocol_handler.h
@@ -20,27 +20,41 @@ class DevToolsClientHost;
class DevToolsHttpServer;
class TabContents;
+namespace net {
+class URLRequestContext;
+}
+
class DevToolsHttpProtocolHandler
: public net::HttpServer::Delegate,
public net::URLRequest::Delegate,
public base::RefCountedThreadSafe<DevToolsHttpProtocolHandler> {
public:
typedef std::vector<TabContents*> InspectableTabs;
- class TabContentsProvider {
+ class Delegate {
public:
- TabContentsProvider() {}
- virtual ~TabContentsProvider() {}
+ Delegate() {}
+ virtual ~Delegate() {}
+
+ // Should return the list of inspectable tabs. Called on the UI thread.
virtual InspectableTabs GetInspectableTabs() = 0;
+
+ // Should return discovery page HTML that should list available tabs
+ // and provide attach links. Called on the IO thread.
+ virtual std::string GetDiscoveryPageHTML() = 0;
+
+ // Should return URL request context for issuing requests against devtools
+ // webui or NULL if no context is available. Called on the IO thread.
+ virtual net::URLRequestContext* GetURLRequestContext() = 0;
private:
- DISALLOW_COPY_AND_ASSIGN(TabContentsProvider);
+ DISALLOW_COPY_AND_ASSIGN(Delegate);
};
- // Takes ownership over |provider|.
+ // Takes ownership over |delegate|.
static scoped_refptr<DevToolsHttpProtocolHandler> Start(
const std::string& ip,
int port,
const std::string& frontend_url,
- TabContentsProvider* provider);
+ Delegate* delegate);
// Called from the main thread in order to stop protocol handler.
// Will schedule tear down task on IO thread.
@@ -52,7 +66,7 @@ class DevToolsHttpProtocolHandler
DevToolsHttpProtocolHandler(const std::string& ip,
int port,
const std::string& frontend_url,
- TabContentsProvider* provider);
+ Delegate* delegate);
virtual ~DevToolsHttpProtocolHandler();
void Start();
@@ -107,7 +121,7 @@ class DevToolsHttpProtocolHandler
typedef std::map<int, DevToolsClientHost*>
ConnectionToClientHostMap;
ConnectionToClientHostMap connection_to_client_host_ui_;
- scoped_ptr<TabContentsProvider> tab_contents_provider_;
+ scoped_ptr<Delegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(DevToolsHttpProtocolHandler);
};
diff --git a/content/browser/debugger/frontend/devtools_frontend.html b/content/browser/debugger/frontend/devtools_frontend.html
deleted file mode 100644
index 85c03b8..0000000
--- a/content/browser/debugger/frontend/devtools_frontend.html
+++ /dev/null
@@ -1,142 +0,0 @@
-<html>
-<head>
-<title>Inspectable pages</title>
-<style>
-body {
- background-color: rgb(245, 245, 245);
- font-family: Helvetica, Arial, sans-serif;
- text-shadow: rgba(255, 255, 255, 0.496094) 0px 1px 0px;
-}
-
-#caption {
- text-align: left;
- color: black;
- font-size: 16px;
- margin-top: 30px;
- margin-bottom: 0px;
- margin-left: 70px;
- height: 20px;
-}
-
-#items {
- display: -webkit-box;
- -webkit-box-orient: horizontal;
- -webkit-box-lines: multiple;
- margin-left: 60px;
- margin-right: 60px;
-}
-
-.frontend_ref {
- color: black;
- text-decoration: initial;
-}
-
-.thumbnail {
- height: 132px;
- width: 212px;
- background-attachment: scroll;
- background-origin: padding-box;
- background-repeat: no-repeat;
- border: 4px solid rgba(184, 184, 184, 1);
- border-radius: 5px;
- -webkit-transition-property: background-color, border-color;
- -webkit-transition: background-color 0.15s, 0.15s;
- -webkit-transition-delay: 0, 0;
-}
-
-.thumbnail:hover {
- background-color: rgba(242, 242, 242, 1);
- border-color: rgba(110, 116, 128, 1);
- color: black;
-}
-
-.thumbnail.connected {
- opacity: 0.5;
-}
-
-.thumbnail.connected:hover {
- border-color: rgba(184, 184, 184, 1);
- color: rgb(110, 116, 128);
-}
-
-.item {
- display: inline-block;
- margin: 5px;
- margin-top: 15px;
- height: 162px;
- width: 222px;
- vertical-align: top;
-}
-
-.text {
- text-align: left;
- font-size: 12px;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
- background: no-repeat 0;
- background-size: 16px;
- padding: 2px 0px 0px 20px;
- margin: 4px 0px 0px 4px;
-}
-</style>
-
-<script>
-function onLoad() {
- var tabsListRequest = new XMLHttpRequest();
- tabsListRequest.open("GET", "/json", true);
- tabsListRequest.onreadystatechange = onReady;
- tabsListRequest.send();
-}
-
-function onReady() {
- if(this.readyState == 4 && this.status == 200) {
- if(this.response != null)
- var responseJSON = JSON.parse(this.response);
- for (var i = 0; i < responseJSON.length; ++i)
- appendItem(responseJSON[i]);
- }
-}
-
-function appendItem(item_object) {
- var frontend_ref;
- if (item_object.devtoolsFrontendUrl) {
- frontend_ref = document.createElement("a");
- frontend_ref.href = item_object.devtoolsFrontendUrl;
- frontend_ref.title = item_object.title;
- } else {
- frontend_ref = document.createElement("div");
- frontend_ref.title = "The tab already has an active debug session";
- }
- frontend_ref.className = "frontend_ref";
-
- var thumbnail = document.createElement("div");
- thumbnail.className = item_object.devtoolsFrontendUrl ?
- "thumbnail" : "thumbnail connected";
- thumbnail.style.cssText = "background-image:url(" +
- item_object.thumbnailUrl +
- ")";
- frontend_ref.appendChild(thumbnail);
-
- var text = document.createElement("div");
- text.className = "text";
- text.innerText = item_object.title;
- text.style.cssText = "background-image:url(" +
- item_object.faviconUrl + ")";
- frontend_ref.appendChild(text);
-
- var item = document.createElement("p");
- item.className = "item";
- item.appendChild(frontend_ref);
-
- document.getElementById("items").appendChild(item);
-}
-</script>
-</head>
-<body onload='onLoad()'>
- <div id='caption'>Inspectable pages</div>
- <div id='items'>
- </div>
- <hr>
-</body>
-</html>
diff --git a/content/browser/debugger/frontend/devtools_frontend_resources.grd b/content/browser/debugger/frontend/devtools_frontend_resources.grd
deleted file mode 100644
index 0351cac..0000000
--- a/content/browser/debugger/frontend/devtools_frontend_resources.grd
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<grit current_release="1" latest_public_release="0">
- <outputs>
- <output filename="grit/devtools_frontend_resources.h"
- type="rc_header">
- <emit emit_type="prepend"/>
- </output>
- <output filename="grit/devtools_frontend_resources_map.cc"
- type="resource_file_map_source"/>
- <output filename="grit/devtools_frontend_resources_map.h"
- type="resource_map_header"/>
- <output filename="devtools_frontend_resources.pak"
- type="data_package"/>
- </outputs>
- <release seq="1">
- <includes>
- <include file="devtools_frontend.html"
- name="IDR_DEVTOOLS_FRONTEND_HTML"
- type="BINDATA"/></includes>
- </release>
-</grit>