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

Side by Side Diff: chrome/browser/extensions/api/capture_web_contents_function.cc

Issue 188633002: Query the preferred readback config in CopyFromBackingStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add Preferred format support for all functions. Created 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/extensions/api/capture_web_contents_function.h" 5 #include "chrome/browser/extensions/api/capture_web_contents_function.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
10 #include "chrome/common/extensions/extension_constants.h" 10 #include "chrome/common/extensions/extension_constants.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (image_details->quality.get()) 65 if (image_details->quality.get())
66 image_quality_ = *image_details->quality; 66 image_quality_ = *image_details->quality;
67 } 67 }
68 68
69 RenderViewHost* render_view_host = contents->GetRenderViewHost(); 69 RenderViewHost* render_view_host = contents->GetRenderViewHost();
70 RenderWidgetHostView* view = render_view_host->GetView(); 70 RenderWidgetHostView* view = render_view_host->GetView();
71 if (!view) { 71 if (!view) {
72 OnCaptureFailure(FAILURE_REASON_VIEW_INVISIBLE); 72 OnCaptureFailure(FAILURE_REASON_VIEW_INVISIBLE);
73 return false; 73 return false;
74 } 74 }
75 SkBitmap::Config preferred_format =
76 render_view_host->PreferredReadbackFormat();
75 render_view_host->CopyFromBackingStore( 77 render_view_host->CopyFromBackingStore(
76 gfx::Rect(), 78 gfx::Rect(),
77 view->GetViewBounds().size(), 79 view->GetViewBounds().size(),
78 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete, 80 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete,
79 this)); 81 this),
82 preferred_format);
piman 2014/03/10 18:27:20 The receiving code only accepts 8888.
sivag 2014/03/11 14:41:50 Done.
80 return true; 83 return true;
81 } 84 }
82 85
83 void CaptureWebContentsFunction::CopyFromBackingStoreComplete( 86 void CaptureWebContentsFunction::CopyFromBackingStoreComplete(
84 bool succeeded, 87 bool succeeded,
85 const SkBitmap& bitmap) { 88 const SkBitmap& bitmap) {
86 if (succeeded) { 89 if (succeeded) {
87 OnCaptureSuccess(bitmap); 90 OnCaptureSuccess(bitmap);
88 return; 91 return;
89 } 92 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 reinterpret_cast<const char*>(vector_as_array(&data)), data.size()); 152 reinterpret_cast<const char*>(vector_as_array(&data)), data.size());
150 153
151 base::Base64Encode(stream_as_string, &base64_result); 154 base::Base64Encode(stream_as_string, &base64_result);
152 base64_result.insert(0, base::StringPrintf("data:%s;base64,", 155 base64_result.insert(0, base::StringPrintf("data:%s;base64,",
153 mime_type.c_str())); 156 mime_type.c_str()));
154 SetResult(new base::StringValue(base64_result)); 157 SetResult(new base::StringValue(base64_result));
155 SendResponse(true); 158 SendResponse(true);
156 } 159 }
157 160
158 } // namespace extensions 161 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/thumbnails/thumbnail_tab_helper.cc » ('j') | chrome/browser/thumbnails/thumbnail_tab_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698