OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |