| 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 <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "chrome/browser/extensions/settings/settings_frontend.h" | 68 #include "chrome/browser/extensions/settings/settings_frontend.h" |
| 69 #include "chrome/browser/extensions/shell_window_registry.h" | 69 #include "chrome/browser/extensions/shell_window_registry.h" |
| 70 #include "chrome/browser/extensions/unpacked_installer.h" | 70 #include "chrome/browser/extensions/unpacked_installer.h" |
| 71 #include "chrome/browser/extensions/updater/extension_updater.h" | 71 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 72 #include "chrome/browser/extensions/window_event_router.h" | 72 #include "chrome/browser/extensions/window_event_router.h" |
| 73 #include "chrome/browser/history/history_extension_api.h" | 73 #include "chrome/browser/history/history_extension_api.h" |
| 74 #include "chrome/browser/net/chrome_url_request_context.h" | 74 #include "chrome/browser/net/chrome_url_request_context.h" |
| 75 #include "chrome/browser/prefs/pref_service.h" | 75 #include "chrome/browser/prefs/pref_service.h" |
| 76 #include "chrome/browser/profiles/profile.h" | 76 #include "chrome/browser/profiles/profile.h" |
| 77 #include "chrome/browser/profiles/profile_manager.h" | 77 #include "chrome/browser/profiles/profile_manager.h" |
| 78 #include "chrome/browser/search_engines/template_url_service.h" | |
| 79 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
| 80 #include "chrome/browser/themes/theme_service.h" | 78 #include "chrome/browser/themes/theme_service.h" |
| 81 #include "chrome/browser/themes/theme_service_factory.h" | 79 #include "chrome/browser/themes/theme_service_factory.h" |
| 82 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 80 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 83 #include "chrome/browser/ui/webui/favicon_source.h" | 81 #include "chrome/browser/ui/webui/favicon_source.h" |
| 84 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 82 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 85 #include "chrome/browser/ui/webui/theme_source.h" | 83 #include "chrome/browser/ui/webui/theme_source.h" |
| 86 #include "chrome/common/child_process_logging.h" | 84 #include "chrome/common/child_process_logging.h" |
| 87 #include "chrome/common/chrome_notification_types.h" | 85 #include "chrome/common/chrome_notification_types.h" |
| 88 #include "chrome/common/chrome_paths.h" | 86 #include "chrome/common/chrome_paths.h" |
| 89 #include "chrome/common/chrome_switches.h" | 87 #include "chrome/common/chrome_switches.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 // Histogram values for logging events related to externally installed | 149 // Histogram values for logging events related to externally installed |
| 152 // extensions. | 150 // extensions. |
| 153 enum ExternalExtensionEvent { | 151 enum ExternalExtensionEvent { |
| 154 EXTERNAL_EXTENSION_INSTALLED = 0, | 152 EXTERNAL_EXTENSION_INSTALLED = 0, |
| 155 EXTERNAL_EXTENSION_IGNORED, | 153 EXTERNAL_EXTENSION_IGNORED, |
| 156 EXTERNAL_EXTENSION_REENABLED, | 154 EXTERNAL_EXTENSION_REENABLED, |
| 157 EXTERNAL_EXTENSION_UNINSTALLED, | 155 EXTERNAL_EXTENSION_UNINSTALLED, |
| 158 EXTERNAL_EXTENSION_BUCKET_BOUNDARY, | 156 EXTERNAL_EXTENSION_BUCKET_BOUNDARY, |
| 159 }; | 157 }; |
| 160 | 158 |
| 161 #if defined(OS_LINUX) | |
| 162 static const int kOmniboxIconPaddingLeft = 2; | |
| 163 static const int kOmniboxIconPaddingRight = 2; | |
| 164 #elif defined(OS_MACOSX) | |
| 165 static const int kOmniboxIconPaddingLeft = 0; | |
| 166 static const int kOmniboxIconPaddingRight = 2; | |
| 167 #else | |
| 168 static const int kOmniboxIconPaddingLeft = 0; | |
| 169 static const int kOmniboxIconPaddingRight = 0; | |
| 170 #endif | |
| 171 | |
| 172 // Prompt the user this many times before considering an extension acknowledged. | 159 // Prompt the user this many times before considering an extension acknowledged. |
| 173 static const int kMaxExtensionAcknowledgePromptCount = 3; | 160 static const int kMaxExtensionAcknowledgePromptCount = 3; |
| 174 | 161 |
| 175 // Wait this many seconds after an extensions becomes idle before updating it. | 162 // Wait this many seconds after an extensions becomes idle before updating it. |
| 176 static const int kUpdateIdleDelay = 5; | 163 static const int kUpdateIdleDelay = 5; |
| 177 | 164 |
| 178 // Wait this many seconds before trying to garbage collect extensions again. | 165 // Wait this many seconds before trying to garbage collect extensions again. |
| 179 static const int kGarbageCollectRetryDelay = 30; | 166 static const int kGarbageCollectRetryDelay = 30; |
| 180 | 167 |
| 181 const char* kNaClPluginMimeType = "application/x-nacl"; | 168 const char* kNaClPluginMimeType = "application/x-nacl"; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 app_notification_manager_->Init(); | 417 app_notification_manager_->Init(); |
| 431 | 418 |
| 432 if (extensions_enabled_) { | 419 if (extensions_enabled_) { |
| 433 if (!command_line->HasSwitch(switches::kImport) && | 420 if (!command_line->HasSwitch(switches::kImport) && |
| 434 !command_line->HasSwitch(switches::kImportFromFile)) { | 421 !command_line->HasSwitch(switches::kImportFromFile)) { |
| 435 extensions::ExternalProviderImpl::CreateExternalProviders( | 422 extensions::ExternalProviderImpl::CreateExternalProviders( |
| 436 this, profile_, &external_extension_providers_); | 423 this, profile_, &external_extension_providers_); |
| 437 } | 424 } |
| 438 } | 425 } |
| 439 | 426 |
| 440 // Use monochrome icons for Omnibox icons. | |
| 441 omnibox_popup_icon_manager_.set_monochrome(true); | |
| 442 omnibox_icon_manager_.set_monochrome(true); | |
| 443 omnibox_icon_manager_.set_padding(gfx::Insets(0, kOmniboxIconPaddingLeft, | |
| 444 0, kOmniboxIconPaddingRight)); | |
| 445 | |
| 446 // Set this as the ExtensionService for extension sorting to ensure it | 427 // Set this as the ExtensionService for extension sorting to ensure it |
| 447 // cause syncs if required. | 428 // cause syncs if required. |
| 448 extension_prefs_->extension_sorting()->SetExtensionService(this); | 429 extension_prefs_->extension_sorting()->SetExtensionService(this); |
| 449 | 430 |
| 450 #if defined(ENABLE_EXTENSIONS) | 431 #if defined(ENABLE_EXTENSIONS) |
| 451 extension_action_storage_manager_.reset( | 432 extension_action_storage_manager_.reset( |
| 452 new extensions::ExtensionActionStorageManager(profile_)); | 433 new extensions::ExtensionActionStorageManager(profile_)); |
| 453 #endif | 434 #endif |
| 454 | 435 |
| 455 // Before loading any extensions, determine whether Sideload Wipeout is on. | 436 // Before loading any extensions, determine whether Sideload Wipeout is on. |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 if (IsUnacknowledgedExternalExtension(extension)) { | 842 if (IsUnacknowledgedExternalExtension(extension)) { |
| 862 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", | 843 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", |
| 863 EXTERNAL_EXTENSION_UNINSTALLED, | 844 EXTERNAL_EXTENSION_UNINSTALLED, |
| 864 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); | 845 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); |
| 865 } | 846 } |
| 866 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", | 847 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", |
| 867 extension->GetType(), 100); | 848 extension->GetType(), 100); |
| 868 RecordPermissionMessagesHistogram( | 849 RecordPermissionMessagesHistogram( |
| 869 extension, "Extensions.Permissions_Uninstall"); | 850 extension, "Extensions.Permissions_Uninstall"); |
| 870 | 851 |
| 871 TemplateURLService* url_service = | |
| 872 TemplateURLServiceFactory::GetForProfile(profile_); | |
| 873 if (url_service) | |
| 874 url_service->UnregisterExtensionKeyword(extension); | |
| 875 | |
| 876 // Unload before doing more cleanup to ensure that nothing is hanging on to | 852 // Unload before doing more cleanup to ensure that nothing is hanging on to |
| 877 // any of these resources. | 853 // any of these resources. |
| 878 UnloadExtension(extension_id, extension_misc::UNLOAD_REASON_UNINSTALL); | 854 UnloadExtension(extension_id, extension_misc::UNLOAD_REASON_UNINSTALL); |
| 879 | 855 |
| 880 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), | 856 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), |
| 881 external_uninstall); | 857 external_uninstall); |
| 882 | 858 |
| 883 // Tell the backend to start deleting installed extensions on the file thread. | 859 // Tell the backend to start deleting installed extensions on the file thread. |
| 884 if (Extension::LOAD != extension->location()) { | 860 if (Extension::LOAD != extension->location()) { |
| 885 if (!GetFileTaskRunner()->PostTask( | 861 if (!GetFileTaskRunner()->PostTask( |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 // relevant objects via EXTENSION_LOADED? | 1097 // relevant objects via EXTENSION_LOADED? |
| 1122 | 1098 |
| 1123 profile_->GetExtensionSpecialStoragePolicy()-> | 1099 profile_->GetExtensionSpecialStoragePolicy()-> |
| 1124 GrantRightsForExtension(extension); | 1100 GrantRightsForExtension(extension); |
| 1125 | 1101 |
| 1126 UpdateActiveExtensionsInCrashReporter(); | 1102 UpdateActiveExtensionsInCrashReporter(); |
| 1127 | 1103 |
| 1128 ExtensionWebUI::RegisterChromeURLOverrides( | 1104 ExtensionWebUI::RegisterChromeURLOverrides( |
| 1129 profile_, extension->GetChromeURLOverrides()); | 1105 profile_, extension->GetChromeURLOverrides()); |
| 1130 | 1106 |
| 1131 TemplateURLService* url_service = | |
| 1132 TemplateURLServiceFactory::GetForProfile(profile_); | |
| 1133 if (url_service) | |
| 1134 url_service->RegisterExtensionKeyword(extension); | |
| 1135 | |
| 1136 // Load the icon for omnibox-enabled extensions so it will be ready to display | |
| 1137 // in the URL bar. | |
| 1138 if (!extension->omnibox_keyword().empty()) { | |
| 1139 omnibox_popup_icon_manager_.LoadIcon(extension); | |
| 1140 omnibox_icon_manager_.LoadIcon(extension); | |
| 1141 } | |
| 1142 | |
| 1143 // If the extension has permission to load chrome://favicon/ resources we need | 1107 // If the extension has permission to load chrome://favicon/ resources we need |
| 1144 // to make sure that the FaviconSource is registered with the | 1108 // to make sure that the FaviconSource is registered with the |
| 1145 // ChromeURLDataManager. | 1109 // ChromeURLDataManager. |
| 1146 if (extension->HasHostPermission(GURL(chrome::kChromeUIFaviconURL))) { | 1110 if (extension->HasHostPermission(GURL(chrome::kChromeUIFaviconURL))) { |
| 1147 FaviconSource* favicon_source = new FaviconSource(profile_, | 1111 FaviconSource* favicon_source = new FaviconSource(profile_, |
| 1148 FaviconSource::FAVICON); | 1112 FaviconSource::FAVICON); |
| 1149 ChromeURLDataManager::AddDataSource(profile_, favicon_source); | 1113 ChromeURLDataManager::AddDataSource(profile_, favicon_source); |
| 1150 } | 1114 } |
| 1151 | 1115 |
| 1152 #if !defined(OS_ANDROID) | 1116 #if !defined(OS_ANDROID) |
| (...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2645 const Extension* extension = extensions_.GetExtensionOrAppByURL( | 2609 const Extension* extension = extensions_.GetExtensionOrAppByURL( |
| 2646 ExtensionURLInfo(*url)); | 2610 ExtensionURLInfo(*url)); |
| 2647 if (extension && extension->is_platform_app()) { | 2611 if (extension && extension->is_platform_app()) { |
| 2648 *url = GURL(chrome::kExtensionInvalidRequestURL); | 2612 *url = GURL(chrome::kExtensionInvalidRequestURL); |
| 2649 return true; | 2613 return true; |
| 2650 } | 2614 } |
| 2651 | 2615 |
| 2652 return false; | 2616 return false; |
| 2653 } | 2617 } |
| 2654 | 2618 |
| 2655 gfx::Image ExtensionService::GetOmniboxIcon( | |
| 2656 const std::string& extension_id) { | |
| 2657 return gfx::Image(omnibox_icon_manager_.GetIcon(extension_id)); | |
| 2658 } | |
| 2659 | |
| 2660 gfx::Image ExtensionService::GetOmniboxPopupIcon( | |
| 2661 const std::string& extension_id) { | |
| 2662 return gfx::Image(omnibox_popup_icon_manager_.GetIcon(extension_id)); | |
| 2663 } | |
| 2664 | |
| 2665 bool ExtensionService::OnExternalExtensionFileFound( | 2619 bool ExtensionService::OnExternalExtensionFileFound( |
| 2666 const std::string& id, | 2620 const std::string& id, |
| 2667 const Version* version, | 2621 const Version* version, |
| 2668 const FilePath& path, | 2622 const FilePath& path, |
| 2669 Extension::Location location, | 2623 Extension::Location location, |
| 2670 int creation_flags, | 2624 int creation_flags, |
| 2671 bool mark_acknowledged) { | 2625 bool mark_acknowledged) { |
| 2672 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2626 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2673 CHECK(Extension::IdIsValid(id)); | 2627 CHECK(Extension::IdIsValid(id)); |
| 2674 if (extension_prefs_->IsExternalExtensionUninstalled(id)) | 2628 if (extension_prefs_->IsExternalExtensionUninstalled(id)) |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3218 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); | 3172 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); |
| 3219 DCHECK(extension); | 3173 DCHECK(extension); |
| 3220 if (!extension) | 3174 if (!extension) |
| 3221 continue; | 3175 continue; |
| 3222 blacklisted_extensions_.Insert(extension); | 3176 blacklisted_extensions_.Insert(extension); |
| 3223 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); | 3177 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); |
| 3224 } | 3178 } |
| 3225 | 3179 |
| 3226 IdentifyAlertableExtensions(); | 3180 IdentifyAlertableExtensions(); |
| 3227 } | 3181 } |
| OLD | NEW |