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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/activity_log_converter_strategy.cc
diff --git a/chrome/renderer/extensions/activity_log_converter_strategy.cc b/chrome/renderer/extensions/activity_log_converter_strategy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1d3f3021e6b08664b34a8eca4e50028e9ee54136
--- /dev/null
+++ b/chrome/renderer/extensions/activity_log_converter_strategy.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/extensions/activity_log_converter_strategy.h"
+#include "base/values.h"
+
+namespace extensions {
+
+bool ActivityLogConverterStrategy::FromV8Object(v8::Handle<v8::Object> value,
+ base::Value** out) const {
+ return FromV8ObjectInternal(value, out);
+}
+
+bool ActivityLogConverterStrategy::FromV8Array(v8::Handle<v8::Array> value,
+ base::Value** out) const {
+ return FromV8ObjectInternal(value, out);
+}
+
+bool ActivityLogConverterStrategy::FromV8ObjectInternal(
+ v8::Handle<v8::Object> value,
+ base::Value** out) const {
+
+ // Handle JSObject.
+ // We cannot use value->Get(key/index) as there may be a getter method,
+ // accessor, interceptor/handler, or access check callback set on the
+ // property. If that it is the case, any of those may invoke JS code that
+ // may result on logging extension activity events caused by value conversion
+ // rather than extension itself.
+
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.
+ v8::Handle<v8::String> name = v8::String::New("[");
+ if (value->IsFunction()) {
+ name = v8::String::Concat(name, v8::String::New("Function"));
+ v8::Handle<v8::Value> fname =
+ v8::Handle<v8::Function>::Cast(value)->GetName();
+ if (fname->IsString() && v8::Handle<v8::String>::Cast(fname)->Length()) {
+ name = v8::String::Concat(name, v8::String::New(" "));
+ name = v8::String::Concat(name, v8::Handle<v8::String>::Cast(fname));
+ name = v8::String::Concat(name, v8::String::New("()"));
+ }
+ } else {
+ name = v8::String::Concat(name, value->ToObject()->GetConstructorName());
+ }
+ name = v8::String::Concat(name, v8::String::New("]"));
+ v8::String::Utf8Value utf8(name);
+ *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.
+ 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.
+}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698