OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/browser/devtools/renderer_overrides_handler.h" | 5 #include "content/browser/devtools/renderer_overrides_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/barrier_closure.h" | 10 #include "base/barrier_closure.h" |
11 #include "base/base64.h" | 11 #include "base/base64.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "content/browser/child_process_security_policy_impl.h" | 18 #include "content/browser/child_process_security_policy_impl.h" |
19 #include "content/browser/devtools/devtools_protocol_constants.h" | 19 #include "content/browser/devtools/devtools_protocol_constants.h" |
20 #include "content/browser/devtools/devtools_tracing_handler.h" | 20 #include "content/browser/devtools/devtools_tracing_handler.h" |
21 #include "content/browser/renderer_host/dip_util.h" | 21 #include "content/browser/renderer_host/dip_util.h" |
22 #include "content/browser/renderer_host/render_view_host_delegate.h" | 22 #include "content/browser/renderer_host/render_view_host_delegate.h" |
23 #include "content/browser/renderer_host/render_view_host_impl.h" | 23 #include "content/browser/renderer_host/render_view_host_impl.h" |
24 #include "content/common/view_messages.h" | 24 #include "content/common/view_messages.h" |
25 #include "content/port/browser/render_widget_host_view_port.h" | 25 #include "content/port/browser/render_widget_host_view_port.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/content_browser_client.h" |
27 #include "content/public/browser/devtools_agent_host.h" | 28 #include "content/public/browser/devtools_agent_host.h" |
28 #include "content/public/browser/javascript_dialog_manager.h" | 29 #include "content/public/browser/javascript_dialog_manager.h" |
29 #include "content/public/browser/navigation_controller.h" | 30 #include "content/public/browser/navigation_controller.h" |
30 #include "content/public/browser/navigation_entry.h" | 31 #include "content/public/browser/navigation_entry.h" |
31 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
32 #include "content/public/browser/render_view_host.h" | 33 #include "content/public/browser/render_view_host.h" |
33 #include "content/public/browser/render_widget_host_view.h" | 34 #include "content/public/browser/render_widget_host_view.h" |
34 #include "content/public/browser/storage_partition.h" | 35 #include "content/public/browser/storage_partition.h" |
35 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
36 #include "content/public/browser/web_contents_delegate.h" | 37 #include "content/public/browser/web_contents_delegate.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 RendererOverridesHandler::RendererOverridesHandler(DevToolsAgentHost* agent) | 86 RendererOverridesHandler::RendererOverridesHandler(DevToolsAgentHost* agent) |
86 : agent_(agent), | 87 : agent_(agent), |
87 capture_retry_count_(0), | 88 capture_retry_count_(0), |
88 weak_factory_(this) { | 89 weak_factory_(this) { |
89 RegisterCommandHandler( | 90 RegisterCommandHandler( |
90 devtools::DOM::setFileInputFiles::kName, | 91 devtools::DOM::setFileInputFiles::kName, |
91 base::Bind( | 92 base::Bind( |
92 &RendererOverridesHandler::GrantPermissionsForSetFileInputFiles, | 93 &RendererOverridesHandler::GrantPermissionsForSetFileInputFiles, |
93 base::Unretained(this))); | 94 base::Unretained(this))); |
94 RegisterCommandHandler( | 95 RegisterCommandHandler( |
| 96 devtools::Network::clearBrowserCache::kName, |
| 97 base::Bind( |
| 98 &RendererOverridesHandler::ClearBrowserCache, |
| 99 base::Unretained(this))); |
| 100 RegisterCommandHandler( |
| 101 devtools::Network::clearBrowserCookies::kName, |
| 102 base::Bind( |
| 103 &RendererOverridesHandler::ClearBrowserCookies, |
| 104 base::Unretained(this))); |
| 105 RegisterCommandHandler( |
95 devtools::Page::disable::kName, | 106 devtools::Page::disable::kName, |
96 base::Bind( | 107 base::Bind( |
97 &RendererOverridesHandler::PageDisable, base::Unretained(this))); | 108 &RendererOverridesHandler::PageDisable, base::Unretained(this))); |
98 RegisterCommandHandler( | 109 RegisterCommandHandler( |
99 devtools::Page::handleJavaScriptDialog::kName, | 110 devtools::Page::handleJavaScriptDialog::kName, |
100 base::Bind( | 111 base::Bind( |
101 &RendererOverridesHandler::PageHandleJavaScriptDialog, | 112 &RendererOverridesHandler::PageHandleJavaScriptDialog, |
102 base::Unretained(this))); | 113 base::Unretained(this))); |
103 RegisterCommandHandler( | 114 RegisterCommandHandler( |
104 devtools::Page::navigate::kName, | 115 devtools::Page::navigate::kName, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 base::FilePath::StringType file; | 291 base::FilePath::StringType file; |
281 if (!file_list->GetString(i, &file)) | 292 if (!file_list->GetString(i, &file)) |
282 return command->InvalidParamResponse(param); | 293 return command->InvalidParamResponse(param); |
283 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 294 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
284 host->GetProcess()->GetID(), base::FilePath(file)); | 295 host->GetProcess()->GetID(), base::FilePath(file)); |
285 } | 296 } |
286 return NULL; | 297 return NULL; |
287 } | 298 } |
288 | 299 |
289 | 300 |
| 301 // Network agent handlers ---------------------------------------------------- |
| 302 |
| 303 scoped_refptr<DevToolsProtocol::Response> |
| 304 RendererOverridesHandler::ClearBrowserCache( |
| 305 scoped_refptr<DevToolsProtocol::Command> command) { |
| 306 GetContentClient()->browser()->ClearCache(agent_->GetRenderViewHost()); |
| 307 return command->SuccessResponse(NULL); |
| 308 } |
| 309 |
| 310 scoped_refptr<DevToolsProtocol::Response> |
| 311 RendererOverridesHandler::ClearBrowserCookies( |
| 312 scoped_refptr<DevToolsProtocol::Command> command) { |
| 313 GetContentClient()->browser()->ClearCookies(agent_->GetRenderViewHost()); |
| 314 return command->SuccessResponse(NULL); |
| 315 } |
| 316 |
| 317 |
290 // Page agent handlers ------------------------------------------------------- | 318 // Page agent handlers ------------------------------------------------------- |
291 | 319 |
292 scoped_refptr<DevToolsProtocol::Response> | 320 scoped_refptr<DevToolsProtocol::Response> |
293 RendererOverridesHandler::PageDisable( | 321 RendererOverridesHandler::PageDisable( |
294 scoped_refptr<DevToolsProtocol::Command> command) { | 322 scoped_refptr<DevToolsProtocol::Command> command) { |
295 screencast_command_ = NULL; | 323 screencast_command_ = NULL; |
296 return NULL; | 324 return NULL; |
297 } | 325 } |
298 | 326 |
299 scoped_refptr<DevToolsProtocol::Response> | 327 scoped_refptr<DevToolsProtocol::Response> |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 return NULL; | 993 return NULL; |
966 } | 994 } |
967 event.data.pinchUpdate.scale = static_cast<float>(scale); | 995 event.data.pinchUpdate.scale = static_cast<float>(scale); |
968 } | 996 } |
969 | 997 |
970 host->ForwardGestureEvent(event); | 998 host->ForwardGestureEvent(event); |
971 return command->SuccessResponse(NULL); | 999 return command->SuccessResponse(NULL); |
972 } | 1000 } |
973 | 1001 |
974 } // namespace content | 1002 } // namespace content |
OLD | NEW |