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