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

Side by Side Diff: extensions/renderer/api_activity_logger.cc

Issue 1167423002: Use V8 Maybe APIs in extensions/renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/public/child/v8_value_converter.h" 8 #include "content/public/child/v8_value_converter.h"
9 #include "content/public/renderer/render_thread.h" 9 #include "content/public/renderer/render_thread.h"
10 #include "extensions/common/extension_messages.h" 10 #include "extensions/common/extension_messages.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 params.extra = ""; 52 params.extra = "";
53 53
54 // Get the array of api call arguments. 54 // Get the array of api call arguments.
55 v8::Local<v8::Array> arg_array = v8::Local<v8::Array>::Cast(args[2]); 55 v8::Local<v8::Array> arg_array = v8::Local<v8::Array>::Cast(args[2]);
56 if (arg_array->Length() > 0) { 56 if (arg_array->Length() > 0) {
57 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 57 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
58 ActivityLogConverterStrategy strategy; 58 ActivityLogConverterStrategy strategy;
59 converter->SetFunctionAllowed(true); 59 converter->SetFunctionAllowed(true);
60 converter->SetStrategy(&strategy); 60 converter->SetStrategy(&strategy);
61 scoped_ptr<base::ListValue> arg_list(new base::ListValue()); 61 scoped_ptr<base::ListValue> arg_list(new base::ListValue());
62 for (size_t i = 0; i < arg_array->Length(); ++i) { 62 v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
63 arg_list->Set( 63 for (uint32_t i = 0; i < arg_array->Length(); ++i) {
64 i, 64 v8::Local<v8::Value> property;
65 converter->FromV8Value(arg_array->Get(i), 65 if (!arg_array->Get(context, i).ToLocal(&property))
66 args.GetIsolate()->GetCurrentContext())); 66 return;
67 arg_list->Set(i, converter->FromV8Value(property, context));
67 } 68 }
68 params.arguments.Swap(arg_list.get()); 69 params.arguments.Swap(arg_list.get());
69 } 70 }
70 71
71 if (call_type == APICALL) { 72 if (call_type == APICALL) {
72 content::RenderThread::Get()->Send( 73 content::RenderThread::Get()->Send(
73 new ExtensionHostMsg_AddAPIActionToActivityLog(ext_id, params)); 74 new ExtensionHostMsg_AddAPIActionToActivityLog(ext_id, params));
74 } else if (call_type == EVENT) { 75 } else if (call_type == EVENT) {
75 content::RenderThread::Get()->Send( 76 content::RenderThread::Get()->Send(
76 new ExtensionHostMsg_AddEventToActivityLog(ext_id, params)); 77 new ExtensionHostMsg_AddEventToActivityLog(ext_id, params));
77 } 78 }
78 } 79 }
79 80
80 } // namespace extensions 81 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/activity_log_converter_strategy.cc ('k') | extensions/renderer/app_runtime_custom_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698