Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/browser/extensions/activity_log/activity_log.cc

Issue 819133004: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 : database_policy_(NULL), 353 : database_policy_(NULL),
354 database_policy_type_(ActivityLogPolicy::POLICY_INVALID), 354 database_policy_type_(ActivityLogPolicy::POLICY_INVALID),
355 uma_policy_(NULL), 355 uma_policy_(NULL),
356 profile_(Profile::FromBrowserContext(context)), 356 profile_(Profile::FromBrowserContext(context)),
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_ = base::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 watchdog_apps_active_ = 367 watchdog_apps_active_ =
368 profile_->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive); 368 profile_->GetPrefs()->GetInteger(prefs::kWatchdogExtensionActive);
369 369
370 observers_ = new ObserverListThreadSafe<Observer>; 370 observers_ = new ObserverListThreadSafe<Observer>;
371 371
372 // Check that the right threads exist for logging to the database. 372 // Check that the right threads exist for logging to the database.
373 // 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.
374 if (!BrowserThread::IsMessageLoopValid(BrowserThread::DB) || 374 if (!BrowserThread::IsMessageLoopValid(BrowserThread::DB) ||
375 !BrowserThread::IsMessageLoopValid(BrowserThread::FILE) || 375 !BrowserThread::IsMessageLoopValid(BrowserThread::FILE) ||
376 !BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 376 !BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
377 has_threads_ = false; 377 has_threads_ = false;
378 } 378 }
379 379
380 db_enabled_ = has_threads_ 380 db_enabled_ =
381 && (CommandLine::ForCurrentProcess()-> 381 has_threads_ && (base::CommandLine::ForCurrentProcess()->HasSwitch(
382 HasSwitch(switches::kEnableExtensionActivityLogging) 382 switches::kEnableExtensionActivityLogging) ||
383 || watchdog_apps_active_); 383 watchdog_apps_active_);
384 384
385 ExtensionSystem::Get(profile_)->ready().Post( 385 ExtensionSystem::Get(profile_)->ready().Post(
386 FROM_HERE, 386 FROM_HERE,
387 base::Bind(&ActivityLog::StartObserving, base::Unretained(this))); 387 base::Bind(&ActivityLog::StartObserving, base::Unretained(this)));
388 388
389 if (!profile_->IsOffTheRecord()) 389 if (!profile_->IsOffTheRecord())
390 uma_policy_ = new UmaPolicy(profile_); 390 uma_policy_ = new UmaPolicy(profile_);
391 391
392 ChooseDatabasePolicy(); 392 ChooseDatabasePolicy();
393 } 393 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 473 }
474 474
475 void ActivityLog::OnExtensionUnloaded(content::BrowserContext* browser_context, 475 void ActivityLog::OnExtensionUnloaded(content::BrowserContext* browser_context,
476 const Extension* extension, 476 const Extension* extension,
477 UnloadedExtensionInfo::Reason reason) { 477 UnloadedExtensionInfo::Reason reason) {
478 if (!ActivityLogAPI::IsExtensionWhitelisted(extension->id())) return; 478 if (!ActivityLogAPI::IsExtensionWhitelisted(extension->id())) return;
479 watchdog_apps_active_--; 479 watchdog_apps_active_--;
480 profile_->GetPrefs()->SetInteger(prefs::kWatchdogExtensionActive, 480 profile_->GetPrefs()->SetInteger(prefs::kWatchdogExtensionActive,
481 watchdog_apps_active_); 481 watchdog_apps_active_);
482 if (watchdog_apps_active_ == 0 && 482 if (watchdog_apps_active_ == 0 &&
483 !CommandLine::ForCurrentProcess()->HasSwitch( 483 !base::CommandLine::ForCurrentProcess()->HasSwitch(
484 switches::kEnableExtensionActivityLogging)) { 484 switches::kEnableExtensionActivityLogging)) {
485 db_enabled_ = false; 485 db_enabled_ = false;
486 } 486 }
487 } 487 }
488 488
489 // OnExtensionUnloaded will also be called right before this. 489 // OnExtensionUnloaded will also be called right before this.
490 void ActivityLog::OnExtensionUninstalled( 490 void ActivityLog::OnExtensionUninstalled(
491 content::BrowserContext* browser_context, 491 content::BrowserContext* browser_context,
492 const Extension* extension, 492 const Extension* extension,
493 extensions::UninstallReason reason) { 493 extensions::UninstallReason reason) {
494 if (ActivityLogAPI::IsExtensionWhitelisted(extension->id()) && 494 if (ActivityLogAPI::IsExtensionWhitelisted(extension->id()) &&
495 !CommandLine::ForCurrentProcess()->HasSwitch( 495 !base::CommandLine::ForCurrentProcess()->HasSwitch(
496 switches::kEnableExtensionActivityLogging) && 496 switches::kEnableExtensionActivityLogging) &&
497 watchdog_apps_active_ == 0) { 497 watchdog_apps_active_ == 0) {
498 DeleteDatabase(); 498 DeleteDatabase();
499 } else if (database_policy_) { 499 } else if (database_policy_) {
500 database_policy_->RemoveExtensionData(extension->id()); 500 database_policy_->RemoveExtensionData(extension->id());
501 } 501 }
502 } 502 }
503 503
504 void ActivityLog::AddObserver(ActivityLog::Observer* observer) { 504 void ActivityLog::AddObserver(ActivityLog::Observer* observer) {
505 observers_->AddObserver(observer); 505 observers_->AddObserver(observer);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 database_policy_->DeleteDatabase(); 674 database_policy_->DeleteDatabase();
675 } 675 }
676 676
677 template <> 677 template <>
678 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() { 678 void BrowserContextKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() {
679 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 679 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
680 DependsOn(ExtensionRegistryFactory::GetInstance()); 680 DependsOn(ExtensionRegistryFactory::GetInstance());
681 } 681 }
682 682
683 } // namespace extensions 683 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698