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

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

Issue 10579028: Revert 142427 - Cleaning Up Extensions When Local Content Removed (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: Created 8 years, 6 months 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 | Annotate | Revision Log
OLDNEW
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 #include "webkit/database/database_tracker.h" 112 #include "webkit/database/database_tracker.h"
113 #include "webkit/database/database_util.h" 113 #include "webkit/database/database_util.h"
114 114
115 #if defined(OS_CHROMEOS) 115 #if defined(OS_CHROMEOS)
116 #include "chrome/browser/chromeos/cros/cros_library.h" 116 #include "chrome/browser/chromeos/cros/cros_library.h"
117 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" 117 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h"
118 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" 118 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
119 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" 119 #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
120 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" 120 #include "chrome/browser/chromeos/extensions/media_player_event_router.h"
121 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 121 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
122 #include "chrome/browser/extensions/extension_input_ime_api.h"
122 #include "webkit/fileapi/file_system_context.h" 123 #include "webkit/fileapi/file_system_context.h"
123 #include "webkit/fileapi/file_system_mount_point_provider.h" 124 #include "webkit/fileapi/file_system_mount_point_provider.h"
124 #endif 125 #endif
125 126
126 using base::Time; 127 using base::Time;
127 using content::BrowserContext; 128 using content::BrowserContext;
128 using content::BrowserThread; 129 using content::BrowserThread;
129 using content::DevToolsAgentHost; 130 using content::DevToolsAgentHost;
130 using content::DevToolsAgentHostRegistry; 131 using content::DevToolsAgentHostRegistry;
131 using content::PluginService; 132 using content::PluginService;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 318
318 ExtensionService::ExtensionService(Profile* profile, 319 ExtensionService::ExtensionService(Profile* profile,
319 const CommandLine* command_line, 320 const CommandLine* command_line,
320 const FilePath& install_directory, 321 const FilePath& install_directory,
321 ExtensionPrefs* extension_prefs, 322 ExtensionPrefs* extension_prefs,
322 bool autoupdate_enabled, 323 bool autoupdate_enabled,
323 bool extensions_enabled) 324 bool extensions_enabled)
324 : profile_(profile), 325 : profile_(profile),
325 system_(ExtensionSystem::Get(profile)), 326 system_(ExtensionSystem::Get(profile)),
326 extension_prefs_(extension_prefs), 327 extension_prefs_(extension_prefs),
327 extension_garbage_collector_(
328 new extensions::ExtensionGarbageCollector(this)),
329 settings_frontend_(extensions::SettingsFrontend::Create(profile)), 328 settings_frontend_(extensions::SettingsFrontend::Create(profile)),
330 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), 329 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)),
331 install_directory_(install_directory), 330 install_directory_(install_directory),
332 extensions_enabled_(extensions_enabled), 331 extensions_enabled_(extensions_enabled),
333 show_extensions_prompts_(true), 332 show_extensions_prompts_(true),
334 ready_(false), 333 ready_(false),
335 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 334 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
336 menu_manager_(profile), 335 menu_manager_(profile),
337 app_notification_manager_(new AppNotificationManager(profile)), 336 app_notification_manager_(new AppNotificationManager(profile)),
338 apps_promo_(profile->GetPrefs()), 337 apps_promo_(profile->GetPrefs()),
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 // or uninstalled, and UnloadAll is just part of shutdown. 1839 // or uninstalled, and UnloadAll is just part of shutdown.
1841 } 1840 }
1842 1841
1843 void ExtensionService::ReloadExtensions() { 1842 void ExtensionService::ReloadExtensions() {
1844 UnloadAllExtensions(); 1843 UnloadAllExtensions();
1845 component_loader_->LoadAll(); 1844 component_loader_->LoadAll();
1846 extensions::InstalledLoader(this).LoadAllExtensions(); 1845 extensions::InstalledLoader(this).LoadAllExtensions();
1847 } 1846 }
1848 1847
1849 void ExtensionService::GarbageCollectExtensions() { 1848 void ExtensionService::GarbageCollectExtensions() {
1850 extension_garbage_collector_->GarbageCollectExtensions(); 1849 if (extension_prefs_->pref_service()->ReadOnly())
1850 return;
1851
1852 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info(
1853 extension_prefs_->GetInstalledExtensionsInfo());
1854
1855 std::map<std::string, FilePath> extension_paths;
1856 for (size_t i = 0; i < info->size(); ++i)
1857 extension_paths[info->at(i)->extension_id] = info->at(i)->extension_path;
1858
1859 if (!BrowserThread::PostTask(
1860 BrowserThread::FILE, FROM_HERE,
1861 base::Bind(
1862 &extension_file_util::GarbageCollectExtensions,
1863 install_directory_,
1864 extension_paths)))
1865 NOTREACHED();
1851 1866
1852 // Also garbage-collect themes. We check |profile_| to be 1867 // Also garbage-collect themes. We check |profile_| to be
1853 // defensive; in the future, we may call GarbageCollectExtensions() 1868 // defensive; in the future, we may call GarbageCollectExtensions()
1854 // from somewhere other than Init() (e.g., in a timer). 1869 // from somewhere other than Init() (e.g., in a timer).
1855 if (profile_) { 1870 if (profile_) {
1856 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes(); 1871 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes();
1857 } 1872 }
1858 } 1873 }
1859 1874
1860 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { 1875 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 // to a version that requires additional privileges. 2021 // to a version that requires additional privileges.
2007 is_privilege_increase = 2022 is_privilege_increase =
2008 granted_permissions->HasLessPrivilegesThan( 2023 granted_permissions->HasLessPrivilegesThan(
2009 extension->GetActivePermissions()); 2024 extension->GetActivePermissions());
2010 } 2025 }
2011 2026
2012 if (is_extension_upgrade) { 2027 if (is_extension_upgrade) {
2013 // Other than for unpacked extensions, CrxInstaller should have guaranteed 2028 // Other than for unpacked extensions, CrxInstaller should have guaranteed
2014 // that we aren't downgrading. 2029 // that we aren't downgrading.
2015 if (extension->location() != Extension::LOAD) 2030 if (extension->location() != Extension::LOAD)
2016 CHECK_GE(extension->version()->CompareTo(*(old->version())), 0); 2031 CHECK(extension->version()->CompareTo(*(old->version())) >= 0);
2017 2032
2018 // Extensions get upgraded if the privileges are allowed to increase or 2033 // Extensions get upgraded if the privileges are allowed to increase or
2019 // the privileges haven't increased. 2034 // the privileges haven't increased.
2020 if (!is_privilege_increase) { 2035 if (!is_privilege_increase) {
2021 SetBeingUpgraded(old, true); 2036 SetBeingUpgraded(old, true);
2022 SetBeingUpgraded(extension, true); 2037 SetBeingUpgraded(extension, true);
2023 } 2038 }
2024 2039
2025 // If the extension was already disabled, suppress any alerts for becoming 2040 // If the extension was already disabled, suppress any alerts for becoming
2026 // disabled on permissions increase. 2041 // disabled on permissions increase.
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 2551
2537 // To coexist with certain unit tests that don't have a work-thread message 2552 // To coexist with certain unit tests that don't have a work-thread message
2538 // loop available at ExtensionService shutdown, we lazy-initialize this 2553 // loop available at ExtensionService shutdown, we lazy-initialize this
2539 // object so that those cases neither create nor destroy an 2554 // object so that those cases neither create nor destroy an
2540 // APIResourceController. 2555 // APIResourceController.
2541 if (!api_resource_controller_.get()) { 2556 if (!api_resource_controller_.get()) {
2542 api_resource_controller_.reset(new extensions::APIResourceController()); 2557 api_resource_controller_.reset(new extensions::APIResourceController());
2543 } 2558 }
2544 return api_resource_controller_.get(); 2559 return api_resource_controller_.get();
2545 } 2560 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698