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

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

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 7 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 | Annotate | Revision Log
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 "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
(...skipping 14 matching lines...) Expand all
25 CaptureWebContentsFunction::CaptureWebContentsFunction() { 25 CaptureWebContentsFunction::CaptureWebContentsFunction() {
26 } 26 }
27 27
28 CaptureWebContentsFunction::~CaptureWebContentsFunction() { 28 CaptureWebContentsFunction::~CaptureWebContentsFunction() {
29 } 29 }
30 30
31 bool CaptureWebContentsFunction::HasPermission() { 31 bool CaptureWebContentsFunction::HasPermission() {
32 return true; 32 return true;
33 } 33 }
34 34
35 bool CaptureWebContentsFunction::RunImpl() { 35 bool CaptureWebContentsFunction::RunAsync() {
36 EXTENSION_FUNCTION_VALIDATE(args_); 36 EXTENSION_FUNCTION_VALIDATE(args_);
37 37
38 context_id_ = extension_misc::kCurrentWindowId; 38 context_id_ = extension_misc::kCurrentWindowId;
39 args_->GetInteger(0, &context_id_); 39 args_->GetInteger(0, &context_id_);
40 40
41 scoped_ptr<ImageDetails> image_details; 41 scoped_ptr<ImageDetails> image_details;
42 if (args_->GetSize() > 1) { 42 if (args_->GetSize() > 1) {
43 base::Value* spec = NULL; 43 base::Value* spec = NULL;
44 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec); 44 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &spec) && spec);
45 image_details = ImageDetails::FromValue(*spec); 45 image_details = ImageDetails::FromValue(*spec);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 reinterpret_cast<const char*>(vector_as_array(&data)), data.size()); 129 reinterpret_cast<const char*>(vector_as_array(&data)), data.size());
130 130
131 base::Base64Encode(stream_as_string, &base64_result); 131 base::Base64Encode(stream_as_string, &base64_result);
132 base64_result.insert(0, base::StringPrintf("data:%s;base64,", 132 base64_result.insert(0, base::StringPrintf("data:%s;base64,",
133 mime_type.c_str())); 133 mime_type.c_str()));
134 SetResult(new base::StringValue(base64_result)); 134 SetResult(new base::StringValue(base64_result));
135 SendResponse(true); 135 SendResponse(true);
136 } 136 }
137 137
138 } // namespace extensions 138 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698