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

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: Cleaning Up Extensions When Local Content Removed Created 8 years, 9 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 #include "net/base/registry_controlled_domain.h" 103 #include "net/base/registry_controlled_domain.h"
104 #include "webkit/database/database_tracker.h" 104 #include "webkit/database/database_tracker.h"
105 #include "webkit/database/database_util.h" 105 #include "webkit/database/database_util.h"
106 106
107 #if defined(OS_CHROMEOS) 107 #if defined(OS_CHROMEOS)
108 #include "chrome/browser/chromeos/cros/cros_library.h" 108 #include "chrome/browser/chromeos/cros/cros_library.h"
109 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" 109 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h"
110 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" 110 #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
111 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" 111 #include "chrome/browser/chromeos/extensions/media_player_event_router.h"
112 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 112 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
113 #include "chrome/browser/extensions/extension_input_ime_api.h"
114 #include "webkit/fileapi/file_system_context.h" 113 #include "webkit/fileapi/file_system_context.h"
115 #include "webkit/fileapi/file_system_mount_point_provider.h" 114 #include "webkit/fileapi/file_system_mount_point_provider.h"
116 #endif 115 #endif
117 116
118 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) 117 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD)
119 #include "chrome/browser/extensions/extension_input_ui_api.h" 118 #include "chrome/browser/extensions/extension_input_ui_api.h"
120 #endif 119 #endif
121 120
122 using base::Time; 121 using base::Time;
123 using content::BrowserContext; 122 using content::BrowserContext;
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 // Keep information about the extension so that we can reload it later 1877 // Keep information about the extension so that we can reload it later
1879 // even if it's not permanently installed. 1878 // even if it's not permanently installed.
1880 unloaded_extension_paths_[extension->id()] = extension->path(); 1879 unloaded_extension_paths_[extension->id()] = extension->path();
1881 1880
1882 // Clean up if the extension is meant to be enabled after a reload. 1881 // Clean up if the extension is meant to be enabled after a reload.
1883 disabled_extension_paths_.erase(extension->id()); 1882 disabled_extension_paths_.erase(extension->id());
1884 1883
1885 // Clean up runtime data. 1884 // Clean up runtime data.
1886 extension_runtime_data_.erase(extension_id); 1885 extension_runtime_data_.erase(extension_id);
1887 1886
1888 if (disabled_extensions_.Contains(extension->id())) { 1887 if (disabled_extensions_.Contains(extension->id())) {
1889 UnloadedExtensionInfo details(extension, reason); 1888 UnloadedExtensionInfo details(extension, reason);
1890 details.already_disabled = true; 1889 details.already_disabled = true;
1891 disabled_extensions_.Remove(extension->id()); 1890 disabled_extensions_.Remove(extension->id());
1892 content::NotificationService::current()->Notify( 1891 content::NotificationService::current()->Notify(
1893 chrome::NOTIFICATION_EXTENSION_UNLOADED, 1892 chrome::NOTIFICATION_EXTENSION_UNLOADED,
1894 content::Source<Profile>(profile_), 1893 content::Source<Profile>(profile_),
1895 content::Details<UnloadedExtensionInfo>(&details)); 1894 content::Details<UnloadedExtensionInfo>(&details));
1896 // Make sure the profile cleans up its RequestContexts when an already 1895 // Make sure the profile cleans up its RequestContexts when an already
1897 // disabled extension is unloaded (since they are also tracking the disabled 1896 // disabled extension is unloaded (since they are also tracking the disabled
1898 // extensions). 1897 // extensions).
(...skipping 28 matching lines...) Expand all
1927 } 1926 }
1928 1927
1929 void ExtensionService::GarbageCollectExtensions() { 1928 void ExtensionService::GarbageCollectExtensions() {
1930 if (extension_prefs_->pref_service()->ReadOnly()) 1929 if (extension_prefs_->pref_service()->ReadOnly())
1931 return; 1930 return;
1932 1931
1933 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( 1932 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info(
1934 extension_prefs_->GetInstalledExtensionsInfo()); 1933 extension_prefs_->GetInstalledExtensionsInfo());
1935 1934
1936 std::map<std::string, FilePath> extension_paths; 1935 std::map<std::string, FilePath> extension_paths;
1937 for (size_t i = 0; i < info->size(); ++i) 1936 for (size_t i = 0; i < info->size(); ++i) {
1938 extension_paths[info->at(i)->extension_id] = info->at(i)->extension_path; 1937 // Uninstall the extension if the path does not exist. If the extension
1938 // failed to load fully (e.g. the user deleted an external extension's
1939 // manifest or the manifest points to the wrong path), we cannot use
1940 // UninstallExtension, which relies on a valid Extension object.
1941 if (!file_util::PathExists(info->at(i)->extension_path)) {
Aaron Boodman 2012/03/21 21:00:47 You cannot use file_util::PathExists here (or inde
Devlin 2012/03/21 21:48:38 Not entirely sure why file_util works...but it doe
1942 LOG(WARNING) << "Could not access local content for extension with id " <<
1943 info->at(i)->extension_id << "; uninstalling extension.";
1944 LOG(WARNING) << "Path: " << info->at(i)->extension_path.value();
1945 if (!GetInstalledExtension(info->at(i)->extension_id)) {
1946 UnloadExtension(info->at(i)->extension_id,
1947 extension_misc::UNLOAD_REASON_UNINSTALL);
1948 extension_prefs_->OnExtensionUninstalled(
1949 info->at(i)->extension_id, info->at(i)->extension_location, false);
1950 } else {
1951 UninstallExtension(info->at(i)->extension_id, false, NULL);
1952 }
1953 } else {
1954 extension_paths[info->at(i)->extension_id] = info->at(i)->extension_path;
1955 }
1956 }
1939 1957
1940 if (!BrowserThread::PostTask( 1958 if (!BrowserThread::PostTask(
1941 BrowserThread::FILE, FROM_HERE, 1959 BrowserThread::FILE, FROM_HERE,
1942 base::Bind( 1960 base::Bind(
1943 &extension_file_util::GarbageCollectExtensions, 1961 &extension_file_util::GarbageCollectExtensions,
1944 install_directory_, 1962 install_directory_,
1945 extension_paths))) 1963 extension_paths)))
1946 NOTREACHED(); 1964 NOTREACHED();
1947 1965
1948 // Also garbage-collect themes. We check |profile_| to be 1966 // Also garbage-collect themes. We check |profile_| to be
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2116 // to a version that requires additional privileges. 2134 // to a version that requires additional privileges.
2117 is_privilege_increase = 2135 is_privilege_increase =
2118 granted_permissions->HasLessPrivilegesThan( 2136 granted_permissions->HasLessPrivilegesThan(
2119 extension->GetActivePermissions()); 2137 extension->GetActivePermissions());
2120 } 2138 }
2121 2139
2122 if (is_extension_upgrade) { 2140 if (is_extension_upgrade) {
2123 // Other than for unpacked extensions, CrxInstaller should have guaranteed 2141 // Other than for unpacked extensions, CrxInstaller should have guaranteed
2124 // that we aren't downgrading. 2142 // that we aren't downgrading.
2125 if (extension->location() != Extension::LOAD) 2143 if (extension->location() != Extension::LOAD)
2126 CHECK(extension->version()->CompareTo(*(old->version())) >= 0); 2144 CHECK_GE(extension->version()->CompareTo(*(old->version())), 0);
2127 2145
2128 // Extensions get upgraded if the privileges are allowed to increase or 2146 // Extensions get upgraded if the privileges are allowed to increase or
2129 // the privileges haven't increased. 2147 // the privileges haven't increased.
2130 if (!is_privilege_increase) { 2148 if (!is_privilege_increase) {
2131 SetBeingUpgraded(old, true); 2149 SetBeingUpgraded(old, true);
2132 SetBeingUpgraded(extension, true); 2150 SetBeingUpgraded(extension, true);
2133 } 2151 }
2134 2152
2135 // To upgrade an extension in place, unload the old one and 2153 // To upgrade an extension in place, unload the old one and
2136 // then load the new one. 2154 // then load the new one.
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
2633 return api_resource_controller_; 2651 return api_resource_controller_;
2634 } 2652 }
2635 2653
2636 extensions::RulesRegistryService* ExtensionService::GetRulesRegistryService() { 2654 extensions::RulesRegistryService* ExtensionService::GetRulesRegistryService() {
2637 if (!rules_registry_service_.get()) { 2655 if (!rules_registry_service_.get()) {
2638 rules_registry_service_.reset( 2656 rules_registry_service_.reset(
2639 new extensions::RulesRegistryService(profile_)); 2657 new extensions::RulesRegistryService(profile_));
2640 } 2658 }
2641 return rules_registry_service_.get(); 2659 return rules_registry_service_.get();
2642 } 2660 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698