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

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

Issue 9817018: Cleaning Up Extensions When Local Content Removed (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated with newest master Created 8 years, 8 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
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 #include "webkit/database/database_tracker.h" 110 #include "webkit/database/database_tracker.h"
111 #include "webkit/database/database_util.h" 111 #include "webkit/database/database_util.h"
112 112
113 #if defined(OS_CHROMEOS) 113 #if defined(OS_CHROMEOS)
114 #include "chrome/browser/chromeos/cros/cros_library.h" 114 #include "chrome/browser/chromeos/cros/cros_library.h"
115 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" 115 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h"
116 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" 116 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
117 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" 117 #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
118 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" 118 #include "chrome/browser/chromeos/extensions/media_player_event_router.h"
119 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 119 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
120 #include "chrome/browser/extensions/extension_input_ime_api.h"
121 #include "webkit/fileapi/file_system_context.h" 120 #include "webkit/fileapi/file_system_context.h"
122 #include "webkit/fileapi/file_system_mount_point_provider.h" 121 #include "webkit/fileapi/file_system_mount_point_provider.h"
123 #endif 122 #endif
124 123
125 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) 124 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD)
126 #include "chrome/browser/extensions/extension_input_ui_api.h" 125 #include "chrome/browser/extensions/extension_input_ui_api.h"
127 #endif 126 #endif
128 127
129 using base::Time; 128 using base::Time;
130 using content::BrowserContext; 129 using content::BrowserContext;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 376
378 ExtensionService::ExtensionService(Profile* profile, 377 ExtensionService::ExtensionService(Profile* profile,
379 const CommandLine* command_line, 378 const CommandLine* command_line,
380 const FilePath& install_directory, 379 const FilePath& install_directory,
381 ExtensionPrefs* extension_prefs, 380 ExtensionPrefs* extension_prefs,
382 bool autoupdate_enabled, 381 bool autoupdate_enabled,
383 bool extensions_enabled) 382 bool extensions_enabled)
384 : profile_(profile), 383 : profile_(profile),
385 system_(ExtensionSystem::Get(profile)), 384 system_(ExtensionSystem::Get(profile)),
386 extension_prefs_(extension_prefs), 385 extension_prefs_(extension_prefs),
386 extension_garbage_collector_(new ExtensionGarbageCollector(this)),
387 settings_frontend_(extensions::SettingsFrontend::Create(profile)), 387 settings_frontend_(extensions::SettingsFrontend::Create(profile)),
388 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), 388 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)),
389 install_directory_(install_directory), 389 install_directory_(install_directory),
390 extensions_enabled_(extensions_enabled), 390 extensions_enabled_(extensions_enabled),
391 show_extensions_prompts_(true), 391 show_extensions_prompts_(true),
392 ready_(false), 392 ready_(false),
393 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 393 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
394 menu_manager_(profile), 394 menu_manager_(profile),
395 app_notification_manager_(new AppNotificationManager(profile)), 395 app_notification_manager_(new AppNotificationManager(profile)),
396 apps_promo_(profile->GetPrefs()), 396 apps_promo_(profile->GetPrefs()),
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 // Keep information about the extension so that we can reload it later 1891 // Keep information about the extension so that we can reload it later
1892 // even if it's not permanently installed. 1892 // even if it's not permanently installed.
1893 unloaded_extension_paths_[extension->id()] = extension->path(); 1893 unloaded_extension_paths_[extension->id()] = extension->path();
1894 1894
1895 // Clean up if the extension is meant to be enabled after a reload. 1895 // Clean up if the extension is meant to be enabled after a reload.
1896 disabled_extension_paths_.erase(extension->id()); 1896 disabled_extension_paths_.erase(extension->id());
1897 1897
1898 // Clean up runtime data. 1898 // Clean up runtime data.
1899 extension_runtime_data_.erase(extension_id); 1899 extension_runtime_data_.erase(extension_id);
1900 1900
1901 if (disabled_extensions_.Contains(extension->id())) { 1901 if (disabled_extensions_.Contains(extension->id())) {
1902 UnloadedExtensionInfo details(extension, reason); 1902 UnloadedExtensionInfo details(extension, reason);
1903 details.already_disabled = true; 1903 details.already_disabled = true;
1904 disabled_extensions_.Remove(extension->id()); 1904 disabled_extensions_.Remove(extension->id());
1905 content::NotificationService::current()->Notify( 1905 content::NotificationService::current()->Notify(
1906 chrome::NOTIFICATION_EXTENSION_UNLOADED, 1906 chrome::NOTIFICATION_EXTENSION_UNLOADED,
1907 content::Source<Profile>(profile_), 1907 content::Source<Profile>(profile_),
1908 content::Details<UnloadedExtensionInfo>(&details)); 1908 content::Details<UnloadedExtensionInfo>(&details));
1909 // Make sure the profile cleans up its RequestContexts when an already 1909 // Make sure the profile cleans up its RequestContexts when an already
1910 // disabled extension is unloaded (since they are also tracking the disabled 1910 // disabled extension is unloaded (since they are also tracking the disabled
1911 // extensions). 1911 // extensions).
(...skipping 21 matching lines...) Expand all
1933 // or uninstalled, and UnloadAll is just part of shutdown. 1933 // or uninstalled, and UnloadAll is just part of shutdown.
1934 } 1934 }
1935 1935
1936 void ExtensionService::ReloadExtensions() { 1936 void ExtensionService::ReloadExtensions() {
1937 UnloadAllExtensions(); 1937 UnloadAllExtensions();
1938 component_loader_->LoadAll(); 1938 component_loader_->LoadAll();
1939 extensions::InstalledLoader(this).LoadAllExtensions(); 1939 extensions::InstalledLoader(this).LoadAllExtensions();
1940 } 1940 }
1941 1941
1942 void ExtensionService::GarbageCollectExtensions() { 1942 void ExtensionService::GarbageCollectExtensions() {
1943 if (extension_prefs_->pref_service()->ReadOnly()) 1943 extension_garbage_collector_->GarbageCollectExtensions();
1944 return;
1945
1946 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info(
1947 extension_prefs_->GetInstalledExtensionsInfo());
1948
1949 std::map<std::string, FilePath> extension_paths;
1950 for (size_t i = 0; i < info->size(); ++i)
1951 extension_paths[info->at(i)->extension_id] = info->at(i)->extension_path;
1952
1953 if (!BrowserThread::PostTask(
1954 BrowserThread::FILE, FROM_HERE,
1955 base::Bind(
1956 &extension_file_util::GarbageCollectExtensions,
1957 install_directory_,
1958 extension_paths)))
1959 NOTREACHED();
1960 1944
1961 // Also garbage-collect themes. We check |profile_| to be 1945 // Also garbage-collect themes. We check |profile_| to be
1962 // defensive; in the future, we may call GarbageCollectExtensions() 1946 // defensive; in the future, we may call GarbageCollectExtensions()
1963 // from somewhere other than Init() (e.g., in a timer). 1947 // from somewhere other than Init() (e.g., in a timer).
1964 if (profile_) { 1948 if (profile_) {
1965 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes(); 1949 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes();
1966 } 1950 }
1967 } 1951 }
1968 1952
1969 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { 1953 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 // to a version that requires additional privileges. 2103 // to a version that requires additional privileges.
2120 is_privilege_increase = 2104 is_privilege_increase =
2121 granted_permissions->HasLessPrivilegesThan( 2105 granted_permissions->HasLessPrivilegesThan(
2122 extension->GetActivePermissions()); 2106 extension->GetActivePermissions());
2123 } 2107 }
2124 2108
2125 if (is_extension_upgrade) { 2109 if (is_extension_upgrade) {
2126 // Other than for unpacked extensions, CrxInstaller should have guaranteed 2110 // Other than for unpacked extensions, CrxInstaller should have guaranteed
2127 // that we aren't downgrading. 2111 // that we aren't downgrading.
2128 if (extension->location() != Extension::LOAD) 2112 if (extension->location() != Extension::LOAD)
2129 CHECK(extension->version()->CompareTo(*(old->version())) >= 0); 2113 CHECK_GE(extension->version()->CompareTo(*(old->version())), 0);
2130 2114
2131 // Extensions get upgraded if the privileges are allowed to increase or 2115 // Extensions get upgraded if the privileges are allowed to increase or
2132 // the privileges haven't increased. 2116 // the privileges haven't increased.
2133 if (!is_privilege_increase) { 2117 if (!is_privilege_increase) {
2134 SetBeingUpgraded(old, true); 2118 SetBeingUpgraded(old, true);
2135 SetBeingUpgraded(extension, true); 2119 SetBeingUpgraded(extension, true);
2136 } 2120 }
2137 2121
2138 // If the extension was already disabled, suppress any alerts for becoming 2122 // If the extension was already disabled, suppress any alerts for becoming
2139 // disabled on permissions increase. 2123 // disabled on permissions increase.
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 // To coexist with certain unit tests that don't have an IO thread message 2630 // To coexist with certain unit tests that don't have an IO thread message
2647 // loop available at ExtensionService shutdown, we lazy-initialize this 2631 // loop available at ExtensionService shutdown, we lazy-initialize this
2648 // object so that those cases neither create nor destroy an 2632 // object so that those cases neither create nor destroy an
2649 // APIResourceController. 2633 // APIResourceController.
2650 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2634 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2651 if (!api_resource_controller_) { 2635 if (!api_resource_controller_) {
2652 api_resource_controller_ = new extensions::APIResourceController(); 2636 api_resource_controller_ = new extensions::APIResourceController();
2653 } 2637 }
2654 return api_resource_controller_; 2638 return api_resource_controller_;
2655 } 2639 }
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