OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 << ": " << error; | 315 << ": " << error; |
316 return false; | 316 return false; |
317 } | 317 } |
318 | 318 |
319 return true; | 319 return true; |
320 } | 320 } |
321 | 321 |
322 ExtensionService::ExtensionService(Profile* profile, | 322 ExtensionService::ExtensionService(Profile* profile, |
323 const CommandLine* command_line, | 323 const CommandLine* command_line, |
324 const FilePath& install_directory, | 324 const FilePath& install_directory, |
325 ExtensionPrefs* extension_prefs, | 325 extensions::ExtensionPrefs* extension_prefs, |
326 bool autoupdate_enabled, | 326 bool autoupdate_enabled, |
327 bool extensions_enabled) | 327 bool extensions_enabled) |
328 : profile_(profile), | 328 : profile_(profile), |
329 system_(ExtensionSystem::Get(profile)), | 329 system_(ExtensionSystem::Get(profile)), |
330 extension_prefs_(extension_prefs), | 330 extension_prefs_(extension_prefs), |
331 settings_frontend_(extensions::SettingsFrontend::Create(profile)), | 331 settings_frontend_(extensions::SettingsFrontend::Create(profile)), |
332 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 332 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
333 install_directory_(install_directory), | 333 install_directory_(install_directory), |
334 extensions_enabled_(extensions_enabled), | 334 extensions_enabled_(extensions_enabled), |
335 show_extensions_prompts_(true), | 335 show_extensions_prompts_(true), |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 // call it outside the iterator loop. | 1132 // call it outside the iterator loop. |
1133 for (unsigned int i = 0; i < to_be_removed.size(); ++i) { | 1133 for (unsigned int i = 0; i < to_be_removed.size(); ++i) { |
1134 UnloadExtension(to_be_removed[i], extension_misc::UNLOAD_REASON_DISABLE); | 1134 UnloadExtension(to_be_removed[i], extension_misc::UNLOAD_REASON_DISABLE); |
1135 } | 1135 } |
1136 } | 1136 } |
1137 | 1137 |
1138 Profile* ExtensionService::profile() { | 1138 Profile* ExtensionService::profile() { |
1139 return profile_; | 1139 return profile_; |
1140 } | 1140 } |
1141 | 1141 |
1142 ExtensionPrefs* ExtensionService::extension_prefs() { | 1142 extensions::ExtensionPrefs* ExtensionService::extension_prefs() { |
1143 return extension_prefs_; | 1143 return extension_prefs_; |
1144 } | 1144 } |
1145 | 1145 |
1146 extensions::SettingsFrontend* ExtensionService::settings_frontend() { | 1146 extensions::SettingsFrontend* ExtensionService::settings_frontend() { |
1147 return settings_frontend_.get(); | 1147 return settings_frontend_.get(); |
1148 } | 1148 } |
1149 | 1149 |
1150 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { | 1150 extensions::ContentSettingsStore* ExtensionService::GetContentSettingsStore() { |
1151 return extension_prefs()->content_settings_store(); | 1151 return extension_prefs()->content_settings_store(); |
1152 } | 1152 } |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 base::TimeDelta elapsed = base::Time::Now() - profile_->GetStartTime(); | 1679 base::TimeDelta elapsed = base::Time::Now() - profile_->GetStartTime(); |
1680 UMA_HISTOGRAM_TIMES("Extension.ExternalProvidersReadyAfter", elapsed); | 1680 UMA_HISTOGRAM_TIMES("Extension.ExternalProvidersReadyAfter", elapsed); |
1681 | 1681 |
1682 // Install any pending extensions. | 1682 // Install any pending extensions. |
1683 if (update_once_all_providers_are_ready_ && updater()) { | 1683 if (update_once_all_providers_are_ready_ && updater()) { |
1684 update_once_all_providers_are_ready_ = false; | 1684 update_once_all_providers_are_ready_ = false; |
1685 updater()->CheckNow(); | 1685 updater()->CheckNow(); |
1686 } | 1686 } |
1687 | 1687 |
1688 // Uninstall all the unclaimed extensions. | 1688 // Uninstall all the unclaimed extensions. |
1689 scoped_ptr<ExtensionPrefs::ExtensionsInfo> extensions_info( | 1689 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> extensions_info( |
1690 extension_prefs_->GetInstalledExtensionsInfo()); | 1690 extension_prefs_->GetInstalledExtensionsInfo()); |
1691 for (size_t i = 0; i < extensions_info->size(); ++i) { | 1691 for (size_t i = 0; i < extensions_info->size(); ++i) { |
1692 ExtensionInfo* info = extensions_info->at(i).get(); | 1692 ExtensionInfo* info = extensions_info->at(i).get(); |
1693 if (Extension::IsExternalLocation(info->extension_location)) | 1693 if (Extension::IsExternalLocation(info->extension_location)) |
1694 CheckExternalUninstall(info->extension_id); | 1694 CheckExternalUninstall(info->extension_id); |
1695 } | 1695 } |
1696 IdentifyAlertableExtensions(); | 1696 IdentifyAlertableExtensions(); |
1697 } | 1697 } |
1698 | 1698 |
1699 void ExtensionService::IdentifyAlertableExtensions() { | 1699 void ExtensionService::IdentifyAlertableExtensions() { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 void ExtensionService::ReloadExtensions() { | 1851 void ExtensionService::ReloadExtensions() { |
1852 UnloadAllExtensions(); | 1852 UnloadAllExtensions(); |
1853 component_loader_->LoadAll(); | 1853 component_loader_->LoadAll(); |
1854 extensions::InstalledLoader(this).LoadAllExtensions(); | 1854 extensions::InstalledLoader(this).LoadAllExtensions(); |
1855 } | 1855 } |
1856 | 1856 |
1857 void ExtensionService::GarbageCollectExtensions() { | 1857 void ExtensionService::GarbageCollectExtensions() { |
1858 if (extension_prefs_->pref_service()->ReadOnly()) | 1858 if (extension_prefs_->pref_service()->ReadOnly()) |
1859 return; | 1859 return; |
1860 | 1860 |
1861 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( | 1861 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> info( |
1862 extension_prefs_->GetInstalledExtensionsInfo()); | 1862 extension_prefs_->GetInstalledExtensionsInfo()); |
1863 | 1863 |
1864 std::map<std::string, FilePath> extension_paths; | 1864 std::map<std::string, FilePath> extension_paths; |
1865 for (size_t i = 0; i < info->size(); ++i) | 1865 for (size_t i = 0; i < info->size(); ++i) |
1866 extension_paths[info->at(i)->extension_id] = info->at(i)->extension_path; | 1866 extension_paths[info->at(i)->extension_id] = info->at(i)->extension_path; |
1867 | 1867 |
1868 if (!BrowserThread::PostTask( | 1868 if (!BrowserThread::PostTask( |
1869 BrowserThread::FILE, FROM_HERE, | 1869 BrowserThread::FILE, FROM_HERE, |
1870 base::Bind( | 1870 base::Bind( |
1871 &extension_file_util::GarbageCollectExtensions, | 1871 &extension_file_util::GarbageCollectExtensions, |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2560 | 2560 |
2561 // To coexist with certain unit tests that don't have a work-thread message | 2561 // To coexist with certain unit tests that don't have a work-thread message |
2562 // loop available at ExtensionService shutdown, we lazy-initialize this | 2562 // loop available at ExtensionService shutdown, we lazy-initialize this |
2563 // object so that those cases neither create nor destroy an | 2563 // object so that those cases neither create nor destroy an |
2564 // APIResourceController. | 2564 // APIResourceController. |
2565 if (!api_resource_controller_.get()) { | 2565 if (!api_resource_controller_.get()) { |
2566 api_resource_controller_.reset(new extensions::APIResourceController()); | 2566 api_resource_controller_.reset(new extensions::APIResourceController()); |
2567 } | 2567 } |
2568 return api_resource_controller_.get(); | 2568 return api_resource_controller_.get(); |
2569 } | 2569 } |
OLD | NEW |