| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "chrome/browser/extensions/extension_util.h" | 35 #include "chrome/browser/extensions/extension_util.h" |
| 36 #include "chrome/browser/extensions/external_install_manager.h" | 36 #include "chrome/browser/extensions/external_install_manager.h" |
| 37 #include "chrome/browser/extensions/external_provider_impl.h" | 37 #include "chrome/browser/extensions/external_provider_impl.h" |
| 38 #include "chrome/browser/extensions/install_verifier.h" | 38 #include "chrome/browser/extensions/install_verifier.h" |
| 39 #include "chrome/browser/extensions/installed_loader.h" | 39 #include "chrome/browser/extensions/installed_loader.h" |
| 40 #include "chrome/browser/extensions/pending_extension_manager.h" | 40 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 41 #include "chrome/browser/extensions/permissions_updater.h" | 41 #include "chrome/browser/extensions/permissions_updater.h" |
| 42 #include "chrome/browser/extensions/shared_module_service.h" | 42 #include "chrome/browser/extensions/shared_module_service.h" |
| 43 #include "chrome/browser/extensions/unpacked_installer.h" | 43 #include "chrome/browser/extensions/unpacked_installer.h" |
| 44 #include "chrome/browser/extensions/updater/chrome_extension_downloader_factory.
h" | 44 #include "chrome/browser/extensions/updater/chrome_extension_downloader_factory.
h" |
| 45 #include "chrome/browser/extensions/updater/extension_cache.h" |
| 45 #include "chrome/browser/extensions/updater/extension_downloader.h" | 46 #include "chrome/browser/extensions/updater/extension_downloader.h" |
| 46 #include "chrome/browser/extensions/updater/extension_updater.h" | 47 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 47 #include "chrome/browser/google/google_brand.h" | 48 #include "chrome/browser/google/google_brand.h" |
| 48 #include "chrome/browser/profiles/profile.h" | 49 #include "chrome/browser/profiles/profile.h" |
| 49 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 50 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 50 #include "chrome/browser/ui/webui/favicon_source.h" | 51 #include "chrome/browser/ui/webui/favicon_source.h" |
| 51 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 52 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 52 #include "chrome/browser/ui/webui/theme_source.h" | 53 #include "chrome/browser/ui/webui/theme_source.h" |
| 53 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
| 54 #include "chrome/common/crash_keys.h" | 55 #include "chrome/common/crash_keys.h" |
| 55 #include "chrome/common/extensions/extension_constants.h" | 56 #include "chrome/common/extensions/extension_constants.h" |
| 56 #include "chrome/common/extensions/features/feature_channel.h" | 57 #include "chrome/common/extensions/features/feature_channel.h" |
| 57 #include "chrome/common/extensions/manifest_url_handler.h" | 58 #include "chrome/common/extensions/manifest_url_handler.h" |
| 58 #include "chrome/common/url_constants.h" | 59 #include "chrome/common/url_constants.h" |
| 59 #include "components/crx_file/id_util.h" | 60 #include "components/crx_file/id_util.h" |
| 60 #include "components/startup_metric_utils/startup_metric_utils.h" | 61 #include "components/startup_metric_utils/startup_metric_utils.h" |
| 61 #include "content/public/browser/devtools_agent_host.h" | 62 #include "content/public/browser/devtools_agent_host.h" |
| 62 #include "content/public/browser/notification_service.h" | 63 #include "content/public/browser/notification_service.h" |
| 63 #include "content/public/browser/render_process_host.h" | 64 #include "content/public/browser/render_process_host.h" |
| 64 #include "content/public/browser/storage_partition.h" | 65 #include "content/public/browser/storage_partition.h" |
| 65 #include "extensions/browser/event_router.h" | 66 #include "extensions/browser/event_router.h" |
| 66 #include "extensions/browser/extension_host.h" | 67 #include "extensions/browser/extension_host.h" |
| 67 #include "extensions/browser/extension_prefs.h" | 68 #include "extensions/browser/extension_prefs.h" |
| 68 #include "extensions/browser/extension_registry.h" | 69 #include "extensions/browser/extension_registry.h" |
| 69 #include "extensions/browser/extension_system.h" | 70 #include "extensions/browser/extension_system.h" |
| 70 #include "extensions/browser/extensions_browser_client.h" | |
| 71 #include "extensions/browser/install_flag.h" | 71 #include "extensions/browser/install_flag.h" |
| 72 #include "extensions/browser/runtime_data.h" | 72 #include "extensions/browser/runtime_data.h" |
| 73 #include "extensions/browser/uninstall_reason.h" | 73 #include "extensions/browser/uninstall_reason.h" |
| 74 #include "extensions/browser/update_observer.h" | 74 #include "extensions/browser/update_observer.h" |
| 75 #include "extensions/browser/updater/extension_cache.h" | |
| 76 #include "extensions/common/extension_messages.h" | 75 #include "extensions/common/extension_messages.h" |
| 77 #include "extensions/common/extension_urls.h" | 76 #include "extensions/common/extension_urls.h" |
| 78 #include "extensions/common/feature_switch.h" | 77 #include "extensions/common/feature_switch.h" |
| 79 #include "extensions/common/file_util.h" | 78 #include "extensions/common/file_util.h" |
| 80 #include "extensions/common/manifest_constants.h" | 79 #include "extensions/common/manifest_constants.h" |
| 81 #include "extensions/common/manifest_handlers/background_info.h" | 80 #include "extensions/common/manifest_handlers/background_info.h" |
| 82 #include "extensions/common/one_shot_event.h" | 81 #include "extensions/common/one_shot_event.h" |
| 83 #include "extensions/common/permissions/permission_message_provider.h" | 82 #include "extensions/common/permissions/permission_message_provider.h" |
| 84 #include "extensions/common/permissions/permissions_data.h" | 83 #include "extensions/common/permissions/permissions_data.h" |
| 85 | 84 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 const std::string& install_parameter, | 178 const std::string& install_parameter, |
| 180 const GURL& update_url, | 179 const GURL& update_url, |
| 181 Manifest::Location location, | 180 Manifest::Location location, |
| 182 int creation_flags, | 181 int creation_flags, |
| 183 bool mark_acknowledged) { | 182 bool mark_acknowledged) { |
| 184 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 183 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 185 CHECK(crx_file::id_util::IdIsValid(id)); | 184 CHECK(crx_file::id_util::IdIsValid(id)); |
| 186 | 185 |
| 187 if (Manifest::IsExternalLocation(location)) { | 186 if (Manifest::IsExternalLocation(location)) { |
| 188 // All extensions that are not user specific can be cached. | 187 // All extensions that are not user specific can be cached. |
| 189 extensions::ExtensionsBrowserClient::Get()->GetExtensionCache() | 188 extensions::ExtensionCache::GetInstance()->AllowCaching(id); |
| 190 ->AllowCaching(id); | |
| 191 } | 189 } |
| 192 | 190 |
| 193 const Extension* extension = GetExtensionById(id, true); | 191 const Extension* extension = GetExtensionById(id, true); |
| 194 if (extension) { | 192 if (extension) { |
| 195 // Already installed. Skip this install if the current location has | 193 // Already installed. Skip this install if the current location has |
| 196 // higher priority than |location|. | 194 // higher priority than |location|. |
| 197 Manifest::Location current = extension->location(); | 195 Manifest::Location current = extension->location(); |
| 198 if (current == Manifest::GetHigherPriorityLocation(current, location)) | 196 if (current == Manifest::GetHigherPriorityLocation(current, location)) |
| 199 return false; | 197 return false; |
| 200 // Otherwise, overwrite the current installation. | 198 // Otherwise, overwrite the current installation. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 base::StringToInt(command_line->GetSwitchValueASCII( | 300 base::StringToInt(command_line->GetSwitchValueASCII( |
| 303 switches::kExtensionsUpdateFrequency), | 301 switches::kExtensionsUpdateFrequency), |
| 304 &update_frequency); | 302 &update_frequency); |
| 305 } | 303 } |
| 306 updater_.reset(new extensions::ExtensionUpdater( | 304 updater_.reset(new extensions::ExtensionUpdater( |
| 307 this, | 305 this, |
| 308 extension_prefs, | 306 extension_prefs, |
| 309 profile->GetPrefs(), | 307 profile->GetPrefs(), |
| 310 profile, | 308 profile, |
| 311 update_frequency, | 309 update_frequency, |
| 312 extensions::ExtensionsBrowserClient::Get()->GetExtensionCache(), | 310 extensions::ExtensionCache::GetInstance(), |
| 313 base::Bind(ChromeExtensionDownloaderFactory::CreateForProfile, | 311 base::Bind(ChromeExtensionDownloaderFactory::CreateForProfile, |
| 314 profile))); | 312 profile))); |
| 315 } | 313 } |
| 316 | 314 |
| 317 component_loader_.reset( | 315 component_loader_.reset( |
| 318 new extensions::ComponentLoader(this, | 316 new extensions::ComponentLoader(this, |
| 319 profile->GetPrefs(), | 317 profile->GetPrefs(), |
| 320 g_browser_process->local_state(), | 318 g_browser_process->local_state(), |
| 321 profile)); | 319 profile)); |
| 322 | 320 |
| (...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 } | 2367 } |
| 2370 | 2368 |
| 2371 void ExtensionService::OnProfileDestructionStarted() { | 2369 void ExtensionService::OnProfileDestructionStarted() { |
| 2372 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2370 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2373 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2371 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2374 it != ids_to_unload.end(); | 2372 it != ids_to_unload.end(); |
| 2375 ++it) { | 2373 ++it) { |
| 2376 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2374 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2377 } | 2375 } |
| 2378 } | 2376 } |
| OLD | NEW |