| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/dom_activity_logger.h" | 5 #include "extensions/renderer/dom_activity_logger.h" |
| 6 | 6 |
| 7 #include "content/public/renderer/render_thread.h" | 7 #include "content/public/renderer/render_thread.h" |
| 8 #include "content/public/renderer/v8_value_converter.h" | 8 #include "content/public/renderer/v8_value_converter.h" |
| 9 #include "extensions/common/ad_injection_constants.h" | 9 #include "extensions/common/ad_injection_constants.h" |
| 10 #include "extensions/common/dom_action_types.h" | 10 #include "extensions/common/dom_action_types.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 DOMActivityLogger::DOMActivityLogger(const std::string& extension_id) | 45 DOMActivityLogger::DOMActivityLogger(const std::string& extension_id) |
| 46 : extension_id_(extension_id) { | 46 : extension_id_(extension_id) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 DOMActivityLogger::~DOMActivityLogger() {} | 49 DOMActivityLogger::~DOMActivityLogger() {} |
| 50 | 50 |
| 51 void DOMActivityLogger::log( | |
| 52 const WebString& api_name, | |
| 53 int argc, | |
| 54 const v8::Handle<v8::Value> argv[], | |
| 55 const WebString& call_type, | |
| 56 const WebURL& url, | |
| 57 const WebString& title) { | |
| 58 scoped_ptr<base::ListValue> args(new base::ListValue()); | |
| 59 std::string api_name_utf8 = api_name.utf8(); | |
| 60 for (int i = 0; i < argc; ++i) | |
| 61 AppendV8Value(api_name_utf8, argv[i], args.get()); | |
| 62 | |
| 63 DomActionType::Type type = DomActionType::METHOD; | |
| 64 if (call_type == "Getter") | |
| 65 type = DomActionType::GETTER; | |
| 66 else if (call_type == "Setter") | |
| 67 type = DomActionType::SETTER; | |
| 68 // else DomActionType::METHOD is correct. | |
| 69 SendDomActionMessage(api_name_utf8, url, title, type, args.Pass()); | |
| 70 } | |
| 71 | |
| 72 void DOMActivityLogger::AttachToWorld(int world_id, | 51 void DOMActivityLogger::AttachToWorld(int world_id, |
| 73 const std::string& extension_id) { | 52 const std::string& extension_id) { |
| 74 #if defined(ENABLE_EXTENSIONS) | 53 #if defined(ENABLE_EXTENSIONS) |
| 75 // If there is no logger registered for world_id, construct a new logger | 54 // If there is no logger registered for world_id, construct a new logger |
| 76 // and register it with world_id. | 55 // and register it with world_id. |
| 77 if (!blink::hasDOMActivityLogger(world_id)) { | 56 if (!blink::hasDOMActivityLogger(world_id)) { |
| 78 DOMActivityLogger* logger = new DOMActivityLogger(extension_id); | 57 DOMActivityLogger* logger = new DOMActivityLogger(extension_id); |
| 79 blink::setDOMActivityLogger(world_id, logger); | 58 blink::setDOMActivityLogger(world_id, logger); |
| 80 } | 59 } |
| 81 #endif | 60 #endif |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 params.api_call = api_call; | 113 params.api_call = api_call; |
| 135 params.url = url; | 114 params.url = url; |
| 136 params.url_title = url_title; | 115 params.url_title = url_title; |
| 137 params.call_type = call_type; | 116 params.call_type = call_type; |
| 138 params.arguments.Swap(args.get()); | 117 params.arguments.Swap(args.get()); |
| 139 content::RenderThread::Get()->Send( | 118 content::RenderThread::Get()->Send( |
| 140 new ExtensionHostMsg_AddDOMActionToActivityLog(extension_id_, params)); | 119 new ExtensionHostMsg_AddDOMActionToActivityLog(extension_id_, params)); |
| 141 } | 120 } |
| 142 | 121 |
| 143 } // namespace extensions | 122 } // namespace extensions |
| OLD | NEW |