| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Add/remove observer. | 65 // Add/remove observer. |
| 66 void AddObserver(const Extension* extension, Observer* observer); | 66 void AddObserver(const Extension* extension, Observer* observer); |
| 67 void RemoveObserver(const Extension* extension, | 67 void RemoveObserver(const Extension* extension, |
| 68 Observer* observer); | 68 Observer* observer); |
| 69 | 69 |
| 70 // Check for the existence observer list by extension_id. | 70 // Check for the existence observer list by extension_id. |
| 71 bool HasObservers(const Extension* extension) const; | 71 bool HasObservers(const Extension* extension) const; |
| 72 | 72 |
| 73 // Log a successful API call made by an extension. | 73 // Log a successful API call made by an extension. |
| 74 // This will create an APIAction for storage in the database. | 74 // This will create an APIAction for storage in the database. |
| 75 // (Note: implemented as a wrapper for LogAPIActionInternal.) |
| 75 void LogAPIAction(const Extension* extension, | 76 void LogAPIAction(const Extension* extension, |
| 76 const std::string& name, // e.g., tabs.get | 77 const std::string& name, // e.g., tabs.get |
| 77 const ListValue* args, // the argument values e.g. 46 | 78 const ListValue* args, // the argument values e.g. 46 |
| 78 const std::string& extra); // any extra logging info | 79 const std::string& extra); // any extra logging info |
| 79 | 80 |
| 80 // Log an event notification delivered to an extension. | 81 // Log an event notification delivered to an extension. |
| 81 // This will create an APIAction for storage in the database. | 82 // This will create an APIAction for storage in the database. |
| 83 // (Note: implemented as a wrapper for LogAPIActionInternal.) |
| 82 void LogEventAction(const Extension* extension, | 84 void LogEventAction(const Extension* extension, |
| 83 const std::string& name, // e.g., tabs.onUpdate | 85 const std::string& name, // e.g., tabs.onUpdate |
| 84 const ListValue* args, // arguments to the callback | 86 const ListValue* args, // arguments to the callback |
| 85 const std::string& extra); // any extra logging info | 87 const std::string& extra); // any extra logging info |
| 86 | 88 |
| 87 // Log a blocked API call made by an extension. | 89 // Log a blocked API call made by an extension. |
| 88 // This will create a BlockedAction for storage in the database. | 90 // This will create a BlockedAction for storage in the database. |
| 89 void LogBlockedAction(const Extension* extension, | 91 void LogBlockedAction(const Extension* extension, |
| 90 const std::string& blocked_call, // e.g., tabs.get | 92 const std::string& blocked_call, // e.g., tabs.get |
| 91 const ListValue* args, // argument values | 93 const ListValue* args, // argument values |
| 92 const char* reason, // why it's blocked | 94 const char* reason, // why it's blocked |
| 93 const std::string& extra); // extra logging info | 95 const std::string& extra); // extra logging info |
| 94 | 96 |
| 95 // Log an interaction between an extension and a URL. | 97 // Log an interaction between an extension and a URL. |
| 96 // This will create a UrlAction for storage in the database. | 98 // This will create a DOMAction for storage in the database. |
| 97 // The technical message might be the list of content scripts that have been | 99 // The technical message might be the list of content scripts that have been |
| 98 // injected, or the DOM API call; it's what's shown under "More". | 100 // injected, or the DOM API call; it's what's shown under "More". |
| 99 void LogUrlAction(const Extension* extension, | 101 void LogDOMAction(const Extension* extension, |
| 100 const UrlAction::UrlActionType verb, // e.g., XHR | |
| 101 const GURL& url, // target URL | 102 const GURL& url, // target URL |
| 102 const string16& url_title, // title of the URL, | 103 const string16& url_title, // title of the URL |
| 103 // can be empty string | 104 const std::string& api_call, // api call |
| 104 const std::string& technical_message, // "More" | 105 const ListValue* args, // arguments |
| 105 const std::string& extra); // extra logging info | 106 const std::string& extra); // extra logging info |
| 106 | 107 |
| 107 // An error has happened; we want to rollback and close the db. | 108 // An error has happened; we want to rollback and close the db. |
| 108 // Needs to be public so the error delegate can call it. | 109 // Needs to be public so the error delegate can call it. |
| 109 void KillActivityLogDatabase(); | 110 void KillActivityLogDatabase(); |
| 110 | 111 |
| 111 private: | 112 private: |
| 112 friend class ActivityLogFactory; | 113 friend class ActivityLogFactory; |
| 113 | 114 |
| 114 explicit ActivityLog(Profile* profile); | 115 explicit ActivityLog(Profile* profile); |
| 115 virtual ~ActivityLog(); | 116 virtual ~ActivityLog(); |
| 116 | 117 |
| 118 // We log callbacks and API calls very similarly, so we handle them the same |
| 119 // way internally. |
| 120 void LogAPIActionInternal( |
| 121 const Extension* extension, |
| 122 const std::string& api_call, |
| 123 const ListValue* args, |
| 124 const std::string& extra, |
| 125 const APIAction::Type type); |
| 126 |
| 127 // We log content script injection and DOM API calls using the same underlying |
| 128 // mechanism, so they have the same internal logging structure. |
| 129 void LogDOMActionInternal(const Extension* extension, |
| 130 const GURL& url, |
| 131 const string16& url_title, |
| 132 const std::string& api_call, |
| 133 const ListValue* args, |
| 134 const std::string& extra, |
| 135 DOMAction::DOMActionType verb); |
| 136 |
| 117 // TabHelper::ScriptExecutionObserver implementation. | 137 // TabHelper::ScriptExecutionObserver implementation. |
| 118 // Fires when a ContentScript is executed. | 138 // Fires when a ContentScript is executed. |
| 119 virtual void OnScriptsExecuted( | 139 virtual void OnScriptsExecuted( |
| 120 const content::WebContents* web_contents, | 140 const content::WebContents* web_contents, |
| 121 const ExecutingScriptsMap& extension_ids, | 141 const ExecutingScriptsMap& extension_ids, |
| 122 int32 page_id, | 142 int32 page_id, |
| 123 const GURL& on_url) OVERRIDE; | 143 const GURL& on_url) OVERRIDE; |
| 124 | 144 |
| 125 // The callback when initializing the database. | 145 // The callback when initializing the database. |
| 126 void OnDBInitComplete(); | 146 void OnDBInitComplete(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 212 |
| 193 virtual bool ServiceRedirectedInIncognito() const OVERRIDE; | 213 virtual bool ServiceRedirectedInIncognito() const OVERRIDE; |
| 194 | 214 |
| 195 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); | 215 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); |
| 196 }; | 216 }; |
| 197 | 217 |
| 198 | 218 |
| 199 } // namespace extensions | 219 } // namespace extensions |
| 200 | 220 |
| 201 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ | 221 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_H_ |
| OLD | NEW |