OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "content/public/child/v8_value_converter.h" | 10 #include "content/public/child/v8_value_converter.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 ExtensionHostMsg_APIActionOrEvent_Params params; | 49 ExtensionHostMsg_APIActionOrEvent_Params params; |
50 params.api_call = *v8::String::Utf8Value(args[1]); | 50 params.api_call = *v8::String::Utf8Value(args[1]); |
51 if (args.Length() == 4) // Extras are optional. | 51 if (args.Length() == 4) // Extras are optional. |
52 params.extra = *v8::String::Utf8Value(args[3]); | 52 params.extra = *v8::String::Utf8Value(args[3]); |
53 else | 53 else |
54 params.extra = ""; | 54 params.extra = ""; |
55 | 55 |
56 // Get the array of api call arguments. | 56 // Get the array of api call arguments. |
57 v8::Local<v8::Array> arg_array = v8::Local<v8::Array>::Cast(args[2]); | 57 v8::Local<v8::Array> arg_array = v8::Local<v8::Array>::Cast(args[2]); |
58 if (arg_array->Length() > 0) { | 58 if (arg_array->Length() > 0) { |
59 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 59 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
60 ActivityLogConverterStrategy strategy; | 60 ActivityLogConverterStrategy strategy; |
61 converter->SetFunctionAllowed(true); | 61 converter->SetFunctionAllowed(true); |
62 converter->SetStrategy(&strategy); | 62 converter->SetStrategy(&strategy); |
63 scoped_ptr<base::ListValue> arg_list(new base::ListValue()); | 63 std::unique_ptr<base::ListValue> arg_list(new base::ListValue()); |
64 for (size_t i = 0; i < arg_array->Length(); ++i) { | 64 for (size_t i = 0; i < arg_array->Length(); ++i) { |
65 arg_list->Set( | 65 arg_list->Set( |
66 i, | 66 i, |
67 converter->FromV8Value(arg_array->Get(i), | 67 converter->FromV8Value(arg_array->Get(i), |
68 args.GetIsolate()->GetCurrentContext())); | 68 args.GetIsolate()->GetCurrentContext())); |
69 } | 69 } |
70 params.arguments.Swap(arg_list.get()); | 70 params.arguments.Swap(arg_list.get()); |
71 } | 71 } |
72 | 72 |
73 if (call_type == APICALL) { | 73 if (call_type == APICALL) { |
74 content::RenderThread::Get()->Send( | 74 content::RenderThread::Get()->Send( |
75 new ExtensionHostMsg_AddAPIActionToActivityLog(ext_id, params)); | 75 new ExtensionHostMsg_AddAPIActionToActivityLog(ext_id, params)); |
76 } else if (call_type == EVENT) { | 76 } else if (call_type == EVENT) { |
77 content::RenderThread::Get()->Send( | 77 content::RenderThread::Get()->Send( |
78 new ExtensionHostMsg_AddEventToActivityLog(ext_id, params)); | 78 new ExtensionHostMsg_AddEventToActivityLog(ext_id, params)); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 } // namespace extensions | 82 } // namespace extensions |
OLD | NEW |