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

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

Issue 1471043004: Convert various vector_as_array calls to vector::data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « device/serial/buffer.cc ('k') | extensions/browser/api/hid/hid_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_widget_host.h" 9 #include "content/public/browser/render_widget_host.h"
10 #include "content/public/browser/render_widget_host_view.h" 10 #include "content/public/browser/render_widget_host_view.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 default: 130 default:
131 NOTREACHED() << "Invalid image format."; 131 NOTREACHED() << "Invalid image format.";
132 } 132 }
133 133
134 if (!encoded) { 134 if (!encoded) {
135 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED); 135 OnCaptureFailure(FAILURE_REASON_ENCODING_FAILED);
136 return; 136 return;
137 } 137 }
138 138
139 std::string base64_result; 139 std::string base64_result;
140 base::StringPiece stream_as_string( 140 base::StringPiece stream_as_string(reinterpret_cast<const char*>(data.data()),
141 reinterpret_cast<const char*>(vector_as_array(&data)), data.size()); 141 data.size());
142 142
143 base::Base64Encode(stream_as_string, &base64_result); 143 base::Base64Encode(stream_as_string, &base64_result);
144 base64_result.insert( 144 base64_result.insert(
145 0, base::StringPrintf("data:%s;base64,", mime_type.c_str())); 145 0, base::StringPrintf("data:%s;base64,", mime_type.c_str()));
146 SetResult(new base::StringValue(base64_result)); 146 SetResult(new base::StringValue(base64_result));
147 SendResponse(true); 147 SendResponse(true);
148 } 148 }
149 149
150 } // namespace extensions 150 } // namespace extensions
OLDNEW
« no previous file with comments | « device/serial/buffer.cc ('k') | extensions/browser/api/hid/hid_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698