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_binding_hooks.h" | 5 #include "extensions/renderer/api_binding_hooks.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/supports_user_data.h" | 9 #include "base/supports_user_data.h" |
10 #include "extensions/renderer/api_binding_hooks_delegate.h" | 10 #include "extensions/renderer/api_binding_hooks_delegate.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 APIHooksPerContextData* data = static_cast<APIHooksPerContextData*>( | 165 APIHooksPerContextData* data = static_cast<APIHooksPerContextData*>( |
166 per_context_data->GetUserData(kExtensionAPIHooksPerContextKey)); | 166 per_context_data->GetUserData(kExtensionAPIHooksPerContextKey)); |
167 if (!data) { | 167 if (!data) { |
168 if (!should_create) | 168 if (!should_create) |
169 return v8::Local<v8::Object>(); | 169 return v8::Local<v8::Object>(); |
170 | 170 |
171 auto api_data = | 171 auto api_data = |
172 base::MakeUnique<APIHooksPerContextData>(context->GetIsolate()); | 172 base::MakeUnique<APIHooksPerContextData>(context->GetIsolate()); |
173 data = api_data.get(); | 173 data = api_data.get(); |
174 per_context_data->SetUserData(kExtensionAPIHooksPerContextKey, | 174 per_context_data->SetUserData(kExtensionAPIHooksPerContextKey, |
175 api_data.release()); | 175 std::move(api_data)); |
176 } | 176 } |
177 | 177 |
178 auto iter = data->hook_interfaces.find(api_name); | 178 auto iter = data->hook_interfaces.find(api_name); |
179 if (iter != data->hook_interfaces.end()) | 179 if (iter != data->hook_interfaces.end()) |
180 return iter->second.Get(context->GetIsolate()); | 180 return iter->second.Get(context->GetIsolate()); |
181 | 181 |
182 if (!should_create) | 182 if (!should_create) |
183 return v8::Local<v8::Object>(); | 183 return v8::Local<v8::Object>(); |
184 | 184 |
185 gin::Handle<JSHookInterface> hooks = | 185 gin::Handle<JSHookInterface> hooks = |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 if (result.IsEmpty() || | 358 if (result.IsEmpty() || |
359 !gin::Converter<std::vector<v8::Local<v8::Value>>>::FromV8( | 359 !gin::Converter<std::vector<v8::Local<v8::Value>>>::FromV8( |
360 context->GetIsolate(), result, &new_args)) { | 360 context->GetIsolate(), result, &new_args)) { |
361 return false; | 361 return false; |
362 } | 362 } |
363 arguments->swap(new_args); | 363 arguments->swap(new_args); |
364 return true; | 364 return true; |
365 } | 365 } |
366 | 366 |
367 } // namespace extensions | 367 } // namespace extensions |
OLD | NEW |