| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/renderer/api_request_handler.h" | 5 #include "extensions/renderer/api_request_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/guid.h" | 8 #include "base/guid.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 v8::Local<v8::Context> context = pending_request.context.Get(isolate); | 120 v8::Local<v8::Context> context = pending_request.context.Get(isolate); |
| 121 v8::Context::Scope context_scope(context); | 121 v8::Context::Scope context_scope(context); |
| 122 std::unique_ptr<content::V8ValueConverter> converter( | 122 std::unique_ptr<content::V8ValueConverter> converter( |
| 123 content::V8ValueConverter::create()); | 123 content::V8ValueConverter::create()); |
| 124 std::vector<v8::Local<v8::Value>> args; | 124 std::vector<v8::Local<v8::Value>> args; |
| 125 args.reserve(response_args.GetSize() + | 125 args.reserve(response_args.GetSize() + |
| 126 pending_request.callback_arguments.size()); | 126 pending_request.callback_arguments.size()); |
| 127 for (const auto& arg : pending_request.callback_arguments) | 127 for (const auto& arg : pending_request.callback_arguments) |
| 128 args.push_back(arg.Get(isolate)); | 128 args.push_back(arg.Get(isolate)); |
| 129 for (const auto& arg : response_args) | 129 for (const auto& arg : response_args) |
| 130 args.push_back(converter->ToV8Value(&arg, context)); | 130 args.push_back(converter->ToV8Value(arg.get(), context)); |
| 131 | 131 |
| 132 blink::WebScopedUserGesture user_gesture(pending_request.user_gesture_token); | 132 blink::WebScopedUserGesture user_gesture(pending_request.user_gesture_token); |
| 133 if (!error.empty()) | 133 if (!error.empty()) |
| 134 last_error_.SetError(context, error); | 134 last_error_.SetError(context, error); |
| 135 | 135 |
| 136 // args.size() is converted to int, but args is controlled by chrome and is | 136 // args.size() is converted to int, but args is controlled by chrome and is |
| 137 // never close to std::numeric_limits<int>::max. | 137 // never close to std::numeric_limits<int>::max. |
| 138 call_js_.Run(pending_request.callback.Get(isolate), context, args.size(), | 138 call_js_.Run(pending_request.callback.Get(isolate), context, args.size(), |
| 139 args.data()); | 139 args.data()); |
| 140 | 140 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 153 } | 153 } |
| 154 | 154 |
| 155 std::set<int> APIRequestHandler::GetPendingRequestIdsForTesting() const { | 155 std::set<int> APIRequestHandler::GetPendingRequestIdsForTesting() const { |
| 156 std::set<int> result; | 156 std::set<int> result; |
| 157 for (const auto& pair : pending_requests_) | 157 for (const auto& pair : pending_requests_) |
| 158 result.insert(pair.first); | 158 result.insert(pair.first); |
| 159 return result; | 159 return result; |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |