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

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: Updated comment, deleted redundant code after rebase 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
not at google - send to devlin 2013/08/07 22:07:56 add a comment about the array index stuff we've be
pmarch 2013/08/08 00:53:07 Done.
31 v8::Handle<v8::String> name = v8::String::New("[");
32 if (value->IsFunction()) {
33 name = v8::String::Concat(name, v8::String::New("Function"));
34 v8::Handle<v8::Value> fname =
35 v8::Handle<v8::Function>::Cast(value)->GetName();
36 if (fname->IsString() && v8::Handle<v8::String>::Cast(fname)->Length()) {
37 name = v8::String::Concat(name, v8::String::New(" "));
38 name = v8::String::Concat(name, v8::Handle<v8::String>::Cast(fname));
39 name = v8::String::Concat(name, v8::String::New("()"));
40 }
41 } else {
42 name = v8::String::Concat(name, value->ToObject()->GetConstructorName());
43 }
44 name = v8::String::Concat(name, v8::String::New("]"));
45 v8::String::Utf8Value utf8(name);
46 *out = new base::StringValue(std::string(*utf8, utf8.length()));
not at google - send to devlin 2013/08/07 22:07:56 you should be able to do just name = v8::String::
not at google - send to devlin 2013/08/07 22:08:40 where by AsciiValue I mean Utf8Value. Or is the le
pmarch 2013/08/08 00:53:07 Done.
pmarch 2013/08/08 00:53:07 Done.
47 return true; // Prevent V8ValueConverter from further processing this object.
not at google - send to devlin 2013/08/07 22:07:56 comment would look better on its own line
pmarch 2013/08/08 00:53:07 Done.
48 }
49
50 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698