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

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

Issue 19730002: V8ValueConverter for the activity logger that does not invoke interceptors and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Dan's comment Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/extensions/activity_log_converter_strategy.h"
6 #include "base/values.h"
7
8 namespace extensions {
9
10 bool ActivityLogConverterStrategy::FromV8Object(v8::Handle<v8::Object> value,
11 base::Value** out) const {
12 return FromV8ObjectInternal(value, out);
13 }
14
15 bool ActivityLogConverterStrategy::FromV8Array(v8::Handle<v8::Array> value,
16 base::Value** out) const {
17 return FromV8ObjectInternal(value, out);
18 }
19
20 bool ActivityLogConverterStrategy::FromV8ObjectInternal(
21 v8::Handle<v8::Object> value,
22 base::Value** out) const {
23
24 // Handle JSObject.
25 // We cannot use value->Get(key/index) as there may be a getter method,
26 // accessor, interceptor/handler, or access check callback set on the
27 // property. If that it is the case, any of those may invoke JS code that
28 // may result on logging extension activity events caused by value conversion
29 // rather than extension itself.
30
31 // V8 arrays are handled here in the same way as other JSObjects as they may
32 // also have getter methods, accessor, interceptor/handler, and access check
33 // callback.
34
35 v8::Handle<v8::String> name = v8::String::New("[");
36 if (value->IsFunction()) {
37 name = v8::String::Concat(name, v8::String::New("Function"));
38 v8::Handle<v8::Value> fname =
39 v8::Handle<v8::Function>::Cast(value)->GetName();
40 if (fname->IsString() && v8::Handle<v8::String>::Cast(fname)->Length()) {
41 name = v8::String::Concat(name, v8::String::New(" "));
42 name = v8::String::Concat(name, v8::Handle<v8::String>::Cast(fname));
43 name = v8::String::Concat(name, v8::String::New("()"));
44 }
45 } else {
46 name = v8::String::Concat(name, value->GetConstructorName());
47 }
48 name = v8::String::Concat(name, v8::String::New("]"));
49 *out = new base::StringValue(std::string(*v8::String::Utf8Value(name)));
50 // Prevent V8ValueConverter from further processing this object.
51 return true;
52 }
53
54 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698