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

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: Apply wjmaclean's comments. 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 web_view_internal::CaptureVisibleRegion::Params::Create(*args_)); 266 web_view_internal::CaptureVisibleRegion::Params::Create(*args_));
267 EXTENSION_FUNCTION_VALIDATE(params.get()); 267 EXTENSION_FUNCTION_VALIDATE(params.get());
268 268
269 scoped_ptr<ImageDetails> image_details; 269 scoped_ptr<ImageDetails> image_details;
270 if (args_->GetSize() > 1) { 270 if (args_->GetSize() > 1) {
271 base::Value* spec = NULL; 271 base::Value* spec = NULL;
272 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); 272 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec);
273 image_details = ImageDetails::FromValue(*spec); 273 image_details = ImageDetails::FromValue(*spec);
274 } 274 }
275 275
276 is_guest_transparent_ = guest->allow_transparency();
276 return CaptureAsync(guest->web_contents(), image_details.get(), 277 return CaptureAsync(guest->web_contents(), image_details.get(),
277 base::Bind(&WebViewInternalCaptureVisibleRegionFunction:: 278 base::Bind(&WebViewInternalCaptureVisibleRegionFunction::
278 CopyFromBackingStoreComplete, 279 CopyFromBackingStoreComplete,
279 this)); 280 this));
280 } 281 }
281 bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() { 282 bool WebViewInternalCaptureVisibleRegionFunction::IsScreenshotEnabled() {
282 // TODO(wjmaclean): Is it ok to always return true here? 283 // TODO(wjmaclean): Is it ok to always return true here?
283 return true; 284 return true;
284 } 285 }
285 286
287 bool WebViewInternalCaptureVisibleRegionFunction::ClientAllowsTransparency() {
288 return is_guest_transparent_;
289 }
290
286 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureSuccess( 291 void WebViewInternalCaptureVisibleRegionFunction::OnCaptureSuccess(
287 const SkBitmap& bitmap) { 292 const SkBitmap& bitmap) {
288 std::string base64_result; 293 std::string base64_result;
289 if (!EncodeBitmap(bitmap, &base64_result)) { 294 if (!EncodeBitmap(bitmap, &base64_result)) {
290 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); 295 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED);
291 return; 296 return;
292 } 297 }
293 298
294 SetResult(new base::StringValue(base64_result)); 299 SetResult(new base::StringValue(base64_result));
295 SendResponse(true); 300 SendResponse(true);
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 // Will finish asynchronously. 956 // Will finish asynchronously.
952 return true; 957 return true;
953 } 958 }
954 959
955 void WebViewInternalClearDataFunction::ClearDataDone() { 960 void WebViewInternalClearDataFunction::ClearDataDone() {
956 Release(); // Balanced in RunAsync(). 961 Release(); // Balanced in RunAsync().
957 SendResponse(true); 962 SendResponse(true);
958 } 963 }
959 964
960 } // namespace extensions 965 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698