| 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_ACTIVITY_LOG_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace extensions { | 35 namespace extensions { |
| 36 class Extension; | 36 class Extension; |
| 37 class ExtensionRegistry; | 37 class ExtensionRegistry; |
| 38 | 38 |
| 39 // A utility for tracing interesting activity for each extension. | 39 // A utility for tracing interesting activity for each extension. |
| 40 // It writes to an ActivityDatabase on a separate thread to record the activity. | 40 // It writes to an ActivityDatabase on a separate thread to record the activity. |
| 41 // Each profile has different extensions, so we keep a different database for | 41 // Each profile has different extensions, so we keep a different database for |
| 42 // each profile. | 42 // each profile. |
| 43 // |
| 44 // TODO(thestig) Remove ENABLE_EXTENSIONS checks when ActivityLog is no longer |
| 45 // built on platforms that do not support extensions. |
| 43 class ActivityLog : public BrowserContextKeyedAPI, | 46 class ActivityLog : public BrowserContextKeyedAPI, |
| 44 public ApiActivityMonitor, | 47 public ApiActivityMonitor, |
| 48 #if defined(ENABLE_EXTENSIONS) |
| 45 public TabHelper::ScriptExecutionObserver, | 49 public TabHelper::ScriptExecutionObserver, |
| 50 #endif |
| 46 public ExtensionRegistryObserver { | 51 public ExtensionRegistryObserver { |
| 47 public: | 52 public: |
| 48 // Observers can listen for activity events. There is probably only one | 53 // Observers can listen for activity events. There is probably only one |
| 49 // observer: the activityLogPrivate API. | 54 // observer: the activityLogPrivate API. |
| 50 class Observer { | 55 class Observer { |
| 51 public: | 56 public: |
| 52 virtual void OnExtensionActivity(scoped_refptr<Action> activity) = 0; | 57 virtual void OnExtensionActivity(scoped_refptr<Action> activity) = 0; |
| 53 }; | 58 }; |
| 54 | 59 |
| 55 static BrowserContextKeyedAPIFactory<ActivityLog>* GetFactoryInstance(); | 60 static BrowserContextKeyedAPIFactory<ActivityLog>* GetFactoryInstance(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 142 |
| 138 // Specifies if we need to record actions to the db. If so, we need to log to | 143 // Specifies if we need to record actions to the db. If so, we need to log to |
| 139 // the database. This is true if the Watchdog app is active *or* the | 144 // the database. This is true if the Watchdog app is active *or* the |
| 140 // --enable-extension-activity-logging flag is set. | 145 // --enable-extension-activity-logging flag is set. |
| 141 bool IsDatabaseEnabled(); | 146 bool IsDatabaseEnabled(); |
| 142 | 147 |
| 143 // Delayed initialization of ExtensionRegistry which waits until after the | 148 // Delayed initialization of ExtensionRegistry which waits until after the |
| 144 // ExtensionSystem/ExtensionService are done with their own setup. | 149 // ExtensionSystem/ExtensionService are done with their own setup. |
| 145 void StartObserving(); | 150 void StartObserving(); |
| 146 | 151 |
| 152 #if defined(ENABLE_EXTENSIONS) |
| 147 // TabHelper::ScriptExecutionObserver implementation. | 153 // TabHelper::ScriptExecutionObserver implementation. |
| 148 // Fires when a ContentScript is executed. | 154 // Fires when a ContentScript is executed. |
| 149 virtual void OnScriptsExecuted( | 155 virtual void OnScriptsExecuted( |
| 150 const content::WebContents* web_contents, | 156 const content::WebContents* web_contents, |
| 151 const ExecutingScriptsMap& extension_ids, | 157 const ExecutingScriptsMap& extension_ids, |
| 152 int32 page_id, | 158 int32 page_id, |
| 153 const GURL& on_url) OVERRIDE; | 159 const GURL& on_url) OVERRIDE; |
| 160 #endif |
| 154 | 161 |
| 155 // At the moment, ActivityLog will use only one policy for summarization. | 162 // At the moment, ActivityLog will use only one policy for summarization. |
| 156 // These methods are used to choose and set the most appropriate policy. | 163 // These methods are used to choose and set the most appropriate policy. |
| 157 // Changing policies at runtime is not recommended, and likely only should be | 164 // Changing policies at runtime is not recommended, and likely only should be |
| 158 // done for unit tests. | 165 // done for unit tests. |
| 159 void ChooseDatabasePolicy(); | 166 void ChooseDatabasePolicy(); |
| 160 void SetDatabasePolicy(ActivityLogPolicy::PolicyType policy_type); | 167 void SetDatabasePolicy(ActivityLogPolicy::PolicyType policy_type); |
| 161 | 168 |
| 162 // BrowserContextKeyedAPI implementation. | 169 // BrowserContextKeyedAPI implementation. |
| 163 static const char* service_name() { return "ActivityLog"; } | 170 static const char* service_name() { return "ActivityLog"; } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 FRIEND_TEST_ALL_PREFIXES(ActivityLogEnabledTest, WatchdogSwitch); | 222 FRIEND_TEST_ALL_PREFIXES(ActivityLogEnabledTest, WatchdogSwitch); |
| 216 DISALLOW_COPY_AND_ASSIGN(ActivityLog); | 223 DISALLOW_COPY_AND_ASSIGN(ActivityLog); |
| 217 }; | 224 }; |
| 218 | 225 |
| 219 template <> | 226 template <> |
| 220 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies(); | 227 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies(); |
| 221 | 228 |
| 222 } // namespace extensions | 229 } // namespace extensions |
| 223 | 230 |
| 224 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ | 231 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ |
| OLD | NEW |