| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/extensions/activity_log/activity_log.h" | 5 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 ActivityLogFactory::ActivityLogFactory() | 166 ActivityLogFactory::ActivityLogFactory() |
| 167 : BrowserContextKeyedServiceFactory( | 167 : BrowserContextKeyedServiceFactory( |
| 168 "ActivityLog", | 168 "ActivityLog", |
| 169 BrowserContextDependencyManager::GetInstance()) { | 169 BrowserContextDependencyManager::GetInstance()) { |
| 170 DependsOn(ExtensionSystemFactory::GetInstance()); | 170 DependsOn(ExtensionSystemFactory::GetInstance()); |
| 171 DependsOn(InstallTrackerFactory::GetInstance()); | 171 DependsOn(InstallTrackerFactory::GetInstance()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // static |
| 175 ActivityLog* ActivityLog::GetInstance(Profile* profile) { |
| 176 return ActivityLogFactory::GetForProfile(profile); |
| 177 } |
| 178 |
| 174 ActivityLogFactory::~ActivityLogFactory() { | 179 ActivityLogFactory::~ActivityLogFactory() { |
| 175 } | 180 } |
| 176 | 181 |
| 177 // ActivityLog | 182 // ActivityLog |
| 178 | 183 |
| 179 // SET THINGS UP. -------------------------------------------------------------- | 184 // SET THINGS UP. -------------------------------------------------------------- |
| 180 | 185 |
| 181 // Use GetInstance instead of directly creating an ActivityLog. | 186 // Use GetInstance instead of directly creating an ActivityLog. |
| 182 ActivityLog::ActivityLog(Profile* profile) | 187 ActivityLog::ActivityLog(Profile* profile) |
| 183 : policy_(NULL), | 188 : policy_(NULL), |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 if (watchdog_app_active_) { | 313 if (watchdog_app_active_) { |
| 309 watchdog_app_active_ = false; | 314 watchdog_app_active_ = false; |
| 310 profile_->GetPrefs()->SetBoolean(prefs::kWatchdogExtensionActive, | 315 profile_->GetPrefs()->SetBoolean(prefs::kWatchdogExtensionActive, |
| 311 false); | 316 false); |
| 312 } | 317 } |
| 313 } | 318 } |
| 314 | 319 |
| 315 void ActivityLog::OnExtensionUninstalled(const Extension* extension) { | 320 void ActivityLog::OnExtensionUninstalled(const Extension* extension) { |
| 316 // If the extension has been uninstalled but not disabled, we delete the | 321 // If the extension has been uninstalled but not disabled, we delete the |
| 317 // database. | 322 // database. |
| 318 if (extension->id() != kActivityLogExtensionId) return; | 323 if (policy_ && extension->id() != kActivityLogExtensionId) |
| 319 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 324 policy_->RemoveExtensionData(extension->id()); |
| 320 switches::kEnableExtensionActivityLogging)) { | 325 if ((extension->id() == kActivityLogExtensionId) && |
| 321 DeleteDatabase(); | 326 (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 327 switches::kEnableExtensionActivityLogging))) { |
| 328 DeleteDatabase(); |
| 322 } | 329 } |
| 323 } | 330 } |
| 324 | 331 |
| 325 // static | |
| 326 ActivityLog* ActivityLog::GetInstance(Profile* profile) { | |
| 327 return ActivityLogFactory::GetForProfile(profile); | |
| 328 } | |
| 329 | |
| 330 void ActivityLog::AddObserver(ActivityLog::Observer* observer) { | 332 void ActivityLog::AddObserver(ActivityLog::Observer* observer) { |
| 331 observers_->AddObserver(observer); | 333 observers_->AddObserver(observer); |
| 332 } | 334 } |
| 333 | 335 |
| 334 void ActivityLog::RemoveObserver(ActivityLog::Observer* observer) { | 336 void ActivityLog::RemoveObserver(ActivityLog::Observer* observer) { |
| 335 observers_->RemoveObserver(observer); | 337 observers_->RemoveObserver(observer); |
| 336 } | 338 } |
| 337 | 339 |
| 338 // static | 340 // static |
| 339 void ActivityLog::RegisterProfilePrefs( | 341 void ActivityLog::RegisterProfilePrefs( |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 RemoveURLs(urls); | 459 RemoveURLs(urls); |
| 458 } | 460 } |
| 459 | 461 |
| 460 void ActivityLog::DeleteDatabase() { | 462 void ActivityLog::DeleteDatabase() { |
| 461 if (!policy_) | 463 if (!policy_) |
| 462 return; | 464 return; |
| 463 policy_->DeleteDatabase(); | 465 policy_->DeleteDatabase(); |
| 464 } | 466 } |
| 465 | 467 |
| 466 } // namespace extensions | 468 } // namespace extensions |
| OLD | NEW |