| 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 16 matching lines...) Expand all Loading... |
| 27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 28 | 28 |
| 29 class Profile; | 29 class Profile; |
| 30 using content::BrowserThread; | 30 using content::BrowserThread; |
| 31 | 31 |
| 32 namespace extensions { | 32 namespace extensions { |
| 33 class Extension; | 33 class Extension; |
| 34 | 34 |
| 35 // A utility for tracing interesting activity for each extension. | 35 // A utility for tracing interesting activity for each extension. |
| 36 // It writes to an ActivityDatabase on a separate thread to record the activity. | 36 // It writes to an ActivityDatabase on a separate thread to record the activity. |
| 37 class ActivityLog : public ProfileKeyedService, | 37 class ActivityLog : public BrowserContextKeyedService, |
| 38 public TabHelper::ScriptExecutionObserver { | 38 public TabHelper::ScriptExecutionObserver { |
| 39 public: | 39 public: |
| 40 enum Activity { | 40 enum Activity { |
| 41 ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called. | 41 ACTIVITY_EXTENSION_API_CALL, // Extension API invocation is called. |
| 42 ACTIVITY_EXTENSION_API_BLOCK, // Extension API invocation is blocked. | 42 ACTIVITY_EXTENSION_API_BLOCK, // Extension API invocation is blocked. |
| 43 ACTIVITY_CONTENT_SCRIPT, // Content script is executing. | 43 ACTIVITY_CONTENT_SCRIPT, // Content script is executing. |
| 44 ACTIVITY_EVENT_DISPATCH, // Event sent to listener in extension. | 44 ACTIVITY_EVENT_DISPATCH, // Event sent to listener in extension. |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // Observers can listen for activity events. | 47 // Observers can listen for activity events. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 bool testing_mode_; | 224 bool testing_mode_; |
| 225 base::hash_set<std::string> arg_whitelist_api_; | 225 base::hash_set<std::string> arg_whitelist_api_; |
| 226 | 226 |
| 227 Profile* profile_; | 227 Profile* profile_; |
| 228 | 228 |
| 229 DISALLOW_COPY_AND_ASSIGN(ActivityLog); | 229 DISALLOW_COPY_AND_ASSIGN(ActivityLog); |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 // Each profile has different extensions, so we keep a different database for | 232 // Each profile has different extensions, so we keep a different database for |
| 233 // each profile. | 233 // each profile. |
| 234 class ActivityLogFactory : public ProfileKeyedServiceFactory { | 234 class ActivityLogFactory : public BrowserContextKeyedServiceFactory { |
| 235 public: | 235 public: |
| 236 static ActivityLog* GetForProfile(Profile* profile) { | 236 static ActivityLog* GetForProfile(Profile* profile) { |
| 237 return static_cast<ActivityLog*>( | 237 return static_cast<ActivityLog*>( |
| 238 GetInstance()->GetServiceForProfile(profile, true)); | 238 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 239 } | 239 } |
| 240 | 240 |
| 241 static ActivityLogFactory* GetInstance(); | 241 static ActivityLogFactory* GetInstance(); |
| 242 | 242 |
| 243 private: | 243 private: |
| 244 friend struct DefaultSingletonTraits<ActivityLogFactory>; | 244 friend struct DefaultSingletonTraits<ActivityLogFactory>; |
| 245 ActivityLogFactory() | 245 ActivityLogFactory() |
| 246 : ProfileKeyedServiceFactory("ActivityLog", | 246 : BrowserContextKeyedServiceFactory("ActivityLog", |
| 247 ProfileDependencyManager::GetInstance()) {} | 247 BrowserContextDependencyManager::GetInstance(
)) {} |
| 248 virtual ~ActivityLogFactory() {} | 248 virtual ~ActivityLogFactory() {} |
| 249 | 249 |
| 250 virtual ProfileKeyedService* BuildServiceInstanceFor( | 250 virtual BrowserContextKeyedService* BuildServiceInstanceFor( |
| 251 content::BrowserContext* profile) const OVERRIDE; | 251 content::BrowserContext* profile) const OVERRIDE; |
| 252 | 252 |
| 253 virtual content::BrowserContext* GetBrowserContextToUse( | 253 virtual content::BrowserContext* GetBrowserContextToUse( |
| 254 content::BrowserContext* context) const OVERRIDE; | 254 content::BrowserContext* context) const OVERRIDE; |
| 255 | 255 |
| 256 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); | 256 DISALLOW_COPY_AND_ASSIGN(ActivityLogFactory); |
| 257 }; | 257 }; |
| 258 | 258 |
| 259 | 259 |
| 260 } // namespace extensions | 260 } // namespace extensions |
| 261 | 261 |
| 262 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ | 262 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_H_ |
| OLD | NEW |