| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/protocol/page_handler.h" | 5 #include "content/browser/devtools/protocol/page_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "base/strings/string_number_conversions.h" | |
| 13 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/worker_pool.h" | 13 #include "base/threading/worker_pool.h" |
| 15 #include "content/browser/devtools/protocol/color_picker.h" | 14 #include "content/browser/devtools/protocol/color_picker.h" |
| 16 #include "content/browser/devtools/protocol/frame_recorder.h" | 15 #include "content/browser/devtools/protocol/frame_recorder.h" |
| 17 #include "content/browser/geolocation/geolocation_service_context.h" | |
| 18 #include "content/browser/renderer_host/render_view_host_impl.h" | 16 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 17 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 20 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
| 21 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
| 22 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/javascript_dialog_manager.h" | 21 #include "content/public/browser/javascript_dialog_manager.h" |
| 24 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
| 25 #include "content/public/browser/navigation_entry.h" | 23 #include "content/public/browser/navigation_entry.h" |
| 26 #include "content/public/browser/storage_partition.h" | 24 #include "content/public/browser/storage_partition.h" |
| 27 #include "content/public/browser/web_contents_delegate.h" | 25 #include "content/public/browser/web_contents_delegate.h" |
| 28 #include "content/public/common/referrer.h" | 26 #include "content/public/common/referrer.h" |
| 29 #include "content/public/common/url_constants.h" | |
| 30 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 27 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
| 31 #include "third_party/skia/include/core/SkBitmap.h" | 28 #include "third_party/skia/include/core/SkBitmap.h" |
| 32 #include "ui/base/page_transition_types.h" | 29 #include "ui/base/page_transition_types.h" |
| 33 #include "ui/gfx/codec/jpeg_codec.h" | 30 #include "ui/gfx/codec/jpeg_codec.h" |
| 34 #include "ui/gfx/codec/png_codec.h" | 31 #include "ui/gfx/codec/png_codec.h" |
| 35 #include "ui/gfx/geometry/size_conversions.h" | 32 #include "ui/gfx/geometry/size_conversions.h" |
| 36 #include "ui/snapshot/snapshot.h" | 33 #include "ui/snapshot/snapshot.h" |
| 37 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 38 | 35 |
| 39 namespace content { | 36 namespace content { |
| 40 namespace devtools { | 37 namespace devtools { |
| 41 namespace page { | 38 namespace page { |
| 42 | 39 |
| 43 namespace { | 40 namespace { |
| 44 | 41 |
| 45 static const char kPng[] = "png"; | 42 static const char kPng[] = "png"; |
| 46 static const char kJpeg[] = "jpeg"; | 43 static const char kJpeg[] = "jpeg"; |
| 47 static int kDefaultScreenshotQuality = 80; | 44 static int kDefaultScreenshotQuality = 80; |
| 48 static int kFrameRetryDelayMs = 100; | 45 static int kFrameRetryDelayMs = 100; |
| 49 static int kCaptureRetryLimit = 2; | 46 static int kCaptureRetryLimit = 2; |
| 50 static int kMaxScreencastFramesInFlight = 2; | 47 static int kMaxScreencastFramesInFlight = 2; |
| 51 | 48 |
| 52 ui::GestureProviderConfigType TouchEmulationConfigurationToType( | |
| 53 const std::string& protocol_value) { | |
| 54 ui::GestureProviderConfigType result = | |
| 55 ui::GestureProviderConfigType::CURRENT_PLATFORM; | |
| 56 if (protocol_value == "mobile") { | |
| 57 result = ui::GestureProviderConfigType::GENERIC_MOBILE; | |
| 58 } | |
| 59 if (protocol_value == "desktop") { | |
| 60 result = ui::GestureProviderConfigType::GENERIC_DESKTOP; | |
| 61 } | |
| 62 return result; | |
| 63 } | |
| 64 | |
| 65 std::string EncodeScreencastFrame(const SkBitmap& bitmap, | 49 std::string EncodeScreencastFrame(const SkBitmap& bitmap, |
| 66 const std::string& format, | 50 const std::string& format, |
| 67 int quality) { | 51 int quality) { |
| 68 std::vector<unsigned char> data; | 52 std::vector<unsigned char> data; |
| 69 SkAutoLockPixels lock_image(bitmap); | 53 SkAutoLockPixels lock_image(bitmap); |
| 70 bool encoded; | 54 bool encoded; |
| 71 if (format == kPng) { | 55 if (format == kPng) { |
| 72 encoded = gfx::PNGCodec::Encode( | 56 encoded = gfx::PNGCodec::Encode( |
| 73 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), | 57 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), |
| 74 gfx::PNGCodec::FORMAT_SkBitmap, | 58 gfx::PNGCodec::FORMAT_SkBitmap, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 97 | 81 |
| 98 return base_64_data; | 82 return base_64_data; |
| 99 } | 83 } |
| 100 | 84 |
| 101 } // namespace | 85 } // namespace |
| 102 | 86 |
| 103 typedef DevToolsProtocolClient::Response Response; | 87 typedef DevToolsProtocolClient::Response Response; |
| 104 | 88 |
| 105 PageHandler::PageHandler() | 89 PageHandler::PageHandler() |
| 106 : enabled_(false), | 90 : enabled_(false), |
| 107 touch_emulation_enabled_(false), | |
| 108 device_emulation_enabled_(false), | |
| 109 screencast_enabled_(false), | 91 screencast_enabled_(false), |
| 110 screencast_quality_(kDefaultScreenshotQuality), | 92 screencast_quality_(kDefaultScreenshotQuality), |
| 111 screencast_max_width_(-1), | 93 screencast_max_width_(-1), |
| 112 screencast_max_height_(-1), | 94 screencast_max_height_(-1), |
| 113 capture_retry_count_(0), | 95 capture_retry_count_(0), |
| 114 has_compositor_frame_metadata_(false), | 96 has_compositor_frame_metadata_(false), |
| 115 screencast_frame_sent_(0), | 97 screencast_frame_sent_(0), |
| 116 screencast_frame_acked_(0), | 98 screencast_frame_acked_(0), |
| 117 processing_screencast_frame_(false), | 99 processing_screencast_frame_(false), |
| 118 color_picker_(new ColorPicker(base::Bind( | 100 color_picker_(new ColorPicker(base::Bind( |
| 119 &PageHandler::OnColorPicked, base::Unretained(this)))), | 101 &PageHandler::OnColorPicked, base::Unretained(this)))), |
| 120 frame_recorder_(new FrameRecorder()), | 102 frame_recorder_(new FrameRecorder()), |
| 121 host_(nullptr), | 103 host_(nullptr), |
| 122 screencast_listener_(nullptr), | 104 screencast_listener_(nullptr), |
| 123 weak_factory_(this) { | 105 weak_factory_(this) { |
| 124 } | 106 } |
| 125 | 107 |
| 126 PageHandler::~PageHandler() { | 108 PageHandler::~PageHandler() { |
| 127 } | 109 } |
| 128 | 110 |
| 129 void PageHandler::SetRenderViewHost(RenderViewHostImpl* host) { | 111 void PageHandler::SetRenderViewHost(RenderViewHostImpl* host) { |
| 130 if (host_ == host) | 112 if (host_ == host) |
| 131 return; | 113 return; |
| 132 | 114 |
| 133 color_picker_->SetRenderViewHost(host); | 115 color_picker_->SetRenderViewHost(host); |
| 134 frame_recorder_->SetRenderViewHost(host); | 116 frame_recorder_->SetRenderViewHost(host); |
| 135 host_ = host; | 117 host_ = host; |
| 136 UpdateTouchEventEmulationState(); | |
| 137 UpdateDeviceEmulationState(); | |
| 138 } | 118 } |
| 139 | 119 |
| 140 void PageHandler::SetClient(scoped_ptr<Client> client) { | 120 void PageHandler::SetClient(scoped_ptr<Client> client) { |
| 141 client_.swap(client); | 121 client_.swap(client); |
| 142 } | 122 } |
| 143 | 123 |
| 144 void PageHandler::Detached() { | 124 void PageHandler::Detached() { |
| 145 Disable(); | 125 Disable(); |
| 146 } | 126 } |
| 147 | 127 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 screencast_listener_ = listener; | 160 screencast_listener_ = listener; |
| 181 } | 161 } |
| 182 | 162 |
| 183 Response PageHandler::Enable() { | 163 Response PageHandler::Enable() { |
| 184 enabled_ = true; | 164 enabled_ = true; |
| 185 return Response::FallThrough(); | 165 return Response::FallThrough(); |
| 186 } | 166 } |
| 187 | 167 |
| 188 Response PageHandler::Disable() { | 168 Response PageHandler::Disable() { |
| 189 enabled_ = false; | 169 enabled_ = false; |
| 190 touch_emulation_enabled_ = false; | |
| 191 screencast_enabled_ = false; | 170 screencast_enabled_ = false; |
| 192 device_emulation_enabled_ = false; | |
| 193 UpdateTouchEventEmulationState(); | |
| 194 UpdateDeviceEmulationState(); | |
| 195 color_picker_->SetEnabled(false); | 171 color_picker_->SetEnabled(false); |
| 196 if (screencast_listener_) | 172 if (screencast_listener_) |
| 197 screencast_listener_->ScreencastEnabledChanged(); | 173 screencast_listener_->ScreencastEnabledChanged(); |
| 198 return Response::FallThrough(); | 174 return Response::FallThrough(); |
| 199 } | 175 } |
| 200 | 176 |
| 201 Response PageHandler::Reload(const bool* ignoreCache, | 177 Response PageHandler::Reload(const bool* ignoreCache, |
| 202 const std::string* script_to_evaluate_on_load, | 178 const std::string* script_to_evaluate_on_load, |
| 203 const std::string* script_preprocessor) { | 179 const std::string* script_preprocessor) { |
| 204 if (!host_) | 180 if (!host_) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 for (int i = 0; i != controller.GetEntryCount(); ++i) { | 243 for (int i = 0; i != controller.GetEntryCount(); ++i) { |
| 268 if (controller.GetEntryAtIndex(i)->GetUniqueID() == entry_id) { | 244 if (controller.GetEntryAtIndex(i)->GetUniqueID() == entry_id) { |
| 269 controller.GoToIndex(i); | 245 controller.GoToIndex(i); |
| 270 return Response::OK(); | 246 return Response::OK(); |
| 271 } | 247 } |
| 272 } | 248 } |
| 273 | 249 |
| 274 return Response::InvalidParams("No entry with passed id"); | 250 return Response::InvalidParams("No entry with passed id"); |
| 275 } | 251 } |
| 276 | 252 |
| 277 Response PageHandler::SetGeolocationOverride(double* latitude, | |
| 278 double* longitude, | |
| 279 double* accuracy) { | |
| 280 if (!host_) | |
| 281 return Response::InternalError("Could not connect to view"); | |
| 282 | |
| 283 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | |
| 284 WebContents::FromRenderViewHost(host_)); | |
| 285 if (!web_contents) | |
| 286 return Response::InternalError("No WebContents to override"); | |
| 287 | |
| 288 GeolocationServiceContext* geolocation_context = | |
| 289 web_contents->GetGeolocationServiceContext(); | |
| 290 scoped_ptr<Geoposition> geoposition(new Geoposition()); | |
| 291 if (latitude && longitude && accuracy) { | |
| 292 geoposition->latitude = *latitude; | |
| 293 geoposition->longitude = *longitude; | |
| 294 geoposition->accuracy = *accuracy; | |
| 295 geoposition->timestamp = base::Time::Now(); | |
| 296 if (!geoposition->Validate()) { | |
| 297 return Response::InternalError("Invalid geolocation"); | |
| 298 } | |
| 299 } else { | |
| 300 geoposition->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; | |
| 301 } | |
| 302 geolocation_context->SetOverride(geoposition.Pass()); | |
| 303 return Response::OK(); | |
| 304 } | |
| 305 | |
| 306 Response PageHandler::ClearGeolocationOverride() { | |
| 307 if (!host_) | |
| 308 return Response::InternalError("Could not connect to view"); | |
| 309 | |
| 310 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | |
| 311 WebContents::FromRenderViewHost(host_)); | |
| 312 if (!web_contents) | |
| 313 return Response::InternalError("No WebContents to override"); | |
| 314 | |
| 315 GeolocationServiceContext* geolocation_context = | |
| 316 web_contents->GetGeolocationServiceContext(); | |
| 317 geolocation_context->ClearOverride(); | |
| 318 return Response::OK(); | |
| 319 } | |
| 320 | |
| 321 Response PageHandler::SetTouchEmulationEnabled( | |
| 322 bool enabled, const std::string* configuration) { | |
| 323 touch_emulation_enabled_ = enabled; | |
| 324 touch_emulation_configuration_ = | |
| 325 configuration ? *configuration : std::string(); | |
| 326 UpdateTouchEventEmulationState(); | |
| 327 return Response::FallThrough(); | |
| 328 } | |
| 329 | |
| 330 Response PageHandler::CaptureScreenshot(DevToolsCommandId command_id) { | 253 Response PageHandler::CaptureScreenshot(DevToolsCommandId command_id) { |
| 331 if (!host_ || !host_->GetView()) | 254 if (!host_ || !host_->GetView()) |
| 332 return Response::InternalError("Could not connect to view"); | 255 return Response::InternalError("Could not connect to view"); |
| 333 | 256 |
| 334 host_->GetSnapshotFromBrowser( | 257 host_->GetSnapshotFromBrowser( |
| 335 base::Bind(&PageHandler::ScreenshotCaptured, | 258 base::Bind(&PageHandler::ScreenshotCaptured, |
| 336 weak_factory_.GetWeakPtr(), command_id)); | 259 weak_factory_.GetWeakPtr(), command_id)); |
| 337 return Response::OK(); | 260 return Response::OK(); |
| 338 } | 261 } |
| 339 | 262 |
| 340 Response PageHandler::CanScreencast(bool* result) { | 263 Response PageHandler::CanScreencast(bool* result) { |
| 341 #if defined(OS_ANDROID) | 264 #if defined(OS_ANDROID) |
| 342 *result = true; | 265 *result = true; |
| 343 #else | 266 #else |
| 344 *result = false; | 267 *result = false; |
| 345 #endif // defined(OS_ANDROID) | 268 #endif // defined(OS_ANDROID) |
| 346 return Response::OK(); | 269 return Response::OK(); |
| 347 } | 270 } |
| 348 | 271 |
| 349 Response PageHandler::CanEmulate(bool* result) { | |
| 350 #if defined(OS_ANDROID) | |
| 351 *result = false; | |
| 352 #else | |
| 353 if (host_) { | |
| 354 if (WebContents* web_contents = WebContents::FromRenderViewHost(host_)) { | |
| 355 *result = web_contents->GetMainFrame()->GetRenderViewHost() == host_; | |
| 356 #if defined(DEBUG_DEVTOOLS) | |
| 357 *result &= !web_contents->GetVisibleURL().SchemeIs(kChromeDevToolsScheme); | |
| 358 #endif // defined(DEBUG_DEVTOOLS) | |
| 359 } else { | |
| 360 *result = true; | |
| 361 } | |
| 362 } else { | |
| 363 *result = true; | |
| 364 } | |
| 365 #endif // defined(OS_ANDROID) | |
| 366 return Response::OK(); | |
| 367 } | |
| 368 | |
| 369 Response PageHandler::SetDeviceMetricsOverride( | |
| 370 int width, int height, double device_scale_factor, bool mobile, | |
| 371 bool fit_window, const double* optional_scale, | |
| 372 const double* optional_offset_x, const double* optional_offset_y) { | |
| 373 const static int max_size = 10000000; | |
| 374 const static double max_scale = 10; | |
| 375 | |
| 376 if (!host_) | |
| 377 return Response::InternalError("Could not connect to view"); | |
| 378 | |
| 379 if (width < 0 || height < 0 || width > max_size || height > max_size) { | |
| 380 return Response::InvalidParams( | |
| 381 "Width and height values must be positive, not greater than " + | |
| 382 base::IntToString(max_size)); | |
| 383 } | |
| 384 | |
| 385 if (device_scale_factor < 0) | |
| 386 return Response::InvalidParams("deviceScaleFactor must be non-negative"); | |
| 387 | |
| 388 if (optional_scale && (*optional_scale <= 0 || *optional_scale > max_scale)) { | |
| 389 return Response::InvalidParams( | |
| 390 "scale must be positive, not greater than " + | |
| 391 base::IntToString(max_scale)); | |
| 392 } | |
| 393 | |
| 394 blink::WebDeviceEmulationParams params; | |
| 395 params.screenPosition = mobile ? blink::WebDeviceEmulationParams::Mobile : | |
| 396 blink::WebDeviceEmulationParams::Desktop; | |
| 397 params.deviceScaleFactor = device_scale_factor; | |
| 398 params.viewSize = blink::WebSize(width, height); | |
| 399 params.fitToView = fit_window; | |
| 400 params.scale = optional_scale ? *optional_scale : 1; | |
| 401 params.offset = blink::WebFloatPoint( | |
| 402 optional_offset_x ? *optional_offset_x : 0.f, | |
| 403 optional_offset_y ? *optional_offset_y : 0.f); | |
| 404 | |
| 405 if (device_emulation_enabled_ && params == device_emulation_params_) | |
| 406 return Response::OK(); | |
| 407 | |
| 408 device_emulation_enabled_ = true; | |
| 409 device_emulation_params_ = params; | |
| 410 UpdateDeviceEmulationState(); | |
| 411 return Response::OK(); | |
| 412 } | |
| 413 | |
| 414 Response PageHandler::ClearDeviceMetricsOverride() { | |
| 415 if (!device_emulation_enabled_) | |
| 416 return Response::OK(); | |
| 417 | |
| 418 device_emulation_enabled_ = false; | |
| 419 UpdateDeviceEmulationState(); | |
| 420 return Response::OK(); | |
| 421 } | |
| 422 | |
| 423 Response PageHandler::StartScreencast(const std::string* format, | 272 Response PageHandler::StartScreencast(const std::string* format, |
| 424 const int* quality, | 273 const int* quality, |
| 425 const int* max_width, | 274 const int* max_width, |
| 426 const int* max_height) { | 275 const int* max_height) { |
| 427 if (!host_) | 276 if (!host_) |
| 428 return Response::InternalError("Could not connect to view"); | 277 return Response::InternalError("Could not connect to view"); |
| 429 | 278 |
| 430 screencast_enabled_ = true; | 279 screencast_enabled_ = true; |
| 431 screencast_format_ = format ? *format : kPng; | 280 screencast_format_ = format ? *format : kPng; |
| 432 screencast_quality_ = quality ? *quality : kDefaultScreenshotQuality; | 281 screencast_quality_ = quality ? *quality : kDefaultScreenshotQuality; |
| 433 if (screencast_quality_ < 0 || screencast_quality_ > 100) | 282 if (screencast_quality_ < 0 || screencast_quality_ > 100) |
| 434 screencast_quality_ = kDefaultScreenshotQuality; | 283 screencast_quality_ = kDefaultScreenshotQuality; |
| 435 screencast_max_width_ = max_width ? *max_width : -1; | 284 screencast_max_width_ = max_width ? *max_width : -1; |
| 436 screencast_max_height_ = max_height ? *max_height : -1; | 285 screencast_max_height_ = max_height ? *max_height : -1; |
| 437 | 286 |
| 438 UpdateTouchEventEmulationState(); | |
| 439 bool visible = !host_->is_hidden(); | 287 bool visible = !host_->is_hidden(); |
| 440 NotifyScreencastVisibility(visible); | 288 NotifyScreencastVisibility(visible); |
| 441 if (visible) { | 289 if (visible) { |
| 442 if (has_compositor_frame_metadata_) | 290 if (has_compositor_frame_metadata_) |
| 443 InnerSwapCompositorFrame(); | 291 InnerSwapCompositorFrame(); |
| 444 else | 292 else |
| 445 host_->Send(new ViewMsg_ForceRedraw(host_->GetRoutingID(), 0)); | 293 host_->Send(new ViewMsg_ForceRedraw(host_->GetRoutingID(), 0)); |
| 446 } | 294 } |
| 447 if (screencast_listener_) | 295 if (screencast_listener_) |
| 448 screencast_listener_->ScreencastEnabledChanged(); | 296 screencast_listener_->ScreencastEnabledChanged(); |
| 449 return Response::FallThrough(); | 297 return Response::FallThrough(); |
| 450 } | 298 } |
| 451 | 299 |
| 452 Response PageHandler::StopScreencast() { | 300 Response PageHandler::StopScreencast() { |
| 453 screencast_enabled_ = false; | 301 screencast_enabled_ = false; |
| 454 UpdateTouchEventEmulationState(); | |
| 455 if (screencast_listener_) | 302 if (screencast_listener_) |
| 456 screencast_listener_->ScreencastEnabledChanged(); | 303 screencast_listener_->ScreencastEnabledChanged(); |
| 457 return Response::FallThrough(); | 304 return Response::FallThrough(); |
| 458 } | 305 } |
| 459 | 306 |
| 460 Response PageHandler::StartRecordingFrames(int max_frame_count) { | 307 Response PageHandler::StartRecordingFrames(int max_frame_count) { |
| 461 return frame_recorder_->StartRecordingFrames(max_frame_count); | 308 return frame_recorder_->StartRecordingFrames(max_frame_count); |
| 462 } | 309 } |
| 463 | 310 |
| 464 Response PageHandler::StopRecordingFrames(DevToolsCommandId command_id) { | 311 Response PageHandler::StopRecordingFrames(DevToolsCommandId command_id) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 } | 351 } |
| 505 | 352 |
| 506 Response PageHandler::SetColorPickerEnabled(bool enabled) { | 353 Response PageHandler::SetColorPickerEnabled(bool enabled) { |
| 507 if (!host_) | 354 if (!host_) |
| 508 return Response::InternalError("Could not connect to view"); | 355 return Response::InternalError("Could not connect to view"); |
| 509 | 356 |
| 510 color_picker_->SetEnabled(enabled); | 357 color_picker_->SetEnabled(enabled); |
| 511 return Response::OK(); | 358 return Response::OK(); |
| 512 } | 359 } |
| 513 | 360 |
| 514 void PageHandler::UpdateTouchEventEmulationState() { | |
| 515 if (!host_) | |
| 516 return; | |
| 517 bool enabled = touch_emulation_enabled_ || screencast_enabled_; | |
| 518 ui::GestureProviderConfigType config_type = | |
| 519 TouchEmulationConfigurationToType(touch_emulation_configuration_); | |
| 520 host_->SetTouchEventEmulationEnabled(enabled, config_type); | |
| 521 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | |
| 522 WebContents::FromRenderViewHost(host_)); | |
| 523 if (web_contents) | |
| 524 web_contents->SetForceDisableOverscrollContent(enabled); | |
| 525 } | |
| 526 | |
| 527 void PageHandler::UpdateDeviceEmulationState() { | |
| 528 if (!host_) | |
| 529 return; | |
| 530 if (device_emulation_enabled_) { | |
| 531 host_->Send(new ViewMsg_EnableDeviceEmulation( | |
| 532 host_->GetRoutingID(), device_emulation_params_)); | |
| 533 } else { | |
| 534 host_->Send(new ViewMsg_DisableDeviceEmulation(host_->GetRoutingID())); | |
| 535 } | |
| 536 } | |
| 537 | |
| 538 void PageHandler::NotifyScreencastVisibility(bool visible) { | 361 void PageHandler::NotifyScreencastVisibility(bool visible) { |
| 539 if (visible) | 362 if (visible) |
| 540 capture_retry_count_ = kCaptureRetryLimit; | 363 capture_retry_count_ = kCaptureRetryLimit; |
| 541 client_->ScreencastVisibilityChanged( | 364 client_->ScreencastVisibilityChanged( |
| 542 ScreencastVisibilityChangedParams::Create()->set_visible(visible)); | 365 ScreencastVisibilityChangedParams::Create()->set_visible(visible)); |
| 543 } | 366 } |
| 544 | 367 |
| 545 void PageHandler::InnerSwapCompositorFrame() { | 368 void PageHandler::InnerSwapCompositorFrame() { |
| 546 if (screencast_frame_sent_ - screencast_frame_acked_ > | 369 if (screencast_frame_sent_ - screencast_frame_acked_ > |
| 547 kMaxScreencastFramesInFlight || processing_screencast_frame_) { | 370 kMaxScreencastFramesInFlight || processing_screencast_frame_) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 | 500 |
| 678 void PageHandler::OnFramesRecorded( | 501 void PageHandler::OnFramesRecorded( |
| 679 DevToolsCommandId command_id, | 502 DevToolsCommandId command_id, |
| 680 scoped_refptr<StopRecordingFramesResponse> response_data) { | 503 scoped_refptr<StopRecordingFramesResponse> response_data) { |
| 681 client_->SendStopRecordingFramesResponse(command_id, response_data); | 504 client_->SendStopRecordingFramesResponse(command_id, response_data); |
| 682 } | 505 } |
| 683 | 506 |
| 684 } // namespace page | 507 } // namespace page |
| 685 } // namespace devtools | 508 } // namespace devtools |
| 686 } // namespace content | 509 } // namespace content |
| OLD | NEW |