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

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

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
« no previous file with comments | « extensions/browser/api_activity_monitor.h ('k') | extensions/browser/event_router.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #include "extensions/browser/api_activity_monitor.h"
6
7 #include "base/values.h"
8
9 namespace extensions {
10 namespace activity_monitor {
11
12 namespace {
13
14 Monitor g_event_monitor = nullptr;
15 Monitor g_function_monitor = nullptr;
16 WebRequestMonitor g_web_request_monitor = nullptr;
17
18 } // namespace
19
20 Monitor GetApiEventMonitor() {
21 return g_event_monitor;
22 }
23
24 Monitor GetApiFunctionMonitor() {
25 return g_function_monitor;
26 }
27
28 WebRequestMonitor GetWebRequestMonitor() {
29 return g_web_request_monitor;
30 }
31
32 void SetApiEventMonitor(Monitor event_monitor) {
33 g_event_monitor = event_monitor;
34 }
35
36 void SetApiFunctionMonitor(Monitor function_monitor) {
37 g_function_monitor = function_monitor;
38 }
39
40 void SetWebRequestMonitor(WebRequestMonitor web_request_monitor) {
41 g_web_request_monitor = web_request_monitor;
42 }
43
44 void OnApiEventDispatched(content::BrowserContext* browser_context,
45 const std::string& extension_id,
46 const std::string& event_name,
47 const base::ListValue& event_args) {
48 if (g_event_monitor)
49 g_event_monitor(browser_context, extension_id, event_name, event_args);
50 }
51
52 // Called when an extension calls an API function.
53 void OnApiFunctionCalled(content::BrowserContext* browser_context,
54 const std::string& extension_id,
55 const std::string& api_name,
56 const base::ListValue& args) {
57 if (g_function_monitor)
58 g_function_monitor(browser_context, extension_id, api_name, args);
59 }
60
61 void OnWebRequestApiUsed(content::BrowserContext* browser_context,
62 const std::string& extension_id,
63 const GURL& url,
64 bool is_incognito,
65 const std::string& api_call,
66 std::unique_ptr<base::DictionaryValue> details) {
67 if (g_web_request_monitor) {
68 g_web_request_monitor(browser_context, extension_id, url, is_incognito,
69 api_call, std::move(details));
70 }
71 }
72
73 } // namespace activity_monitor
74 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api_activity_monitor.h ('k') | extensions/browser/event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698