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

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

Issue 593503003: Support error handling for Surface readbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary headers. Created 6 years, 2 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 "extensions/browser/api/capture_web_contents_function.h" 5 #include "extensions/browser/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 "content/public/browser/render_view_host.h" 9 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/render_widget_host_view.h" 10 #include "content/public/browser/render_widget_host_view.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 gfx::Rect(), 69 gfx::Rect(),
70 view->GetViewBounds().size(), 70 view->GetViewBounds().size(),
71 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete, 71 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete,
72 this), 72 this),
73 kN32_SkColorType); 73 kN32_SkColorType);
74 return true; 74 return true;
75 } 75 }
76 76
77 void CaptureWebContentsFunction::CopyFromBackingStoreComplete( 77 void CaptureWebContentsFunction::CopyFromBackingStoreComplete(
78 bool succeeded, 78 bool succeeded,
79 const SkBitmap& bitmap) { 79 const SkBitmap& bitmap,
80 const int& response) {
80 if (succeeded) { 81 if (succeeded) {
81 OnCaptureSuccess(bitmap); 82 OnCaptureSuccess(bitmap);
82 return; 83 return;
83 } 84 }
84 OnCaptureFailure(FAILURE_REASON_UNKNOWN); 85 OnCaptureFailure(FAILURE_REASON_UNKNOWN);
85 } 86 }
86 87
87 void CaptureWebContentsFunction::OnCaptureSuccess(const SkBitmap& bitmap) { 88 void CaptureWebContentsFunction::OnCaptureSuccess(const SkBitmap& bitmap) {
88 std::vector<unsigned char> data; 89 std::vector<unsigned char> data;
89 SkAutoLockPixels screen_capture_lock(bitmap); 90 SkAutoLockPixels screen_capture_lock(bitmap);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 reinterpret_cast<const char*>(vector_as_array(&data)), data.size()); 123 reinterpret_cast<const char*>(vector_as_array(&data)), data.size());
123 124
124 base::Base64Encode(stream_as_string, &base64_result); 125 base::Base64Encode(stream_as_string, &base64_result);
125 base64_result.insert( 126 base64_result.insert(
126 0, base::StringPrintf("data:%s;base64,", mime_type.c_str())); 127 0, base::StringPrintf("data:%s;base64,", mime_type.c_str()));
127 SetResult(new base::StringValue(base64_result)); 128 SetResult(new base::StringValue(base64_result));
128 SendResponse(true); 129 SendResponse(true);
129 } 130 }
130 131
131 } // namespace extensions 132 } // namespace extensions
OLDNEW
« content/common/readback_types.h ('K') | « extensions/browser/api/capture_web_contents_function.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698