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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
34 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
35 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
36 #include "content/public/browser/render_widget_host_view.h" | 36 #include "content/public/browser/render_widget_host_view.h" |
37 #include "content/public/browser/storage_partition.h" | 37 #include "content/public/browser/storage_partition.h" |
38 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
39 #include "content/public/browser/web_contents_delegate.h" | 39 #include "content/public/browser/web_contents_delegate.h" |
40 #include "content/public/common/content_client.h" | 40 #include "content/public/common/content_client.h" |
41 #include "content/public/common/page_transition_types.h" | 41 #include "content/public/common/page_transition_types.h" |
42 #include "content/public/common/referrer.h" | 42 #include "content/public/common/referrer.h" |
| 43 #include "content/public/common/url_constants.h" |
43 #include "ipc/ipc_sender.h" | 44 #include "ipc/ipc_sender.h" |
44 #include "net/base/net_util.h" | 45 #include "net/base/net_util.h" |
45 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 46 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
46 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 47 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
47 #include "third_party/WebKit/public/web/WebInputEvent.h" | 48 #include "third_party/WebKit/public/web/WebInputEvent.h" |
48 #include "third_party/skia/include/core/SkCanvas.h" | 49 #include "third_party/skia/include/core/SkCanvas.h" |
49 #include "ui/gfx/codec/jpeg_codec.h" | 50 #include "ui/gfx/codec/jpeg_codec.h" |
50 #include "ui/gfx/codec/png_codec.h" | 51 #include "ui/gfx/codec/png_codec.h" |
51 #include "ui/gfx/display.h" | 52 #include "ui/gfx/display.h" |
52 #include "ui/gfx/screen.h" | 53 #include "ui/gfx/screen.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 devtools::Page::captureScreenshot::kName, | 138 devtools::Page::captureScreenshot::kName, |
138 base::Bind( | 139 base::Bind( |
139 &RendererOverridesHandler::PageCaptureScreenshot, | 140 &RendererOverridesHandler::PageCaptureScreenshot, |
140 base::Unretained(this))); | 141 base::Unretained(this))); |
141 RegisterCommandHandler( | 142 RegisterCommandHandler( |
142 devtools::Page::setTouchEmulationEnabled::kName, | 143 devtools::Page::setTouchEmulationEnabled::kName, |
143 base::Bind( | 144 base::Bind( |
144 &RendererOverridesHandler::PageSetTouchEmulationEnabled, | 145 &RendererOverridesHandler::PageSetTouchEmulationEnabled, |
145 base::Unretained(this))); | 146 base::Unretained(this))); |
146 RegisterCommandHandler( | 147 RegisterCommandHandler( |
| 148 devtools::Page::canEmulate::kName, |
| 149 base::Bind( |
| 150 &RendererOverridesHandler::PageCanEmulate, |
| 151 base::Unretained(this))); |
| 152 RegisterCommandHandler( |
147 devtools::Page::canScreencast::kName, | 153 devtools::Page::canScreencast::kName, |
148 base::Bind( | 154 base::Bind( |
149 &RendererOverridesHandler::PageCanScreencast, | 155 &RendererOverridesHandler::PageCanScreencast, |
150 base::Unretained(this))); | 156 base::Unretained(this))); |
151 RegisterCommandHandler( | 157 RegisterCommandHandler( |
152 devtools::Page::startScreencast::kName, | 158 devtools::Page::startScreencast::kName, |
153 base::Bind( | 159 base::Bind( |
154 &RendererOverridesHandler::PageStartScreencast, | 160 &RendererOverridesHandler::PageStartScreencast, |
155 base::Unretained(this))); | 161 base::Unretained(this))); |
156 RegisterCommandHandler( | 162 RegisterCommandHandler( |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 564 } |
559 | 565 |
560 touch_emulation_enabled_ = enabled; | 566 touch_emulation_enabled_ = enabled; |
561 UpdateTouchEventEmulationState(); | 567 UpdateTouchEventEmulationState(); |
562 | 568 |
563 // Pass to renderer. | 569 // Pass to renderer. |
564 return NULL; | 570 return NULL; |
565 } | 571 } |
566 | 572 |
567 scoped_refptr<DevToolsProtocol::Response> | 573 scoped_refptr<DevToolsProtocol::Response> |
| 574 RendererOverridesHandler::PageCanEmulate( |
| 575 scoped_refptr<DevToolsProtocol::Command> command) { |
| 576 base::DictionaryValue* result = new base::DictionaryValue(); |
| 577 #if defined(OS_ANDROID) |
| 578 result->SetBoolean(devtools::kResult, false); |
| 579 #else |
| 580 if (WebContents* web_contents = WebContents::FromRenderViewHost(host_)) { |
| 581 result->SetBoolean( |
| 582 devtools::kResult, |
| 583 !web_contents->GetVisibleURL().SchemeIs(kChromeDevToolsScheme)); |
| 584 } else { |
| 585 result->SetBoolean(devtools::kResult, true); |
| 586 } |
| 587 #endif // defined(OS_ANDROID) |
| 588 return command->SuccessResponse(result); |
| 589 } |
| 590 |
| 591 scoped_refptr<DevToolsProtocol::Response> |
568 RendererOverridesHandler::PageCanScreencast( | 592 RendererOverridesHandler::PageCanScreencast( |
569 scoped_refptr<DevToolsProtocol::Command> command) { | 593 scoped_refptr<DevToolsProtocol::Command> command) { |
570 base::DictionaryValue* result = new base::DictionaryValue(); | 594 base::DictionaryValue* result = new base::DictionaryValue(); |
571 #if defined(OS_ANDROID) | 595 #if defined(OS_ANDROID) |
572 result->SetBoolean(devtools::kResult, true); | 596 result->SetBoolean(devtools::kResult, true); |
573 #else | 597 #else |
574 result->SetBoolean(devtools::kResult, false); | 598 result->SetBoolean(devtools::kResult, false); |
575 #endif // defined(OS_ANDROID) | 599 #endif // defined(OS_ANDROID) |
576 return command->SuccessResponse(result); | 600 return command->SuccessResponse(result); |
577 } | 601 } |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 return; | 1325 return; |
1302 bool enabled = touch_emulation_enabled_ || screencast_command_; | 1326 bool enabled = touch_emulation_enabled_ || screencast_command_; |
1303 host_->SetTouchEventEmulationEnabled(enabled); | 1327 host_->SetTouchEventEmulationEnabled(enabled); |
1304 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 1328 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
1305 WebContents::FromRenderViewHost(host_)); | 1329 WebContents::FromRenderViewHost(host_)); |
1306 if (web_contents) | 1330 if (web_contents) |
1307 web_contents->SetForceDisableOverscrollContent(enabled); | 1331 web_contents->SetForceDisableOverscrollContent(enabled); |
1308 } | 1332 } |
1309 | 1333 |
1310 } // namespace content | 1334 } // namespace content |
OLD | NEW |