OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/browser/net/chrome_url_request_context.h" | 12 #include "chrome/browser/net/chrome_url_request_context.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.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/devtools_http_handler.h" |
19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
21 #include "content/public/browser/web_ui.h" | 21 #include "content/public/browser/web_ui.h" |
| 22 #include "ui/base/layout.h" |
22 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
23 | 24 |
24 using content::BrowserThread; | 25 using content::BrowserThread; |
25 using content::WebContents; | 26 using content::WebContents; |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 std::string PathWithoutParams(const std::string& path) { | 30 std::string PathWithoutParams(const std::string& path) { |
30 return GURL(std::string("chrome-devtools://devtools/") + path) | 31 return GURL(std::string("chrome-devtools://devtools/") + path) |
31 .path().substr(1); | 32 .path().substr(1); |
(...skipping 27 matching lines...) Expand all Loading... |
59 | 60 |
60 | 61 |
61 int resource_id = | 62 int resource_id = |
62 content::DevToolsHttpHandler::GetFrontendResourceId(filename); | 63 content::DevToolsHttpHandler::GetFrontendResourceId(filename); |
63 | 64 |
64 DLOG_IF(WARNING, -1 == resource_id) << "Unable to find dev tool resource: " | 65 DLOG_IF(WARNING, -1 == resource_id) << "Unable to find dev tool resource: " |
65 << filename << ". If you compiled with debug_devtools=1, try running" | 66 << filename << ". If you compiled with debug_devtools=1, try running" |
66 " with --debug-devtools."; | 67 " with --debug-devtools."; |
67 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 68 const ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
68 scoped_refptr<base::RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes( | 69 scoped_refptr<base::RefCountedStaticMemory> bytes(rb.LoadDataResourceBytes( |
69 resource_id)); | 70 resource_id, ui::SCALE_FACTOR_NONE)); |
70 SendResponse(request_id, bytes); | 71 SendResponse(request_id, bytes); |
71 } | 72 } |
72 | 73 |
73 std::string DevToolsDataSource::GetMimeType(const std::string& path) const { | 74 std::string DevToolsDataSource::GetMimeType(const std::string& path) const { |
74 std::string filename = PathWithoutParams(path); | 75 std::string filename = PathWithoutParams(path); |
75 if (EndsWith(filename, ".html", false)) { | 76 if (EndsWith(filename, ".html", false)) { |
76 return "text/html"; | 77 return "text/html"; |
77 } else if (EndsWith(filename, ".css", false)) { | 78 } else if (EndsWith(filename, ".css", false)) { |
78 return "text/css"; | 79 return "text/css"; |
79 } else if (EndsWith(filename, ".js", false)) { | 80 } else if (EndsWith(filename, ".js", false)) { |
(...skipping 21 matching lines...) Expand all Loading... |
101 DevToolsUI::DevToolsUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 102 DevToolsUI::DevToolsUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
102 DevToolsDataSource* data_source = new DevToolsDataSource(); | 103 DevToolsDataSource* data_source = new DevToolsDataSource(); |
103 Profile* profile = Profile::FromWebUI(web_ui); | 104 Profile* profile = Profile::FromWebUI(web_ui); |
104 ChromeURLDataManager::AddDataSource(profile, data_source); | 105 ChromeURLDataManager::AddDataSource(profile, data_source); |
105 } | 106 } |
106 | 107 |
107 void DevToolsUI::RenderViewCreated( | 108 void DevToolsUI::RenderViewCreated( |
108 content::RenderViewHost* render_view_host) { | 109 content::RenderViewHost* render_view_host) { |
109 content::DevToolsClientHost::SetupDevToolsFrontendClient(render_view_host); | 110 content::DevToolsClientHost::SetupDevToolsFrontendClient(render_view_host); |
110 } | 111 } |
OLD | NEW |