OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/shell/browser/shell_devtools_manager_delegate.h" | 5 #include "content/shell/browser/shell_devtools_manager_delegate.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "components/devtools_discovery/basic_target_descriptor.h" | 15 #include "components/devtools_discovery/basic_target_descriptor.h" |
16 #include "components/devtools_discovery/devtools_discovery_manager.h" | 16 #include "components/devtools_discovery/devtools_discovery_manager.h" |
17 #include "components/devtools_http_handler/devtools_http_handler.h" | 17 #include "components/devtools_http_handler/devtools_http_handler.h" |
18 #include "content/public/browser/devtools_agent_host.h" | 18 #include "content/public/browser/devtools_agent_host.h" |
19 #include "content/public/browser/devtools_frontend_host.h" | 19 #include "content/public/browser/devtools_frontend_host.h" |
20 #include "content/public/browser/devtools_target.h" | |
21 #include "content/public/browser/favicon_status.h" | 20 #include "content/public/browser/favicon_status.h" |
22 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
23 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
24 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
25 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
26 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
27 #include "content/public/common/user_agent.h" | 26 #include "content/public/common/user_agent.h" |
28 #include "content/shell/browser/shell.h" | 27 #include "content/shell/browser/shell.h" |
29 #include "content/shell/common/shell_content_client.h" | 28 #include "content/shell/common/shell_content_client.h" |
30 #include "grit/shell_resources.h" | 29 #include "grit/shell_resources.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 145 |
147 class ShellDevToolsDelegate : | 146 class ShellDevToolsDelegate : |
148 public devtools_http_handler::DevToolsHttpHandlerDelegate { | 147 public devtools_http_handler::DevToolsHttpHandlerDelegate { |
149 public: | 148 public: |
150 explicit ShellDevToolsDelegate(BrowserContext* browser_context); | 149 explicit ShellDevToolsDelegate(BrowserContext* browser_context); |
151 ~ShellDevToolsDelegate() override; | 150 ~ShellDevToolsDelegate() override; |
152 | 151 |
153 // devtools_http_handler::DevToolsHttpHandlerDelegate implementation. | 152 // devtools_http_handler::DevToolsHttpHandlerDelegate implementation. |
154 std::string GetDiscoveryPageHTML() override; | 153 std::string GetDiscoveryPageHTML() override; |
155 std::string GetFrontendResource(const std::string& path) override; | 154 std::string GetFrontendResource(const std::string& path) override; |
| 155 std::string GetPageThumbnailData(const GURL& url) override; |
156 | 156 |
157 private: | 157 private: |
158 BrowserContext* browser_context_; | 158 BrowserContext* browser_context_; |
159 | 159 |
160 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsDelegate); | 160 DISALLOW_COPY_AND_ASSIGN(ShellDevToolsDelegate); |
161 }; | 161 }; |
162 | 162 |
163 ShellDevToolsDelegate::ShellDevToolsDelegate(BrowserContext* browser_context) | 163 ShellDevToolsDelegate::ShellDevToolsDelegate(BrowserContext* browser_context) |
164 : browser_context_(browser_context) { | 164 : browser_context_(browser_context) { |
165 devtools_discovery::DevToolsDiscoveryManager::GetInstance()-> | 165 devtools_discovery::DevToolsDiscoveryManager::GetInstance()-> |
(...skipping 14 matching lines...) Expand all Loading... |
180 return ResourceBundle::GetSharedInstance().GetRawDataResource( | 180 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
181 IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); | 181 IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); |
182 #endif | 182 #endif |
183 } | 183 } |
184 | 184 |
185 std::string ShellDevToolsDelegate::GetFrontendResource( | 185 std::string ShellDevToolsDelegate::GetFrontendResource( |
186 const std::string& path) { | 186 const std::string& path) { |
187 return content::DevToolsFrontendHost::GetFrontendResource(path).as_string(); | 187 return content::DevToolsFrontendHost::GetFrontendResource(path).as_string(); |
188 } | 188 } |
189 | 189 |
| 190 std::string ShellDevToolsDelegate::GetPageThumbnailData(const GURL& url) { |
| 191 return std::string(); |
| 192 } |
| 193 |
190 } // namespace | 194 } // namespace |
191 | 195 |
192 // ShellDevToolsManagerDelegate ---------------------------------------------- | 196 // ShellDevToolsManagerDelegate ---------------------------------------------- |
193 | 197 |
194 // static | 198 // static |
195 DevToolsHttpHandler* | 199 DevToolsHttpHandler* |
196 ShellDevToolsManagerDelegate::CreateHttpHandler( | 200 ShellDevToolsManagerDelegate::CreateHttpHandler( |
197 BrowserContext* browser_context) { | 201 BrowserContext* browser_context) { |
198 std::string frontend_url; | 202 std::string frontend_url; |
199 #if defined(OS_ANDROID) | 203 #if defined(OS_ANDROID) |
200 frontend_url = base::StringPrintf(kFrontEndURL, GetWebKitRevision().c_str()); | 204 frontend_url = base::StringPrintf(kFrontEndURL, GetWebKitRevision().c_str()); |
201 #endif | 205 #endif |
202 return new DevToolsHttpHandler( | 206 return new DevToolsHttpHandler( |
203 CreateSocketFactory(), | 207 CreateSocketFactory(), |
204 frontend_url, | 208 frontend_url, |
205 new ShellDevToolsDelegate(browser_context), | 209 new ShellDevToolsDelegate(browser_context), |
206 new ShellDevToolsManagerDelegate(browser_context), | |
207 base::FilePath(), | 210 base::FilePath(), |
208 base::FilePath(), | 211 base::FilePath(), |
209 std::string(), | 212 std::string(), |
210 GetShellUserAgent()); | 213 GetShellUserAgent()); |
211 } | 214 } |
212 | 215 |
213 ShellDevToolsManagerDelegate::ShellDevToolsManagerDelegate( | 216 ShellDevToolsManagerDelegate::ShellDevToolsManagerDelegate( |
214 BrowserContext* browser_context) | 217 BrowserContext* browser_context) |
215 : browser_context_(browser_context) { | 218 : browser_context_(browser_context) { |
216 } | 219 } |
217 | 220 |
218 ShellDevToolsManagerDelegate::~ShellDevToolsManagerDelegate() { | 221 ShellDevToolsManagerDelegate::~ShellDevToolsManagerDelegate() { |
219 } | 222 } |
220 | 223 |
221 base::DictionaryValue* ShellDevToolsManagerDelegate::HandleCommand( | 224 base::DictionaryValue* ShellDevToolsManagerDelegate::HandleCommand( |
222 DevToolsAgentHost* agent_host, | 225 DevToolsAgentHost* agent_host, |
223 base::DictionaryValue* command) { | 226 base::DictionaryValue* command) { |
224 return NULL; | 227 return NULL; |
225 } | 228 } |
226 | 229 |
227 std::string ShellDevToolsManagerDelegate::GetPageThumbnailData( | |
228 const GURL& url) { | |
229 return std::string(); | |
230 } | |
231 | |
232 scoped_ptr<DevToolsTarget> | |
233 ShellDevToolsManagerDelegate::CreateNewTarget(const GURL& url) { | |
234 devtools_discovery::DevToolsDiscoveryManager* discovery_manager = | |
235 devtools_discovery::DevToolsDiscoveryManager::GetInstance(); | |
236 return discovery_manager->CreateNew(url); | |
237 } | |
238 | |
239 void ShellDevToolsManagerDelegate::EnumerateTargets(TargetCallback callback) { | |
240 TargetList targets; | |
241 devtools_discovery::DevToolsDiscoveryManager* discovery_manager = | |
242 devtools_discovery::DevToolsDiscoveryManager::GetInstance(); | |
243 for (const auto& descriptor : discovery_manager->GetDescriptors()) | |
244 targets.push_back(descriptor); | |
245 callback.Run(targets); | |
246 } | |
247 | |
248 } // namespace content | 230 } // namespace content |
OLD | NEW |