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

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

Issue 15520002: Moved DOMActionType information from extras into a real field (ActivityLog) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added prefix Created 7 years, 7 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
« no previous file with comments | « chrome/renderer/extensions/dom_activity_logger.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extension_messages.h" 9 #include "chrome/common/extensions/extension_messages.h"
9 #include "chrome/renderer/chrome_render_process_observer.h" 10 #include "chrome/renderer/chrome_render_process_observer.h"
10 #include "content/public/renderer/render_thread.h" 11 #include "content/public/renderer/render_thread.h"
11 #include "content/public/renderer/v8_value_converter.h" 12 #include "content/public/renderer/v8_value_converter.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMActivityLogger. h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMActivityLogger. h"
14 #include "v8/include/v8.h" 15 #include "v8/include/v8.h"
15 16
16 using content::V8ValueConverter; 17 using content::V8ValueConverter;
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 DOMActivityLogger::DOMActivityLogger(const std::string& extension_id, 21 DOMActivityLogger::DOMActivityLogger(const std::string& extension_id,
21 const GURL& url, 22 const GURL& url,
22 const string16& title) 23 const string16& title)
23 : extension_id_(extension_id), url_(url), title_(title) { 24 : extension_id_(extension_id), url_(url), title_(title) {
24 } 25 } // namespace extensions
25 26
26 void DOMActivityLogger::log( 27 void DOMActivityLogger::log(
27 const WebString& api_name, 28 const WebString& api_name,
28 int argc, 29 int argc,
29 const v8::Handle<v8::Value> argv[], 30 const v8::Handle<v8::Value> argv[],
30 const WebString& extra_info) { 31 const WebString& call_type) {
31 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 32 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create());
32 scoped_ptr<ListValue> argv_list_value(new ListValue()); 33 scoped_ptr<ListValue> argv_list_value(new ListValue());
33 for (int i =0; i < argc; i++) { 34 for (int i =0; i < argc; i++) {
34 argv_list_value->Set( 35 argv_list_value->Set(
35 i, converter->FromV8Value(argv[i], v8::Context::GetCurrent())); 36 i, converter->FromV8Value(argv[i], v8::Context::GetCurrent()));
36 } 37 }
37 ExtensionHostMsg_DOMAction_Params params; 38 ExtensionHostMsg_DOMAction_Params params;
38 params.url = url_; 39 params.url = url_;
39 params.url_title = title_; 40 params.url_title = title_;
40 params.api_call = api_name.utf8(); 41 params.api_call = api_name.utf8();
41 params.arguments.Swap(argv_list_value.get()); 42 params.arguments.Swap(argv_list_value.get());
42 params.extra = extra_info.utf8(); 43 const std::string type = call_type.utf8();
44 if (type == "Getter")
45 params.call_type = DomActionType::GETTER;
46 else if (type == "Setter")
47 params.call_type = DomActionType::SETTER;
48 else
49 params.call_type = DomActionType::METHOD;
43 50
44 content::RenderThread::Get()->Send( 51 content::RenderThread::Get()->Send(
45 new ExtensionHostMsg_AddDOMActionToActivityLog(extension_id_, params)); 52 new ExtensionHostMsg_AddDOMActionToActivityLog(extension_id_, params));
46 } 53 }
47 54
48 void DOMActivityLogger::AttachToWorld(int world_id, 55 void DOMActivityLogger::AttachToWorld(int world_id,
49 const std::string& extension_id, 56 const std::string& extension_id,
50 const GURL& url, 57 const GURL& url,
51 const string16& title) { 58 const string16& title) {
52 // Check if extension activity logging is enabled. 59 // Check if extension activity logging is enabled.
53 if (!ChromeRenderProcessObserver::extension_activity_log_enabled()) 60 if (!ChromeRenderProcessObserver::extension_activity_log_enabled())
54 return; 61 return;
55 // If there is no logger registered for world_id, construct a new logger 62 // If there is no logger registered for world_id, construct a new logger
56 // and register it with world_id. 63 // and register it with world_id.
57 if (!WebKit::hasDOMActivityLogger(world_id)) { 64 if (!WebKit::hasDOMActivityLogger(world_id)) {
58 DOMActivityLogger* logger = new DOMActivityLogger(extension_id, url, title); 65 DOMActivityLogger* logger = new DOMActivityLogger(extension_id, url, title);
59 WebKit::setDOMActivityLogger(world_id, logger); 66 WebKit::setDOMActivityLogger(world_id, logger);
60 } 67 }
61 } 68 }
62 69
63 } // namespace extensions 70 } // namespace extensions
64 71
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/dom_activity_logger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698