OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 18 matching lines...) Expand all Loading... | |
29 class Extension; | 29 class Extension; |
30 | 30 |
31 // A utility for tracing interesting activity for each extension. | 31 // A utility for tracing interesting activity for each extension. |
32 // It writes to an ActivityDatabase on a separate thread to record the activity. | 32 // It writes to an ActivityDatabase on a separate thread to record the activity. |
33 class ActivityLog : public ProfileKeyedService, | 33 class ActivityLog : public ProfileKeyedService, |
34 public TabHelper::ScriptExecutionObserver { | 34 public TabHelper::ScriptExecutionObserver { |
35 public: | 35 public: |
36 enum Activity { | 36 enum Activity { |
37 ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called. | 37 ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called. |
38 ACTIVITY_EXTENSION_API_BLOCK, // Extension API invocation is blocked. | 38 ACTIVITY_EXTENSION_API_BLOCK, // Extension API invocation is blocked. |
39 ACTIVITY_CONTENT_SCRIPT // Content script is executing. | 39 ACTIVITY_CONTENT_SCRIPT, // Content script is executing. |
40 ACTIVITY_EVENT_DISPATCH, // Event sent to listener in extension. | |
Eric Dingle
2013/01/24 16:16:34
Looking back, it would have been nice if those fir
| |
40 }; | 41 }; |
41 | 42 |
42 // Observers can listen for activity events. | 43 // Observers can listen for activity events. |
43 class Observer { | 44 class Observer { |
44 public: | 45 public: |
45 virtual void OnExtensionActivity( | 46 virtual void OnExtensionActivity( |
46 const Extension* extension, | 47 const Extension* extension, |
47 Activity activity, | 48 Activity activity, |
48 const std::string& message) = 0; | 49 const std::string& message) = 0; |
49 }; | 50 }; |
(...skipping 10 matching lines...) Expand all Loading... | |
60 void AddObserver(const Extension* extension, Observer* observer); | 61 void AddObserver(const Extension* extension, Observer* observer); |
61 void RemoveObserver(const Extension* extension, | 62 void RemoveObserver(const Extension* extension, |
62 Observer* observer); | 63 Observer* observer); |
63 | 64 |
64 // Check for the existence observer list by extension_id. | 65 // Check for the existence observer list by extension_id. |
65 bool HasObservers(const Extension* extension) const; | 66 bool HasObservers(const Extension* extension) const; |
66 | 67 |
67 // Log a successful API call made by an extension. | 68 // Log a successful API call made by an extension. |
68 // This will create an APIAction for storage in the database. | 69 // This will create an APIAction for storage in the database. |
69 void LogAPIAction(const Extension* extension, | 70 void LogAPIAction(const Extension* extension, |
70 const std::string& name, // e.g., chrome.tabs.get | 71 const std::string& name, // e.g., tabs.get |
71 const ListValue* args, // the argument values e.g. 46 | 72 const ListValue* args, // the argument values e.g. 46 |
72 const std::string& extra); // any extra logging info | 73 const std::string& extra); // any extra logging info |
73 | 74 |
75 // Log an event notification delivered to an extension. | |
76 // This will crate an APIActiion for storage in the database. | |
Eric Dingle
2013/01/24 16:16:34
*create
*APIAction
mvrable
2013/01/24 18:12:31
Done.
| |
77 void LogEventAction(const Extension* extension, | |
78 const std::string& name, // e.g., tabs.onUpdate | |
79 const ListValue* args, // arguments to the callback | |
Eric Dingle
2013/01/24 16:16:34
All comments should begin capitalized and end with
mvrable
2013/01/24 18:12:31
Is that necessary even here? There isn't much roo
Eric Dingle
2013/01/24 18:56:56
Fine to leave as is.
On 2013/01/24 18:12:31, mvra
| |
80 const std::string& extra); // any extra logging info | |
81 | |
74 // Log a blocked API call made by an extension. | 82 // Log a blocked API call made by an extension. |
75 // This will create a BlockedAction for storage in the database. | 83 // This will create a BlockedAction for storage in the database. |
76 void LogBlockedAction(const Extension* extension, | 84 void LogBlockedAction(const Extension* extension, |
77 const std::string& blocked_call, // eg chrome.tabs.get | 85 const std::string& blocked_call, // eg tabs.get |
Eric Dingle
2013/01/24 16:16:34
Be consistent with your e.g.,
mvrable
2013/01/24 18:12:31
Done.
| |
78 const ListValue* args, // argument values | 86 const ListValue* args, // argument values |
79 const char* reason, // why it's blocked | 87 const char* reason, // why it's blocked |
80 const std::string& extra); // extra logging info | 88 const std::string& extra); // extra logging info |
81 | 89 |
82 // Log an interaction between an extension and a URL. | 90 // Log an interaction between an extension and a URL. |
83 // This will create a UrlAction for storage in the database. | 91 // This will create a UrlAction for storage in the database. |
84 // The technical message might be the list of content scripts that have been | 92 // The technical message might be the list of content scripts that have been |
85 // injected, or the DOM API call; it's what's shown under "More". | 93 // injected, or the DOM API call; it's what's shown under "More". |
86 void LogUrlAction(const Extension* extension, | 94 void LogUrlAction(const Extension* extension, |
87 const UrlAction::UrlActionType verb, // eg XHR | 95 const UrlAction::UrlActionType verb, // eg XHR |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 virtual bool ServiceRedirectedInIncognito() const OVERRIDE; | 188 virtual bool ServiceRedirectedInIncognito() const OVERRIDE; |
181 | 189 |
182 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); | 190 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); |
183 }; | 191 }; |
184 | 192 |
185 | 193 |
186 } // namespace extensions | 194 } // namespace extensions |
187 | 195 |
188 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ | 196 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ |
189 | 197 |
OLD | NEW |