| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 db_enabled_(false), | 357 db_enabled_(false), |
| 358 testing_mode_(false), | 358 testing_mode_(false), |
| 359 has_threads_(true), | 359 has_threads_(true), |
| 360 extension_registry_observer_(this), | 360 extension_registry_observer_(this), |
| 361 watchdog_apps_active_(0) { | 361 watchdog_apps_active_(0) { |
| 362 // This controls whether logging statements are printed & which policy is set. | 362 // This controls whether logging statements are printed & which policy is set. |
| 363 testing_mode_ = CommandLine::ForCurrentProcess()->HasSwitch( | 363 testing_mode_ = CommandLine::ForCurrentProcess()->HasSwitch( |
| 364 switches::kEnableExtensionActivityLogTesting); | 364 switches::kEnableExtensionActivityLogTesting); |
| 365 | 365 |
| 366 // Check if the watchdog extension is previously installed and active. | 366 // Check if the watchdog extension is previously installed and active. |
| 367 // It was originally a boolean, but we've had to move to an integer. Handle | |
| 368 // the legacy case. | |
| 369 // TODO(felt): In M34, remove the legacy code & old pref. | |
| 370 if (profile_->GetPrefs()->GetBoolean(prefs::kWatchdogExtensionActiveOld)) | |
| 371 profile_->GetPrefs()->SetInteger(prefs::kWatchdogExtensionActive, 1); | |
| 372 watchdog_apps_active_ = | 367 watchdog_apps_active_ = |
| 373 profile_->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive); | 368 profile_->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive); |
| 374 | 369 |
| 375 observers_ = new ObserverListThreadSafe<Observer>; | 370 observers_ = new ObserverListThreadSafe<Observer>; |
| 376 | 371 |
| 377 // Check that the right threads exist for logging to the database. | 372 // Check that the right threads exist for logging to the database. |
| 378 // If not, we shouldn't try to do things that require them. | 373 // If not, we shouldn't try to do things that require them. |
| 379 if (!BrowserThread::IsMessageLoopValid(BrowserThread::DB) || | 374 if (!BrowserThread::IsMessageLoopValid(BrowserThread::DB) || |
| 380 !BrowserThread::IsMessageLoopValid(BrowserThread::FILE) || | 375 !BrowserThread::IsMessageLoopValid(BrowserThread::FILE) || |
| 381 !BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 376 !BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 observers_->RemoveObserver(observer); | 509 observers_->RemoveObserver(observer); |
| 515 } | 510 } |
| 516 | 511 |
| 517 // static | 512 // static |
| 518 void ActivityLog::RegisterProfilePrefs( | 513 void ActivityLog::RegisterProfilePrefs( |
| 519 user_prefs::PrefRegistrySyncable* registry) { | 514 user_prefs::PrefRegistrySyncable* registry) { |
| 520 registry->RegisterIntegerPref( | 515 registry->RegisterIntegerPref( |
| 521 prefs::kWatchdogExtensionActive, | 516 prefs::kWatchdogExtensionActive, |
| 522 false, | 517 false, |
| 523 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 518 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 524 registry->RegisterBooleanPref( | |
| 525 prefs::kWatchdogExtensionActiveOld, | |
| 526 false, | |
| 527 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 528 } | 519 } |
| 529 | 520 |
| 530 // LOG ACTIONS. ---------------------------------------------------------------- | 521 // LOG ACTIONS. ---------------------------------------------------------------- |
| 531 | 522 |
| 532 void ActivityLog::LogAction(scoped_refptr<Action> action) { | 523 void ActivityLog::LogAction(scoped_refptr<Action> action) { |
| 533 if (ActivityLogAPI::IsExtensionWhitelisted(action->extension_id())) | 524 if (ActivityLogAPI::IsExtensionWhitelisted(action->extension_id())) |
| 534 return; | 525 return; |
| 535 | 526 |
| 536 // Perform some preprocessing of the Action data: convert tab IDs to URLs and | 527 // Perform some preprocessing of the Action data: convert tab IDs to URLs and |
| 537 // mask out incognito URLs if appropriate. | 528 // mask out incognito URLs if appropriate. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 database_policy_->DeleteDatabase(); | 674 database_policy_->DeleteDatabase(); |
| 684 } | 675 } |
| 685 | 676 |
| 686 template <> | 677 template <> |
| 687 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() { | 678 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() { |
| 688 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 679 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 689 DependsOn(ExtensionRegistryFactory::GetInstance()); | 680 DependsOn(ExtensionRegistryFactory::GetInstance()); |
| 690 } | 681 } |
| 691 | 682 |
| 692 } // namespace extensions | 683 } // namespace extensions |
| OLD | NEW |