Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/renderer/extensions/dom_activity_logger.h" | 5 #include "chrome/renderer/extensions/dom_activity_logger.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/common/extensions/dom_action_types.h" | 8 #include "chrome/common/extensions/dom_action_types.h" |
| 9 #include "chrome/common/extensions/extension_messages.h" | 9 #include "chrome/common/extensions/extension_messages.h" |
| 10 #include "chrome/renderer/chrome_render_process_observer.h" | 10 #include "chrome/renderer/chrome_render_process_observer.h" |
| 11 #include "chrome/renderer/extensions/activity_log_converter_strategy.h" | |
| 11 #include "content/public/renderer/render_thread.h" | 12 #include "content/public/renderer/render_thread.h" |
| 12 #include "content/public/renderer/v8_value_converter.h" | 13 #include "content/public/renderer/v8_value_converter.h" |
| 13 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
| 14 #include "third_party/WebKit/public/web/WebDOMActivityLogger.h" | 15 #include "third_party/WebKit/public/web/WebDOMActivityLogger.h" |
| 15 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
| 16 | 17 |
| 17 using content::V8ValueConverter; | 18 using content::V8ValueConverter; |
| 18 | 19 |
| 19 namespace extensions { | 20 namespace extensions { |
| 20 | 21 |
| 21 DOMActivityLogger::DOMActivityLogger(const std::string& extension_id, | 22 DOMActivityLogger::DOMActivityLogger(const std::string& extension_id, |
| 22 const GURL& url, | 23 const GURL& url, |
| 23 const string16& title) | 24 const string16& title) |
| 24 : extension_id_(extension_id), url_(url), title_(title) { | 25 : extension_id_(extension_id), url_(url), title_(title) { |
| 25 } // namespace extensions | 26 } // namespace extensions |
| 26 | 27 |
| 27 void DOMActivityLogger::log( | 28 void DOMActivityLogger::log( |
| 28 const WebString& api_name, | 29 const WebString& api_name, |
| 29 int argc, | 30 int argc, |
| 30 const v8::Handle<v8::Value> argv[], | 31 const v8::Handle<v8::Value> argv[], |
| 31 const WebString& call_type) { | 32 const WebString& call_type) { |
| 32 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 33 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 34 ActivityLogConverterStrategy strategy; | |
| 35 // Do not set the converter's RegExpr to true via SetRegExpAllowed() as this | |
|
pmarch
2013/08/08 00:53:07
killed comment as well
| |
| 36 // will call JS toString() method which can be overwritten. | |
| 37 converter->SetFunctionAllowed(true); | |
| 38 converter->SetStrategy(&strategy); | |
| 33 scoped_ptr<ListValue> argv_list_value(new ListValue()); | 39 scoped_ptr<ListValue> argv_list_value(new ListValue()); |
| 34 for (int i =0; i < argc; i++) { | 40 for (int i =0; i < argc; i++) { |
| 35 argv_list_value->Set( | 41 argv_list_value->Set( |
| 36 i, converter->FromV8Value(argv[i], v8::Context::GetCurrent())); | 42 i, converter->FromV8Value(argv[i], v8::Context::GetCurrent())); |
| 37 } | 43 } |
| 38 ExtensionHostMsg_DOMAction_Params params; | 44 ExtensionHostMsg_DOMAction_Params params; |
| 39 params.url = url_; | 45 params.url = url_; |
| 40 params.url_title = title_; | 46 params.url_title = title_; |
| 41 params.api_call = api_name.utf8(); | 47 params.api_call = api_name.utf8(); |
| 42 params.arguments.Swap(argv_list_value.get()); | 48 params.arguments.Swap(argv_list_value.get()); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 62 // If there is no logger registered for world_id, construct a new logger | 68 // If there is no logger registered for world_id, construct a new logger |
| 63 // and register it with world_id. | 69 // and register it with world_id. |
| 64 if (!WebKit::hasDOMActivityLogger(world_id)) { | 70 if (!WebKit::hasDOMActivityLogger(world_id)) { |
| 65 DOMActivityLogger* logger = new DOMActivityLogger(extension_id, url, title); | 71 DOMActivityLogger* logger = new DOMActivityLogger(extension_id, url, title); |
| 66 WebKit::setDOMActivityLogger(world_id, logger); | 72 WebKit::setDOMActivityLogger(world_id, logger); |
| 67 } | 73 } |
| 68 } | 74 } |
| 69 | 75 |
| 70 } // namespace extensions | 76 } // namespace extensions |
| 71 | 77 |
| OLD | NEW |