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

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

Issue 98543004: Remove usage of deprecated V8 APIs from c/r/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « PRESUBMIT.py ('k') | chrome/renderer/extensions/app_bindings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <string> 5 #include <string>
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "chrome/common/extensions/extension_messages.h" 7 #include "chrome/common/extensions/extension_messages.h"
8 #include "chrome/renderer/chrome_render_process_observer.h" 8 #include "chrome/renderer/chrome_render_process_observer.h"
9 #include "chrome/renderer/extensions/activity_log_converter_strategy.h" 9 #include "chrome/renderer/extensions/activity_log_converter_strategy.h"
10 #include "chrome/renderer/extensions/api_activity_logger.h" 10 #include "chrome/renderer/extensions/api_activity_logger.h"
(...skipping 25 matching lines...) Expand all
36 36
37 // static 37 // static
38 void APIActivityLogger::LogInternal( 38 void APIActivityLogger::LogInternal(
39 const CallType call_type, 39 const CallType call_type,
40 const v8::FunctionCallbackInfo<v8::Value>& args) { 40 const v8::FunctionCallbackInfo<v8::Value>& args) {
41 DCHECK_GT(args.Length(), 2); 41 DCHECK_GT(args.Length(), 2);
42 DCHECK(args[0]->IsString()); 42 DCHECK(args[0]->IsString());
43 DCHECK(args[1]->IsString()); 43 DCHECK(args[1]->IsString());
44 DCHECK(args[2]->IsArray()); 44 DCHECK(args[2]->IsArray());
45 45
46 std::string ext_id = *v8::String::AsciiValue(args[0]); 46 std::string ext_id = *v8::String::Utf8Value(args[0]);
47 ExtensionHostMsg_APIActionOrEvent_Params params; 47 ExtensionHostMsg_APIActionOrEvent_Params params;
48 params.api_call = *v8::String::AsciiValue(args[1]); 48 params.api_call = *v8::String::Utf8Value(args[1]);
49 if (args.Length() == 4) // Extras are optional. 49 if (args.Length() == 4) // Extras are optional.
50 params.extra = *v8::String::AsciiValue(args[3]); 50 params.extra = *v8::String::Utf8Value(args[3]);
51 else 51 else
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<ListValue> arg_list(new ListValue()); 61 scoped_ptr<ListValue> arg_list(new ListValue());
62 for (size_t i = 0; i < arg_array->Length(); ++i) { 62 for (size_t i = 0; i < arg_array->Length(); ++i) {
63 arg_list->Set(i, 63 arg_list->Set(i,
64 converter->FromV8Value(arg_array->Get(i), 64 converter->FromV8Value(arg_array->Get(i),
65 v8::Context::GetCurrent())); 65 args.GetIsolate()->GetCurrentContext()));
66 } 66 }
67 params.arguments.Swap(arg_list.get()); 67 params.arguments.Swap(arg_list.get());
68 } 68 }
69 69
70 if (call_type == APICALL) { 70 if (call_type == APICALL) {
71 content::RenderThread::Get()->Send( 71 content::RenderThread::Get()->Send(
72 new ExtensionHostMsg_AddAPIActionToActivityLog(ext_id, params)); 72 new ExtensionHostMsg_AddAPIActionToActivityLog(ext_id, params));
73 } else if (call_type == EVENT) { 73 } else if (call_type == EVENT) {
74 content::RenderThread::Get()->Send( 74 content::RenderThread::Get()->Send(
75 new ExtensionHostMsg_AddEventToActivityLog(ext_id, params)); 75 new ExtensionHostMsg_AddEventToActivityLog(ext_id, params));
76 } 76 }
77 } 77 }
78 78
79 } // namespace extensions 79 } // namespace extensions
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | chrome/renderer/extensions/app_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698