Revert of Support braille commands in ChromeVox Next. (patchset #4 id:60001 of https...
[chromium-blink-merge.git] / extensions / renderer / dom_activity_logger.h
blob13dfd42bb788d038f0f90fe554ea6a57e8146a26
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_RENDERER_DOM_ACTIVITY_LOGGER_H_
6 #define EXTENSIONS_RENDERER_DOM_ACTIVITY_LOGGER_H_
8 #include <string>
10 #include "base/macros.h"
11 #include "extensions/common/dom_action_types.h"
12 #include "third_party/WebKit/public/web/WebDOMActivityLogger.h"
13 #include "v8/include/v8.h"
15 namespace base {
16 class ListValue;
19 namespace blink {
20 class WebString;
21 class WebURL;
24 namespace content {
25 class V8ValueConverter;
28 namespace extensions {
30 // Used to log DOM API calls from within WebKit. The events are sent via IPC to
31 // extensions::ActivityLog for recording and display.
32 class DOMActivityLogger: public blink::WebDOMActivityLogger {
33 public:
34 static const int kMainWorldId = 0;
35 explicit DOMActivityLogger(const std::string& extension_id);
36 virtual ~DOMActivityLogger();
38 // Check (using the WebKit API) if there is no logger attached to the world
39 // corresponding to world_id, and if so, construct a new logger and attach it.
40 // world_id = 0 indicates the main world.
41 static void AttachToWorld(int world_id,
42 const std::string& extension_id);
44 private:
45 // blink::WebDOMActivityLogger implementation.
46 // Marshals the arguments into an ExtensionHostMsg_DOMAction_Params and sends
47 // it over to the browser (via IPC) for appending it to the extension activity
48 // log.
49 // These methods don't have the override keyword due to the complexities it
50 // introduces when changes blink apis.
51 virtual void logGetter(const blink::WebString& api_name,
52 const blink::WebURL& url,
53 const blink::WebString& title);
54 virtual void logSetter(const blink::WebString& api_name,
55 const v8::Local<v8::Value>& new_value,
56 const blink::WebURL& url,
57 const blink::WebString& title);
58 virtual void logSetter(const blink::WebString& api_name,
59 const v8::Local<v8::Value>& new_value,
60 const v8::Local<v8::Value>& old_value,
61 const blink::WebURL& url,
62 const blink::WebString& title);
63 virtual void logMethod(const blink::WebString& api_name,
64 int argc,
65 const v8::Local<v8::Value>* argv,
66 const blink::WebURL& url,
67 const blink::WebString& title);
68 virtual void logEvent(const blink::WebString& event_name,
69 int argc,
70 const blink::WebString* argv,
71 const blink::WebURL& url,
72 const blink::WebString& title);
74 // Helper function to actually send the message across IPC.
75 void SendDomActionMessage(const std::string& api_call,
76 const GURL& url,
77 const base::string16& url_title,
78 DomActionType::Type call_type,
79 scoped_ptr<base::ListValue> args);
81 // The id of the extension with which this logger is associated.
82 std::string extension_id_;
84 DISALLOW_COPY_AND_ASSIGN(DOMActivityLogger);
87 } // namespace extensions
89 #endif // EXTENSIONS_RENDERER_DOM_ACTIVITY_LOGGER_H_