Chromium Code Reviews| 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" |
| 11 #include "base/json/json_string_value_serializer.h" | 11 #include "base/json/json_string_value_serializer.h" |
| 12 #include "base/lazy_instance.h" | |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 16 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" | 17 #include "chrome/browser/extensions/activity_log/activity_action_constants.h" |
| 17 #include "chrome/browser/extensions/activity_log/counting_policy.h" | 18 #include "chrome/browser/extensions/activity_log/counting_policy.h" |
| 18 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" | 19 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" |
| 19 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat e_api.h" | 20 #include "chrome/browser/extensions/api/activity_log_private/activity_log_privat e_api.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/extension_tab_util.h" | 22 #include "chrome/browser/extensions/extension_tab_util.h" |
| 22 #include "chrome/browser/extensions/install_tracker.h" | 23 #include "chrome/browser/extensions/install_tracker.h" |
| 23 #include "chrome/browser/extensions/install_tracker_factory.h" | 24 #include "chrome/browser/extensions/install_tracker_factory.h" |
| 24 #include "chrome/browser/prefs/pref_service_syncable.h" | 25 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 25 #include "chrome/browser/prerender/prerender_manager.h" | 26 #include "chrome/browser/prerender/prerender_manager.h" |
| 26 #include "chrome/browser/prerender/prerender_manager_factory.h" | 27 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
| 29 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
| 30 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 32 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" | |
| 33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 35 #include "extensions/browser/extension_system.h" | 35 #include "extensions/browser/extension_system.h" |
| 36 #include "extensions/browser/extension_system_provider.h" | 36 #include "extensions/browser/extension_system_provider.h" |
| 37 #include "extensions/browser/extensions_browser_client.h" | 37 #include "extensions/browser/extensions_browser_client.h" |
| 38 #include "extensions/common/extension.h" | 38 #include "extensions/common/extension.h" |
| 39 #include "third_party/re2/re2/re2.h" | 39 #include "third_party/re2/re2/re2.h" |
| 40 #include "url/gurl.h" | 40 #include "url/gurl.h" |
| 41 | 41 |
| 42 #if !defined(OS_ANDROID) | 42 #if !defined(OS_ANDROID) |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 if (arg_url.is_valid()) { | 329 if (arg_url.is_valid()) { |
| 330 action->set_arg_incognito(arg_incognito); | 330 action->set_arg_incognito(arg_incognito); |
| 331 action->set_arg_url(arg_url); | 331 action->set_arg_url(arg_url); |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 | 334 |
| 335 } // namespace | 335 } // namespace |
| 336 | 336 |
| 337 namespace extensions { | 337 namespace extensions { |
| 338 | 338 |
| 339 // ActivityLogFactory | 339 // SET THINGS UP. -------------------------------------------------------------- |
| 340 | 340 |
| 341 ActivityLogFactory* ActivityLogFactory::GetInstance() { | 341 static base::LazyInstance<ProfileKeyedAPIFactory<ActivityLog> > g_factory = |
| 342 return Singleton<ActivityLogFactory>::get(); | 342 LAZY_INSTANCE_INITIALIZER; |
| 343 } | |
| 344 | 343 |
| 345 BrowserContextKeyedService* ActivityLogFactory::BuildServiceInstanceFor( | 344 ProfileKeyedAPIFactory<ActivityLog>* ActivityLog::GetFactoryInstance() { |
| 346 content::BrowserContext* profile) const { | 345 return g_factory.Pointer(); |
| 347 return new ActivityLog(static_cast<Profile*>(profile)); | |
| 348 } | |
| 349 | |
| 350 content::BrowserContext* ActivityLogFactory::GetBrowserContextToUse( | |
| 351 content::BrowserContext* context) const { | |
| 352 return ExtensionsBrowserClient::Get()->GetOriginalContext(context); | |
|
James Cook
2014/02/19 02:37:43
I'll bet this is the way it is because there's som
Yoyo Zhou
2014/02/19 02:49:05
Good call. But actually I think we don't use Activ
| |
| 353 } | |
| 354 | |
| 355 ActivityLogFactory::ActivityLogFactory() | |
| 356 : BrowserContextKeyedServiceFactory( | |
| 357 "ActivityLog", | |
| 358 BrowserContextDependencyManager::GetInstance()) { | |
| 359 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | |
| 360 DependsOn(InstallTrackerFactory::GetInstance()); | |
| 361 } | 346 } |
| 362 | 347 |
| 363 // static | 348 // static |
| 364 ActivityLog* ActivityLog::GetInstance(content::BrowserContext* context) { | 349 ActivityLog* ActivityLog::GetInstance(content::BrowserContext* context) { |
| 365 return ActivityLogFactory::GetForBrowserContext(context); | 350 return ActivityLog::GetFactoryInstance()->GetForProfile( |
| 351 Profile::FromBrowserContext(context)); | |
| 366 } | 352 } |
| 367 | 353 |
| 368 ActivityLogFactory::~ActivityLogFactory() { | |
| 369 } | |
| 370 | |
| 371 // ActivityLog | |
| 372 | |
| 373 // SET THINGS UP. -------------------------------------------------------------- | |
| 374 | |
| 375 // Use GetInstance instead of directly creating an ActivityLog. | 354 // Use GetInstance instead of directly creating an ActivityLog. |
| 376 ActivityLog::ActivityLog(Profile* profile) | 355 ActivityLog::ActivityLog(Profile* profile) |
| 377 : database_policy_(NULL), | 356 : database_policy_(NULL), |
| 378 database_policy_type_(ActivityLogPolicy::POLICY_INVALID), | 357 database_policy_type_(ActivityLogPolicy::POLICY_INVALID), |
| 379 uma_policy_(NULL), | 358 uma_policy_(NULL), |
| 380 profile_(profile), | 359 profile_(profile), |
| 381 db_enabled_(false), | 360 db_enabled_(false), |
| 382 testing_mode_(false), | 361 testing_mode_(false), |
| 383 has_threads_(true), | 362 has_threads_(true), |
| 384 tracker_(NULL), | 363 tracker_(NULL), |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 urls.push_back(url); | 688 urls.push_back(url); |
| 710 RemoveURLs(urls); | 689 RemoveURLs(urls); |
| 711 } | 690 } |
| 712 | 691 |
| 713 void ActivityLog::DeleteDatabase() { | 692 void ActivityLog::DeleteDatabase() { |
| 714 if (!database_policy_) | 693 if (!database_policy_) |
| 715 return; | 694 return; |
| 716 database_policy_->DeleteDatabase(); | 695 database_policy_->DeleteDatabase(); |
| 717 } | 696 } |
| 718 | 697 |
| 698 template <> | |
| 699 void ProfileKeyedAPIFactory<ActivityLog>::DeclareFactoryDependencies() { | |
| 700 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | |
| 701 DependsOn(InstallTrackerFactory::GetInstance()); | |
| 702 } | |
| 703 | |
| 719 } // namespace extensions | 704 } // namespace extensions |
| OLD | NEW |