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

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

Issue 508973003: DevTools: Protocol handler generator for content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Style fix Created 6 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/devtools/protocol/page_handler.h"
6
7 #include "base/base64.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h"
9
10 namespace content {
11 namespace devtools {
12 namespace page {
13
14 typedef DevToolsProtocolFrontend::Response Response;
15
16 PageHandler::PageHandler()
17 : weak_factory_(this) {
18 }
19
20 PageHandler::~PageHandler() {
21 }
22
23 void PageHandler::OnClientDetached() {
24 }
25
26 void PageHandler::SetRenderViewHost(RenderViewHostImpl* host) {
27 host_ = host;
28 }
29
30 void PageHandler::SetFrontend(scoped_ptr<Frontend> frontend) {
31 frontend_.swap(frontend);
32 }
33
34 Response PageHandler::Enable() {
35 return Response::FallThrough();
36 }
37
38 Response PageHandler::Disable() {
39 return Response::FallThrough();
40 }
41
42 Response PageHandler::Reload(const bool* ignoreCache,
43 const std::string* script_to_evaluate_on_load,
44 const std::string* script_preprocessor) {
45 return Response::FallThrough();
46 }
47
48 Response PageHandler::Navigate(const std::string& url,
49 FrameId* frame_id) {
50 return Response::FallThrough();
51 }
52
53 Response PageHandler::GetNavigationHistory(
54 int* current_index,
55 std::vector<NavigationEntry>* entries) {
56 return Response::FallThrough();
57 }
58
59 Response PageHandler::NavigateToHistoryEntry(int entry_id) {
60 return Response::FallThrough();
61 }
62
63 Response PageHandler::SetTouchEmulationEnabled(bool enabled) {
64 return Response::FallThrough();
65 }
66
67 scoped_refptr<DevToolsProtocol::Response> PageHandler::CaptureScreenshot(
68 scoped_refptr<DevToolsProtocol::Command> command) {
69 if (!host_ || !host_->GetView())
70 return command->InternalErrorResponse("Could not connect to view");
71
72 host_->GetSnapshotFromBrowser(
73 base::Bind(&PageHandler::ScreenshotCaptured,
74 weak_factory_.GetWeakPtr(), command));
75 return command->AsyncResponsePromise();
76 }
77
78 Response PageHandler::CanScreencast(bool* result) {
79 return Response::FallThrough();
80 }
81
82 Response PageHandler::CanEmulate(bool* result) {
83 return Response::FallThrough();
84 }
85
86 Response PageHandler::StartScreencast(const std::string* format,
87 const int* quality,
88 const int* max_width,
89 const int* max_height) {
90 return Response::FallThrough();
91 }
92
93 Response PageHandler::StopScreencast() {
94 return Response::FallThrough();
95 }
96
97 Response PageHandler::HandleJavaScriptDialog(bool accept,
98 const std::string* prompt_text) {
99 return Response::FallThrough();
100 }
101
102 scoped_refptr<DevToolsProtocol::Response> PageHandler::QueryUsageAndQuota(
103 const std::string& security_origin,
104 scoped_refptr<DevToolsProtocol::Command> command) {
105 return NULL;
106 }
107
108 Response PageHandler::SetColorPickerEnabled(bool enabled) {
109 return Response::FallThrough();
110 }
111
112 void PageHandler::ScreenshotCaptured(
113 scoped_refptr<DevToolsProtocol::Command> command,
114 const unsigned char* png_data,
115 size_t png_size) {
116 if (!png_data || !png_size) {
117 frontend_->SendInternalErrorResponse(command,
118 "Unable to capture screenshot");
119 return;
120 }
121
122 std::string base_64_data;
123 base::Base64Encode(
124 base::StringPiece(reinterpret_cast<const char*>(png_data), png_size),
125 &base_64_data);
126
127 CaptureScreenshotResponse response;
128 response.set_data(base_64_data);
129 frontend_->SendCaptureScreenshotResponse(command, response);
130 }
131
132
133 } // namespace page
134 } // namespace devtools
135 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698