| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 #include "webkit/database/database_tracker.h" | 105 #include "webkit/database/database_tracker.h" |
| 106 #include "webkit/database/database_util.h" | 106 #include "webkit/database/database_util.h" |
| 107 | 107 |
| 108 #if defined(OS_CHROMEOS) | 108 #if defined(OS_CHROMEOS) |
| 109 #include "chrome/browser/chromeos/cros/cros_library.h" | 109 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 110 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" | 110 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" |
| 111 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" | 111 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
| 112 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 112 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
| 113 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | 113 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" |
| 114 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 114 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 115 #include "chrome/browser/extensions/extension_input_ime_api.h" | |
| 116 #include "webkit/fileapi/file_system_context.h" | 115 #include "webkit/fileapi/file_system_context.h" |
| 117 #include "webkit/fileapi/file_system_mount_point_provider.h" | 116 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 118 #endif | 117 #endif |
| 119 | 118 |
| 120 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) | 119 #if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) |
| 121 #include "chrome/browser/extensions/extension_input_ui_api.h" | 120 #include "chrome/browser/extensions/extension_input_ui_api.h" |
| 122 #endif | 121 #endif |
| 123 | 122 |
| 124 using base::Time; | 123 using base::Time; |
| 125 using content::BrowserContext; | 124 using content::BrowserContext; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } | 370 } |
| 372 | 371 |
| 373 ExtensionService::ExtensionService(Profile* profile, | 372 ExtensionService::ExtensionService(Profile* profile, |
| 374 const CommandLine* command_line, | 373 const CommandLine* command_line, |
| 375 const FilePath& install_directory, | 374 const FilePath& install_directory, |
| 376 ExtensionPrefs* extension_prefs, | 375 ExtensionPrefs* extension_prefs, |
| 377 bool autoupdate_enabled, | 376 bool autoupdate_enabled, |
| 378 bool extensions_enabled) | 377 bool extensions_enabled) |
| 379 : profile_(profile), | 378 : profile_(profile), |
| 380 extension_prefs_(extension_prefs), | 379 extension_prefs_(extension_prefs), |
| 380 extension_garbage_collector_(new ExtensionGarbageCollector(this)), |
| 381 settings_frontend_(extensions::SettingsFrontend::Create(profile)), | 381 settings_frontend_(extensions::SettingsFrontend::Create(profile)), |
| 382 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 382 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 383 install_directory_(install_directory), | 383 install_directory_(install_directory), |
| 384 extensions_enabled_(extensions_enabled), | 384 extensions_enabled_(extensions_enabled), |
| 385 show_extensions_prompts_(true), | 385 show_extensions_prompts_(true), |
| 386 ready_(false), | 386 ready_(false), |
| 387 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 387 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 388 menu_manager_(profile), | 388 menu_manager_(profile), |
| 389 app_notification_manager_(new AppNotificationManager(profile)), | 389 app_notification_manager_(new AppNotificationManager(profile)), |
| 390 apps_promo_(profile->GetPrefs()), | 390 apps_promo_(profile->GetPrefs()), |
| (...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 // Keep information about the extension so that we can reload it later | 1887 // Keep information about the extension so that we can reload it later |
| 1888 // even if it's not permanently installed. | 1888 // even if it's not permanently installed. |
| 1889 unloaded_extension_paths_[extension->id()] = extension->path(); | 1889 unloaded_extension_paths_[extension->id()] = extension->path(); |
| 1890 | 1890 |
| 1891 // Clean up if the extension is meant to be enabled after a reload. | 1891 // Clean up if the extension is meant to be enabled after a reload. |
| 1892 disabled_extension_paths_.erase(extension->id()); | 1892 disabled_extension_paths_.erase(extension->id()); |
| 1893 | 1893 |
| 1894 // Clean up runtime data. | 1894 // Clean up runtime data. |
| 1895 extension_runtime_data_.erase(extension_id); | 1895 extension_runtime_data_.erase(extension_id); |
| 1896 | 1896 |
| 1897 if (disabled_extensions_.Contains(extension->id())) { | 1897 if (disabled_extensions_.Contains(extension->id())) { |
| 1898 UnloadedExtensionInfo details(extension, reason); | 1898 UnloadedExtensionInfo details(extension, reason); |
| 1899 details.already_disabled = true; | 1899 details.already_disabled = true; |
| 1900 disabled_extensions_.Remove(extension->id()); | 1900 disabled_extensions_.Remove(extension->id()); |
| 1901 content::NotificationService::current()->Notify( | 1901 content::NotificationService::current()->Notify( |
| 1902 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 1902 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 1903 content::Source<Profile>(profile_), | 1903 content::Source<Profile>(profile_), |
| 1904 content::Details<UnloadedExtensionInfo>(&details)); | 1904 content::Details<UnloadedExtensionInfo>(&details)); |
| 1905 // Make sure the profile cleans up its RequestContexts when an already | 1905 // Make sure the profile cleans up its RequestContexts when an already |
| 1906 // disabled extension is unloaded (since they are also tracking the disabled | 1906 // disabled extension is unloaded (since they are also tracking the disabled |
| 1907 // extensions). | 1907 // extensions). |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1929 // or uninstalled, and UnloadAll is just part of shutdown. | 1929 // or uninstalled, and UnloadAll is just part of shutdown. |
| 1930 } | 1930 } |
| 1931 | 1931 |
| 1932 void ExtensionService::ReloadExtensions() { | 1932 void ExtensionService::ReloadExtensions() { |
| 1933 UnloadAllExtensions(); | 1933 UnloadAllExtensions(); |
| 1934 component_loader_->LoadAll(); | 1934 component_loader_->LoadAll(); |
| 1935 extensions::InstalledLoader(this).LoadAllExtensions(); | 1935 extensions::InstalledLoader(this).LoadAllExtensions(); |
| 1936 } | 1936 } |
| 1937 | 1937 |
| 1938 void ExtensionService::GarbageCollectExtensions() { | 1938 void ExtensionService::GarbageCollectExtensions() { |
| 1939 if (extension_prefs_->pref_service()->ReadOnly()) | 1939 extension_garbage_collector_->GarbageCollectExtensions(); |
| 1940 return; | |
| 1941 | |
| 1942 scoped_ptr<ExtensionPrefs::ExtensionsInfo> info( | |
| 1943 extension_prefs_->GetInstalledExtensionsInfo()); | |
| 1944 | |
| 1945 std::map<std::string, FilePath> extension_paths; | |
| 1946 for (size_t i = 0; i < info->size(); ++i) | |
| 1947 extension_paths[info->at(i)->extension_id] = info->at(i)->extension_path; | |
| 1948 | |
| 1949 if (!BrowserThread::PostTask( | |
| 1950 BrowserThread::FILE, FROM_HERE, | |
| 1951 base::Bind( | |
| 1952 &extension_file_util::GarbageCollectExtensions, | |
| 1953 install_directory_, | |
| 1954 extension_paths))) | |
| 1955 NOTREACHED(); | |
| 1956 | 1940 |
| 1957 // Also garbage-collect themes. We check |profile_| to be | 1941 // Also garbage-collect themes. We check |profile_| to be |
| 1958 // defensive; in the future, we may call GarbageCollectExtensions() | 1942 // defensive; in the future, we may call GarbageCollectExtensions() |
| 1959 // from somewhere other than Init() (e.g., in a timer). | 1943 // from somewhere other than Init() (e.g., in a timer). |
| 1960 if (profile_) { | 1944 if (profile_) { |
| 1961 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes(); | 1945 ThemeServiceFactory::GetForProfile(profile_)->RemoveUnusedThemes(); |
| 1962 } | 1946 } |
| 1963 } | 1947 } |
| 1964 | 1948 |
| 1965 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { | 1949 void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2126 // to a version that requires additional privileges. | 2110 // to a version that requires additional privileges. |
| 2127 is_privilege_increase = | 2111 is_privilege_increase = |
| 2128 granted_permissions->HasLessPrivilegesThan( | 2112 granted_permissions->HasLessPrivilegesThan( |
| 2129 extension->GetActivePermissions()); | 2113 extension->GetActivePermissions()); |
| 2130 } | 2114 } |
| 2131 | 2115 |
| 2132 if (is_extension_upgrade) { | 2116 if (is_extension_upgrade) { |
| 2133 // Other than for unpacked extensions, CrxInstaller should have guaranteed | 2117 // Other than for unpacked extensions, CrxInstaller should have guaranteed |
| 2134 // that we aren't downgrading. | 2118 // that we aren't downgrading. |
| 2135 if (extension->location() != Extension::LOAD) | 2119 if (extension->location() != Extension::LOAD) |
| 2136 CHECK(extension->version()->CompareTo(*(old->version())) >= 0); | 2120 CHECK_GE(extension->version()->CompareTo(*(old->version())), 0); |
| 2137 | 2121 |
| 2138 // Extensions get upgraded if the privileges are allowed to increase or | 2122 // Extensions get upgraded if the privileges are allowed to increase or |
| 2139 // the privileges haven't increased. | 2123 // the privileges haven't increased. |
| 2140 if (!is_privilege_increase) { | 2124 if (!is_privilege_increase) { |
| 2141 SetBeingUpgraded(old, true); | 2125 SetBeingUpgraded(old, true); |
| 2142 SetBeingUpgraded(extension, true); | 2126 SetBeingUpgraded(extension, true); |
| 2143 } | 2127 } |
| 2144 | 2128 |
| 2145 // To upgrade an extension in place, unload the old one and | 2129 // To upgrade an extension in place, unload the old one and |
| 2146 // then load the new one. | 2130 // then load the new one. |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 return api_resource_controller_; | 2626 return api_resource_controller_; |
| 2643 } | 2627 } |
| 2644 | 2628 |
| 2645 extensions::RulesRegistryService* ExtensionService::GetRulesRegistryService() { | 2629 extensions::RulesRegistryService* ExtensionService::GetRulesRegistryService() { |
| 2646 if (!rules_registry_service_.get()) { | 2630 if (!rules_registry_service_.get()) { |
| 2647 rules_registry_service_.reset( | 2631 rules_registry_service_.reset( |
| 2648 new extensions::RulesRegistryService(profile_)); | 2632 new extensions::RulesRegistryService(profile_)); |
| 2649 } | 2633 } |
| 2650 return rules_registry_service_.get(); | 2634 return rules_registry_service_.get(); |
| 2651 } | 2635 } |
| OLD | NEW |