| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 295 } |
| 296 | 296 |
| 297 ActivityLogFactory::ActivityLogFactory() | 297 ActivityLogFactory::ActivityLogFactory() |
| 298 : BrowserContextKeyedServiceFactory( | 298 : BrowserContextKeyedServiceFactory( |
| 299 "ActivityLog", | 299 "ActivityLog", |
| 300 BrowserContextDependencyManager::GetInstance()) { | 300 BrowserContextDependencyManager::GetInstance()) { |
| 301 DependsOn(ExtensionSystemFactory::GetInstance()); | 301 DependsOn(ExtensionSystemFactory::GetInstance()); |
| 302 DependsOn(InstallTrackerFactory::GetInstance()); | 302 DependsOn(InstallTrackerFactory::GetInstance()); |
| 303 } | 303 } |
| 304 | 304 |
| 305 // static | |
| 306 ActivityLog* ActivityLog::GetInstance(Profile* profile) { | |
| 307 return ActivityLogFactory::GetForProfile(profile); | |
| 308 } | |
| 309 | |
| 310 ActivityLogFactory::~ActivityLogFactory() { | 305 ActivityLogFactory::~ActivityLogFactory() { |
| 311 } | 306 } |
| 312 | 307 |
| 313 // ActivityLog | 308 // ActivityLog |
| 314 | 309 |
| 315 // SET THINGS UP. -------------------------------------------------------------- | 310 // SET THINGS UP. -------------------------------------------------------------- |
| 316 | 311 |
| 317 // Use GetInstance instead of directly creating an ActivityLog. | 312 // Use GetInstance instead of directly creating an ActivityLog. |
| 318 ActivityLog::ActivityLog(Profile* profile) | 313 ActivityLog::ActivityLog(Profile* profile) |
| 319 : policy_(NULL), | 314 : policy_(NULL), |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 if (watchdog_app_active_) { | 439 if (watchdog_app_active_) { |
| 445 watchdog_app_active_ = false; | 440 watchdog_app_active_ = false; |
| 446 profile_->GetPrefs()->SetBoolean(prefs::kWatchdogExtensionActive, | 441 profile_->GetPrefs()->SetBoolean(prefs::kWatchdogExtensionActive, |
| 447 false); | 442 false); |
| 448 } | 443 } |
| 449 } | 444 } |
| 450 | 445 |
| 451 void ActivityLog::OnExtensionUninstalled(const Extension* extension) { | 446 void ActivityLog::OnExtensionUninstalled(const Extension* extension) { |
| 452 // If the extension has been uninstalled but not disabled, we delete the | 447 // If the extension has been uninstalled but not disabled, we delete the |
| 453 // database. | 448 // database. |
| 454 if (extension->id() == kActivityLogExtensionId) { | 449 if (extension->id() != kActivityLogExtensionId) return; |
| 455 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 450 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 456 switches::kEnableExtensionActivityLogging)) { | 451 switches::kEnableExtensionActivityLogging)) { |
| 457 DeleteDatabase(); | 452 DeleteDatabase(); |
| 458 } | |
| 459 } else { | |
| 460 if (policy_) | |
| 461 policy_->RemoveExtensionData(extension->id()); | |
| 462 } | 453 } |
| 463 } | 454 } |
| 464 | 455 |
| 456 // static |
| 457 ActivityLog* ActivityLog::GetInstance(Profile* profile) { |
| 458 return ActivityLogFactory::GetForProfile(profile); |
| 459 } |
| 460 |
| 465 void ActivityLog::AddObserver(ActivityLog::Observer* observer) { | 461 void ActivityLog::AddObserver(ActivityLog::Observer* observer) { |
| 466 observers_->AddObserver(observer); | 462 observers_->AddObserver(observer); |
| 467 } | 463 } |
| 468 | 464 |
| 469 void ActivityLog::RemoveObserver(ActivityLog::Observer* observer) { | 465 void ActivityLog::RemoveObserver(ActivityLog::Observer* observer) { |
| 470 observers_->RemoveObserver(observer); | 466 observers_->RemoveObserver(observer); |
| 471 } | 467 } |
| 472 | 468 |
| 473 // static | 469 // static |
| 474 void ActivityLog::RegisterProfilePrefs( | 470 void ActivityLog::RegisterProfilePrefs( |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 RemoveURLs(urls); | 584 RemoveURLs(urls); |
| 589 } | 585 } |
| 590 | 586 |
| 591 void ActivityLog::DeleteDatabase() { | 587 void ActivityLog::DeleteDatabase() { |
| 592 if (!policy_) | 588 if (!policy_) |
| 593 return; | 589 return; |
| 594 policy_->DeleteDatabase(); | 590 policy_->DeleteDatabase(); |
| 595 } | 591 } |
| 596 | 592 |
| 597 } // namespace extensions | 593 } // namespace extensions |
| OLD | NEW |