Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: chrome/browser/ui/webui/devtools_ui.cc

Issue 9113079: DevTools: refactor remote debugging server to enable content_shell debugging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch for landing. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/devtools_ui.h" 5 #include "chrome/browser/ui/webui/devtools_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "chrome/browser/net/chrome_url_request_context.h" 11 #include "chrome/browser/net/chrome_url_request_context.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "content/browser/renderer_host/render_view_host.h" 15 #include "content/browser/renderer_host/render_view_host.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/devtools_client_host.h" 17 #include "content/public/browser/devtools_client_host.h"
18 #include "content/public/browser/devtools_http_handler.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_ui.h" 20 #include "content/public/browser/web_ui.h"
20 #include "grit/devtools_resources_map.h"
21 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
22 22
23 using content::BrowserThread; 23 using content::BrowserThread;
24 using content::WebContents; 24 using content::WebContents;
25 25
26 namespace { 26 namespace {
27 27
28 std::string PathWithoutParams(const std::string& path) { 28 std::string PathWithoutParams(const std::string& path) {
29 return GURL(std::string("chrome-devtools://devtools/") + path) 29 return GURL(std::string("chrome-devtools://devtools/") + path)
30 .path().substr(1); 30 .path().substr(1);
(...skipping 18 matching lines...) Expand all
49 49
50 DevToolsDataSource::DevToolsDataSource() 50 DevToolsDataSource::DevToolsDataSource()
51 : DataSource(chrome::kChromeUIDevToolsHost, NULL) { 51 : DataSource(chrome::kChromeUIDevToolsHost, NULL) {
52 } 52 }
53 53
54 void DevToolsDataSource::StartDataRequest(const std::string& path, 54 void DevToolsDataSource::StartDataRequest(const std::string& path,
55 bool is_incognito, 55 bool is_incognito,
56 int request_id) { 56 int request_id) {
57 std::string filename = PathWithoutParams(path); 57 std::string filename = PathWithoutParams(path);
58 58
59 int resource_id = -1; 59
60 for (size_t i = 0; i < kDevtoolsResourcesSize; ++i) { 60 int resource_id =
61 if (filename == kDevtoolsResources[i].name) { 61 content::DevToolsHttpHandler::GetFrontendResourceId(filename);
62 resource_id = kDevtoolsResources[i].value;
63 break;
64 }
65 }
66 62
67 DLOG_IF(WARNING, -1 == resource_id) << "Unable to find dev tool resource: " 63 DLOG_IF(WARNING, -1 == resource_id) << "Unable to find dev tool resource: "
68 << filename << ". If you compiled with debug_devtools=1, try running" 64 << filename << ". If you compiled with debug_devtools=1, try running"
69 " with --debug-devtools."; 65 " with --debug-devtools.";
70 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 66 const ResourceBundle& rb = ResourceBundle::GetSharedInstance();
71 scoped_refptr<RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes( 67 scoped_refptr<RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes(
72 resource_id)); 68 resource_id));
73 SendResponse(request_id, bytes); 69 SendResponse(request_id, bytes);
74 } 70 }
75 71
(...skipping 27 matching lines...) Expand all
103 99
104 DevToolsUI::DevToolsUI(content::WebUI* web_ui) : WebUIController(web_ui) { 100 DevToolsUI::DevToolsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
105 DevToolsDataSource* data_source = new DevToolsDataSource(); 101 DevToolsDataSource* data_source = new DevToolsDataSource();
106 Profile* profile = Profile::FromWebUI(web_ui); 102 Profile* profile = Profile::FromWebUI(web_ui);
107 profile->GetChromeURLDataManager()->AddDataSource(data_source); 103 profile->GetChromeURLDataManager()->AddDataSource(data_source);
108 } 104 }
109 105
110 void DevToolsUI::RenderViewCreated(RenderViewHost* render_view_host) { 106 void DevToolsUI::RenderViewCreated(RenderViewHost* render_view_host) {
111 content::DevToolsClientHost::SetupDevToolsFrontendClient(render_view_host); 107 content::DevToolsClientHost::SetupDevToolsFrontendClient(render_view_host);
112 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698