Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: content/browser/devtools/protocol/page_handler.cc

Issue 1014403002: [DevTools] Emulation domain implementation (browser side). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nullptr Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 screencast_max_height_(-1), 114 screencast_max_height_(-1),
115 capture_retry_count_(0), 115 capture_retry_count_(0),
116 has_compositor_frame_metadata_(false), 116 has_compositor_frame_metadata_(false),
117 screencast_frame_sent_(0), 117 screencast_frame_sent_(0),
118 screencast_frame_acked_(0), 118 screencast_frame_acked_(0),
119 processing_screencast_frame_(false), 119 processing_screencast_frame_(false),
120 color_picker_(new ColorPicker(base::Bind( 120 color_picker_(new ColorPicker(base::Bind(
121 &PageHandler::OnColorPicked, base::Unretained(this)))), 121 &PageHandler::OnColorPicked, base::Unretained(this)))),
122 frame_recorder_(new FrameRecorder()), 122 frame_recorder_(new FrameRecorder()),
123 host_(nullptr), 123 host_(nullptr),
124 screencast_listener_(nullptr),
124 weak_factory_(this) { 125 weak_factory_(this) {
125 } 126 }
126 127
127 PageHandler::~PageHandler() { 128 PageHandler::~PageHandler() {
128 } 129 }
129 130
130 void PageHandler::SetRenderViewHost(RenderViewHostImpl* host) { 131 void PageHandler::SetRenderViewHost(RenderViewHostImpl* host) {
131 if (host_ == host) 132 if (host_ == host)
132 return; 133 return;
133 134
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return; 171 return;
171 client_->InterstitialShown(InterstitialShownParams::Create()); 172 client_->InterstitialShown(InterstitialShownParams::Create());
172 } 173 }
173 174
174 void PageHandler::DidDetachInterstitialPage() { 175 void PageHandler::DidDetachInterstitialPage() {
175 if (!enabled_) 176 if (!enabled_)
176 return; 177 return;
177 client_->InterstitialHidden(InterstitialHiddenParams::Create()); 178 client_->InterstitialHidden(InterstitialHiddenParams::Create());
178 } 179 }
179 180
181 void PageHandler::SetScreencastListener(ScreencastListener* listener) {
182 screencast_listener_ = listener;
183 }
184
180 Response PageHandler::Enable() { 185 Response PageHandler::Enable() {
181 enabled_ = true; 186 enabled_ = true;
182 return Response::FallThrough(); 187 return Response::FallThrough();
183 } 188 }
184 189
185 Response PageHandler::Disable() { 190 Response PageHandler::Disable() {
186 enabled_ = false; 191 enabled_ = false;
187 touch_emulation_enabled_ = false; 192 touch_emulation_enabled_ = false;
188 screencast_enabled_ = false; 193 screencast_enabled_ = false;
189 device_emulation_enabled_ = false; 194 device_emulation_enabled_ = false;
190 UpdateTouchEventEmulationState(); 195 UpdateTouchEventEmulationState();
191 UpdateDeviceEmulationState(); 196 UpdateDeviceEmulationState();
192 color_picker_->SetEnabled(false); 197 color_picker_->SetEnabled(false);
198 if (screencast_listener_)
199 screencast_listener_->ScreencastEnabledChanged();
193 return Response::FallThrough(); 200 return Response::FallThrough();
194 } 201 }
195 202
196 Response PageHandler::Reload(const bool* ignoreCache, 203 Response PageHandler::Reload(const bool* ignoreCache,
197 const std::string* script_to_evaluate_on_load, 204 const std::string* script_to_evaluate_on_load,
198 const std::string* script_preprocessor) { 205 const std::string* script_preprocessor) {
199 if (!host_) 206 if (!host_)
200 return Response::InternalError("Could not connect to view"); 207 return Response::InternalError("Could not connect to view");
201 208
202 WebContents* web_contents = WebContents::FromRenderViewHost(host_); 209 WebContents* web_contents = WebContents::FromRenderViewHost(host_);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 439
433 UpdateTouchEventEmulationState(); 440 UpdateTouchEventEmulationState();
434 bool visible = !host_->is_hidden(); 441 bool visible = !host_->is_hidden();
435 NotifyScreencastVisibility(visible); 442 NotifyScreencastVisibility(visible);
436 if (visible) { 443 if (visible) {
437 if (has_compositor_frame_metadata_) 444 if (has_compositor_frame_metadata_)
438 InnerSwapCompositorFrame(); 445 InnerSwapCompositorFrame();
439 else 446 else
440 host_->Send(new ViewMsg_ForceRedraw(host_->GetRoutingID(), 0)); 447 host_->Send(new ViewMsg_ForceRedraw(host_->GetRoutingID(), 0));
441 } 448 }
449 if (screencast_listener_)
450 screencast_listener_->ScreencastEnabledChanged();
442 return Response::FallThrough(); 451 return Response::FallThrough();
443 } 452 }
444 453
445 Response PageHandler::StopScreencast() { 454 Response PageHandler::StopScreencast() {
446 screencast_enabled_ = false; 455 screencast_enabled_ = false;
447 UpdateTouchEventEmulationState(); 456 UpdateTouchEventEmulationState();
457 if (screencast_listener_)
458 screencast_listener_->ScreencastEnabledChanged();
448 return Response::FallThrough(); 459 return Response::FallThrough();
449 } 460 }
450 461
451 Response PageHandler::StartRecordingFrames(int max_frame_count) { 462 Response PageHandler::StartRecordingFrames(int max_frame_count) {
452 return frame_recorder_->StartRecordingFrames(max_frame_count); 463 return frame_recorder_->StartRecordingFrames(max_frame_count);
453 } 464 }
454 465
455 Response PageHandler::StopRecordingFrames(DevToolsCommandId command_id) { 466 Response PageHandler::StopRecordingFrames(DevToolsCommandId command_id) {
456 return frame_recorder_->StopRecordingFrames(base::Bind( 467 return frame_recorder_->StopRecordingFrames(base::Bind(
457 &PageHandler::OnFramesRecorded, base::Unretained(this), command_id)); 468 &PageHandler::OnFramesRecorded, base::Unretained(this), command_id));
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 679
669 void PageHandler::OnFramesRecorded( 680 void PageHandler::OnFramesRecorded(
670 DevToolsCommandId command_id, 681 DevToolsCommandId command_id,
671 scoped_refptr<StopRecordingFramesResponse> response_data) { 682 scoped_refptr<StopRecordingFramesResponse> response_data) {
672 client_->SendStopRecordingFramesResponse(command_id, response_data); 683 client_->SendStopRecordingFramesResponse(command_id, response_data);
673 } 684 }
674 685
675 } // namespace page 686 } // namespace page
676 } // namespace devtools 687 } // namespace devtools
677 } // namespace content 688 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/page_handler.h ('k') | content/browser/devtools/render_frame_devtools_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698