| 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/location.h" | 11 #include "base/location.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "base/threading/worker_pool.h" | 16 #include "base/threading/worker_pool.h" |
| 17 #include "content/browser/devtools/devtools_session.h" |
| 17 #include "content/browser/devtools/page_navigation_throttle.h" | 18 #include "content/browser/devtools/page_navigation_throttle.h" |
| 18 #include "content/browser/devtools/protocol/color_picker.h" | 19 #include "content/browser/devtools/protocol/color_picker.h" |
| 19 #include "content/browser/renderer_host/render_widget_host_impl.h" | 20 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 20 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 21 #include "content/browser/web_contents/web_contents_impl.h" | 22 #include "content/browser/web_contents/web_contents_impl.h" |
| 22 #include "content/browser/web_contents/web_contents_view.h" | 23 #include "content/browser/web_contents/web_contents_view.h" |
| 23 #include "content/common/view_messages.h" | 24 #include "content/common/view_messages.h" |
| 24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/javascript_dialog_manager.h" | 26 #include "content/public/browser/javascript_dialog_manager.h" |
| 26 #include "content/public/browser/navigation_controller.h" | 27 #include "content/public/browser/navigation_controller.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 base::Base64Encode( | 84 base::Base64Encode( |
| 84 base::StringPiece(reinterpret_cast<char*>(&data[0]), data.size()), | 85 base::StringPiece(reinterpret_cast<char*>(&data[0]), data.size()), |
| 85 &base_64_data); | 86 &base_64_data); |
| 86 | 87 |
| 87 return base_64_data; | 88 return base_64_data; |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace | 91 } // namespace |
| 91 | 92 |
| 92 PageHandler::PageHandler() | 93 PageHandler::PageHandler() |
| 93 : enabled_(false), | 94 : DevToolsDomainHandler(Page::Metainfo::domainName), |
| 95 enabled_(false), |
| 94 screencast_enabled_(false), | 96 screencast_enabled_(false), |
| 95 screencast_quality_(kDefaultScreenshotQuality), | 97 screencast_quality_(kDefaultScreenshotQuality), |
| 96 screencast_max_width_(-1), | 98 screencast_max_width_(-1), |
| 97 screencast_max_height_(-1), | 99 screencast_max_height_(-1), |
| 98 capture_every_nth_frame_(1), | 100 capture_every_nth_frame_(1), |
| 99 capture_retry_count_(0), | 101 capture_retry_count_(0), |
| 100 has_compositor_frame_metadata_(false), | 102 has_compositor_frame_metadata_(false), |
| 101 session_id_(0), | 103 session_id_(0), |
| 102 frame_counter_(0), | 104 frame_counter_(0), |
| 103 frames_in_flight_(0), | 105 frames_in_flight_(0), |
| 104 color_picker_(new ColorPicker( | 106 color_picker_(new ColorPicker( |
| 105 base::Bind(&PageHandler::OnColorPicked, base::Unretained(this)))), | 107 base::Bind(&PageHandler::OnColorPicked, base::Unretained(this)))), |
| 106 navigation_throttle_enabled_(false), | 108 navigation_throttle_enabled_(false), |
| 107 next_navigation_id_(0), | 109 next_navigation_id_(0), |
| 108 host_(nullptr), | 110 host_(nullptr), |
| 109 weak_factory_(this) {} | 111 weak_factory_(this) {} |
| 110 | 112 |
| 111 PageHandler::~PageHandler() { | 113 PageHandler::~PageHandler() { |
| 112 } | 114 } |
| 113 | 115 |
| 116 // static |
| 117 PageHandler* PageHandler::FromSession(DevToolsSession* session) { |
| 118 return static_cast<PageHandler*>( |
| 119 session->GetHandlerByName(Page::Metainfo::domainName)); |
| 120 } |
| 121 |
| 114 void PageHandler::SetRenderFrameHost(RenderFrameHostImpl* host) { | 122 void PageHandler::SetRenderFrameHost(RenderFrameHostImpl* host) { |
| 115 if (host_ == host) | 123 if (host_ == host) |
| 116 return; | 124 return; |
| 117 | 125 |
| 118 RenderWidgetHostImpl* widget_host = | 126 RenderWidgetHostImpl* widget_host = |
| 119 host_ ? host_->GetRenderWidgetHost() : nullptr; | 127 host_ ? host_->GetRenderWidgetHost() : nullptr; |
| 120 if (widget_host) { | 128 if (widget_host) { |
| 121 registrar_.Remove( | 129 registrar_.Remove( |
| 122 this, | 130 this, |
| 123 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, | 131 content::NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 Response PageHandler::StopLoading() { | 582 Response PageHandler::StopLoading() { |
| 575 WebContentsImpl* web_contents = GetWebContents(); | 583 WebContentsImpl* web_contents = GetWebContents(); |
| 576 if (!web_contents) | 584 if (!web_contents) |
| 577 return Response::InternalError(); | 585 return Response::InternalError(); |
| 578 web_contents->Stop(); | 586 web_contents->Stop(); |
| 579 return Response::OK(); | 587 return Response::OK(); |
| 580 } | 588 } |
| 581 | 589 |
| 582 } // namespace protocol | 590 } // namespace protocol |
| 583 } // namespace content | 591 } // namespace content |
| OLD | NEW |