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

Side by Side Diff: extensions/browser/api_activity_monitor.h

Issue 2077723002: [Extensions] Short-circuit activity logging if not enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add Test Created 4 years, 6 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
OLDNEW
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 #ifndef EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_ 5 #ifndef EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_
6 #define EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_ 6 #define EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 class GURL;
11 12
12 namespace base { 13 namespace base {
14 class DictionaryValue;
13 class ListValue; 15 class ListValue;
14 } 16 }
15 17
18 namespace content {
19 class BrowserContext;
20 }
21
16 namespace extensions { 22 namespace extensions {
23 namespace activity_monitor {
17 24
18 // ApiActivityMonitor is used to monitor extension API event dispatch and API 25 using Monitor = void (*)(content::BrowserContext* browser_context,
19 // function calls. An embedder can use this interface to log low-level extension 26 const std::string& extension_id,
20 // activity. 27 const std::string& activity_name,
21 class ApiActivityMonitor { 28 const base::ListValue& event_args);
22 public: 29 using WebRequestMonitor =
23 // Called when an API event is dispatched to an extension. 30 void (*)(content::BrowserContext* browser_context,
24 virtual void OnApiEventDispatched( 31 const std::string& extension_id,
25 const std::string& extension_id, 32 const GURL& url,
26 const std::string& event_name, 33 bool is_incognito,
27 std::unique_ptr<base::ListValue> event_args) = 0; 34 const std::string& api_call,
35 std::unique_ptr<base::DictionaryValue> details);
28 36
29 // Called when an extension calls an API function. 37 // Get or set the current global monitor for API events and functions. Note that
30 virtual void OnApiFunctionCalled(const std::string& extension_id, 38 // these handlers *must* be allowed to be called on any thread!
31 const std::string& api_name, 39 // Additionally, since this may be called on any thead, |browser_context| is
32 std::unique_ptr<base::ListValue> args) = 0; 40 // unsafe to use unless posted to the UI thread.
41 Monitor GetApiEventMonitor();
42 Monitor GetApiFunctionMonitor();
43 WebRequestMonitor GetWebRequestMonitor();
44 void SetApiEventMonitor(Monitor event_monitor);
45 void SetApiFunctionMonitor(Monitor function_monitor);
46 void SetWebRequestMonitor(WebRequestMonitor web_request_monitor);
33 47
34 protected: 48 // Called when an API event is dispatched to an extension. May be called on any
35 virtual ~ApiActivityMonitor() {} 49 // thread. |browser_context| is unsafe to use.
36 }; 50 void OnApiEventDispatched(content::BrowserContext* browser_context,
51 const std::string& extension_id,
52 const std::string& event_name,
53 const base::ListValue& event_args);
37 54
55 // Called when an extension calls an API function. May be called on any thread.
56 // |browser_context| is unsafe to use.
57 void OnApiFunctionCalled(content::BrowserContext* browser_context,
58 const std::string& extension_id,
59 const std::string& api_name,
60 const base::ListValue& args);
61
62 // Called when an extension uses the web request API. May be called on any
63 // thread. |browser_context| is unsafe to use.
64 void OnWebRequestApiUsed(content::BrowserContext* browser_context,
65 const std::string& extension_id,
66 const GURL& url,
67 bool is_incognito,
68 const std::string& api_call,
69 std::unique_ptr<base::DictionaryValue> details);
70
71 } // namespace activity_monitor
38 } // namespace extensions 72 } // namespace extensions
39 73
40 #endif // EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_ 74 #endif // EXTENSIONS_BROWSER_API_ACTIVITY_MONITOR_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/web_request/web_request_event_router_delegate.cc ('k') | extensions/browser/api_activity_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698