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 #ifndef CHROME_RENDERER_EXTENSIONS_DOM_ACTIVITY_LOGGER_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_DOM_ACTIVITY_LOGGER_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_DOM_ACTIVITY_LOGGER_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_DOM_ACTIVITY_LOGGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
11 #include "chrome/common/extensions/dom_action_types.h" | |
11 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
12 #include "third_party/WebKit/public/platform/WebURL.h" | 13 #include "third_party/WebKit/public/platform/WebURL.h" |
13 #include "third_party/WebKit/public/web/WebDOMActivityLogger.h" | 14 #include "third_party/WebKit/public/web/WebDOMActivityLogger.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
16 | 17 |
18 namespace base { | |
19 class ListValue; | |
20 } | |
21 | |
17 namespace content { | 22 namespace content { |
18 class V8ValueConverter; | 23 class V8ValueConverter; |
19 } | 24 } |
20 | 25 |
21 namespace extensions { | 26 namespace extensions { |
22 | 27 |
23 class ActivityLogConverterStrategy; | |
24 | |
25 // Used to log DOM API calls from within WebKit. The events are sent via IPC to | 28 // Used to log DOM API calls from within WebKit. The events are sent via IPC to |
26 // extensions::ActivityLog for recording and display. | 29 // extensions::ActivityLog for recording and display. |
27 class DOMActivityLogger: public blink::WebDOMActivityLogger { | 30 class DOMActivityLogger: public blink::WebDOMActivityLogger { |
28 public: | 31 public: |
29 static const int kMainWorldId = 0; | 32 static const int kMainWorldId = 0; |
30 explicit DOMActivityLogger(const std::string& extension_id); | 33 explicit DOMActivityLogger(const std::string& extension_id); |
31 virtual ~DOMActivityLogger(); | 34 virtual ~DOMActivityLogger(); |
32 | 35 |
33 // Marshalls the arguments into an ExtensionHostMsg_DOMAction_Params | 36 // This will soon be deprecated, and converted to the logX methods below. |
34 // and sends it over to the browser (via IPC) for appending it to the | |
35 // extension activity log. | |
36 // (Overrides the log method in blink::WebDOMActivityLogger) | |
37 virtual void log(const blink::WebString& api_name, | 37 virtual void log(const blink::WebString& api_name, |
38 int argc, | 38 int argc, |
39 const v8::Handle<v8::Value> argv[], | 39 const v8::Handle<v8::Value> argv[], |
40 const blink::WebString& call_type, | 40 const blink::WebString& call_type, |
41 const blink::WebURL& url, | 41 const blink::WebURL& url, |
42 const blink::WebString& title) OVERRIDE; | 42 const blink::WebString& title); |
43 | 43 |
44 // Check (using the WebKit API) if there is no logger attached to the world | 44 // Check (using the WebKit API) if there is no logger attached to the world |
45 // corresponding to world_id, and if so, construct a new logger and attach it. | 45 // corresponding to world_id, and if so, construct a new logger and attach it. |
46 // world_id = 0 indicates the main world. | 46 // world_id = 0 indicates the main world. |
47 static void AttachToWorld(int world_id, | 47 static void AttachToWorld(int world_id, |
48 const std::string& extension_id); | 48 const std::string& extension_id); |
49 | 49 |
50 private: | 50 private: |
51 // blink::WebDOMActivityLogger implementation. | |
52 // Marshals the arguments into an ExtensionHostMsg_DOMAction_Params and sends | |
53 // it over to the browser (via IPC) for appending it to the extension activity | |
54 // log. | |
55 // These methods don't have the OVERRIDE keyword due to the complexities it | |
56 // introduces when changes blink apis. | |
57 virtual void logGetter(const blink::WebString& api_name, | |
58 const blink::WebURL& url, | |
59 const blink::WebString& title); | |
60 virtual void logSetter(const blink::WebString& api_name, | |
61 const v8::Handle<v8::Value>& new_value, | |
not at google - send to devlin
2014/04/24 17:35:56
the only difference is that this doesn't take an o
Devlin
2014/04/24 17:45:30
Haha I did, originally, but blink folks preferred
not at google - send to devlin
2014/04/24 17:48:38
you don't need to construct an empty *value* just
Devlin
2014/04/24 17:57:55
Ah, right. Okay, done on chrome side.
| |
62 const blink::WebURL& url, | |
63 const blink::WebString& title); | |
64 virtual void logSetter(const blink::WebString& api_name, | |
65 const v8::Handle<v8::Value>& new_value, | |
66 const v8::Handle<v8::Value>& old_value, | |
not at google - send to devlin
2014/04/24 17:35:56
i find it odd taking the new value after the odd i
Devlin
2014/04/24 17:45:30
{assuming you meant taking old after new}
Mainly,
| |
67 const blink::WebURL& url, | |
68 const blink::WebString& title); | |
69 virtual void logMethod(const blink::WebString& api_name, | |
70 int argc, | |
71 const v8::Handle<v8::Value>* argv, | |
72 const blink::WebURL& url, | |
73 const blink::WebString& title); | |
74 | |
75 // Helper function to actually send the message across IPC. | |
76 void SendDomActionMessage(const std::string& api_call, | |
77 const GURL& url, | |
78 const base::string16& url_title, | |
79 DomActionType::Type call_type, | |
80 scoped_ptr<base::ListValue> args); | |
81 | |
82 // The id of the extension with which this logger is associated. | |
51 std::string extension_id_; | 83 std::string extension_id_; |
52 | 84 |
53 DISALLOW_COPY_AND_ASSIGN(DOMActivityLogger); | 85 DISALLOW_COPY_AND_ASSIGN(DOMActivityLogger); |
54 }; | 86 }; |
55 | 87 |
56 } // namespace extensions | 88 } // namespace extensions |
57 | 89 |
58 #endif // CHROME_RENDERER_EXTENSIONS_DOM_ACTIVITY_LOGGER_H_ | 90 #endif // CHROME_RENDERER_EXTENSIONS_DOM_ACTIVITY_LOGGER_H_ |
59 | 91 |
OLD | NEW |