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 <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/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "content/browser/child_process_security_policy_impl.h" | 15 #include "content/browser/child_process_security_policy_impl.h" |
16 #include "content/browser/devtools/devtools_protocol_constants.h" | 16 #include "content/browser/devtools/devtools_protocol_constants.h" |
17 #include "content/browser/devtools/devtools_tracing_handler.h" | 17 #include "content/browser/devtools/devtools_tracing_handler.h" |
18 #include "content/browser/renderer_host/render_view_host_delegate.h" | 18 #include "content/browser/renderer_host/render_view_host_delegate.h" |
19 #include "content/port/browser/render_view_host_delegate_view.h" | |
19 #include "content/public/browser/devtools_agent_host.h" | 20 #include "content/public/browser/devtools_agent_host.h" |
20 #include "content/public/browser/javascript_dialog_manager.h" | 21 #include "content/public/browser/javascript_dialog_manager.h" |
21 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
22 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
23 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
24 #include "content/public/browser/render_widget_host_view.h" | 25 #include "content/public/browser/render_widget_host_view.h" |
25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
26 #include "content/public/browser/web_contents_delegate.h" | 27 #include "content/public/browser/web_contents_delegate.h" |
27 #include "content/public/common/page_transition_types.h" | 28 #include "content/public/common/page_transition_types.h" |
28 #include "content/public/common/referrer.h" | 29 #include "content/public/common/referrer.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 response->SetString( | 148 response->SetString( |
148 devtools::Page::captureScreenshot::kResponseData, base_64_data); | 149 devtools::Page::captureScreenshot::kResponseData, base_64_data); |
149 return command->SuccessResponse(response); | 150 return command->SuccessResponse(response); |
150 } | 151 } |
151 | 152 |
152 bool RendererOverridesHandler::CaptureScreenshot(std::string* base_64_data) { | 153 bool RendererOverridesHandler::CaptureScreenshot(std::string* base_64_data) { |
153 RenderViewHost* host = agent_->GetRenderViewHost(); | 154 RenderViewHost* host = agent_->GetRenderViewHost(); |
154 gfx::Rect view_bounds = host->GetView()->GetViewBounds(); | 155 gfx::Rect view_bounds = host->GetView()->GetViewBounds(); |
155 gfx::Rect snapshot_bounds(view_bounds.size()); | 156 gfx::Rect snapshot_bounds(view_bounds.size()); |
156 gfx::Size snapshot_size = snapshot_bounds.size(); | 157 gfx::Size snapshot_size = snapshot_bounds.size(); |
157 std::vector<unsigned char> png; | 158 RenderViewHostDelegate* delegate = host->GetDelegate(); |
158 if (!ui::GrabViewSnapshot(host->GetView()->GetNativeView(), | 159 RenderViewHostDelegateView* view = delegate->GetDelegateView(); |
159 &png, | 160 if (!view) |
160 snapshot_bounds)) | 161 return false; |
162 | |
163 std::vector<unsigned uint8> png; | |
Sami
2013/08/02 10:53:23
No "unsigned" here either.
pfeldman
2013/08/02 12:25:30
Done.
| |
164 if (!view->GrabSnapshot(&png)) | |
161 return false; | 165 return false; |
162 | 166 |
163 return base::Base64Encode(base::StringPiece( | 167 return base::Base64Encode(base::StringPiece( |
164 reinterpret_cast<char*>(&*png.begin()), | 168 reinterpret_cast<char*>(&*png.begin()), |
165 png.size()), | 169 png.size()), |
166 base_64_data); | 170 base_64_data); |
167 } | 171 } |
168 | 172 |
169 } // namespace content | 173 } // namespace content |
OLD | NEW |