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

Side by Side Diff: extensions/browser/api/guest_view/web_view/web_view_internal_api.cc

Issue 1863953002: <webview>: Fix missing transparency in captureVisibleRegion(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build break Created 4 years, 8 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 "extensions/browser/api/guest_view/web_view/web_view_internal_api.h" 5 #include "extensions/browser/api/guest_view/web_view/web_view_internal_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 int instance_id = 0; 251 int instance_id = 0;
252 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id)); 252 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &instance_id));
253 WebViewGuest* guest = WebViewGuest::From( 253 WebViewGuest* guest = WebViewGuest::From(
254 render_frame_host()->GetProcess()->GetID(), instance_id); 254 render_frame_host()->GetProcess()->GetID(), instance_id);
255 if (!guest) 255 if (!guest)
256 return false; 256 return false;
257 257
258 return RunAsyncSafe(guest); 258 return RunAsyncSafe(guest);
259 } 259 }
260 260
261 WebViewInternalCaptureVisibleRegionFunction::
262 WebViewInternalCaptureVisibleRegionFunction()
263 : is_guest_transparent_(false) {}
264
261 bool WebViewInternalCaptureVisibleRegionFunction::RunAsyncSafe( 265 bool WebViewInternalCaptureVisibleRegionFunction::RunAsyncSafe(
262 WebViewGuest* guest) { 266 WebViewGuest* guest) {
263 using api::extension_types::ImageDetails; 267 using api::extension_types::ImageDetails;
264 268
265 scoped_ptr<web_view_internal::CaptureVisibleRegion::Params> params( 269 scoped_ptr<web_view_internal::CaptureVisibleRegion::Params> params(
266 web_view_internal::CaptureVisibleRegion::Params::Create(*args_)); 270 web_view_internal::CaptureVisibleRegion::Params::Create(*args_));
267 EXTENSION_FUNCTION_VALIDATE(params.get()); 271 EXTENSION_FUNCTION_VALIDATE(params.get());
268 272
269 scoped_ptr<ImageDetails> image_details; 273 scoped_ptr<ImageDetails> image_details;
270 if (args_->GetSize() > 1) { 274 if (args_->GetSize() > 1) {
271 base::Value* spec = NULL; 275 base::Value* spec = NULL;
272 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); 276 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec);
273 image_details = ImageDetails::FromValue(*spec); 277 image_details = ImageDetails::FromValue(*spec);
274 } 278 }
275 279
280 is_guest_transparent_ = guest->allow_transparency();
276 return CaptureAsync(guest->web_contents(), image_details.get(), 281 return CaptureAsync(guest->web_contents(), image_details.get(),
277 base::Bind(&WebViewInternalCaptureVisibleRegionFunction:: 282 base::Bind(&WebViewInternalCaptureVisibleRegionFunction::
278 CopyFromBackingStoreComplete, 283 CopyFromBackingStoreComplete,
279 this)); 284 this));
280 } 285 }
281 bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() { 286 bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() {
282 // TODO(wjmaclean): Is it ok to always return true here? 287 // TODO(wjmaclean): Is it ok to always return true here?
283 return true; 288 return true;
284 } 289 }
285 290
291 bool WebViewInternalCaptureVisibleRegionFunction::ClientAllowsTransparency() {
292 return is_guest_transparent_;
293 }
294
286 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureSuccess( 295 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureSuccess(
287 const SkBitmap& bitmap) { 296 const SkBitmap& bitmap) {
288 std::string base64_result; 297 std::string base64_result;
289 if (!EncodeBitmap(bitmap, &base64_result)) { 298 if (!EncodeBitmap(bitmap, &base64_result)) {
290 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); 299 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED);
291 return; 300 return;
292 } 301 }
293 302
294 SetResult(new base::StringValue(base64_result)); 303 SetResult(new base::StringValue(base64_result));
295 SendResponse(true); 304 SendResponse(true);
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 // Will finish asynchronously. 960 // Will finish asynchronously.
952 return true; 961 return true;
953 } 962 }
954 963
955 void WebViewInternalClearDataFunction::ClearDataDone() { 964 void WebViewInternalClearDataFunction::ClearDataDone() {
956 Release(); // Balanced in RunAsync(). 965 Release(); // Balanced in RunAsync().
957 SendResponse(true); 966 SendResponse(true);
958 } 967 }
959 968
960 } // namespace extensions 969 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698