| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 #include "chrome/browser/extensions/settings/settings_frontend.h" | 70 #include "chrome/browser/extensions/settings/settings_frontend.h" |
| 71 #include "chrome/browser/extensions/shell_window_registry.h" | 71 #include "chrome/browser/extensions/shell_window_registry.h" |
| 72 #include "chrome/browser/extensions/unpacked_installer.h" | 72 #include "chrome/browser/extensions/unpacked_installer.h" |
| 73 #include "chrome/browser/extensions/updater/extension_updater.h" | 73 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 74 #include "chrome/browser/extensions/window_event_router.h" | 74 #include "chrome/browser/extensions/window_event_router.h" |
| 75 #include "chrome/browser/history/history_extension_api.h" | 75 #include "chrome/browser/history/history_extension_api.h" |
| 76 #include "chrome/browser/net/chrome_url_request_context.h" | 76 #include "chrome/browser/net/chrome_url_request_context.h" |
| 77 #include "chrome/browser/prefs/pref_service.h" | 77 #include "chrome/browser/prefs/pref_service.h" |
| 78 #include "chrome/browser/profiles/profile.h" | 78 #include "chrome/browser/profiles/profile.h" |
| 79 #include "chrome/browser/profiles/profile_manager.h" | 79 #include "chrome/browser/profiles/profile_manager.h" |
| 80 #include "chrome/browser/search_engines/template_url_service.h" | |
| 81 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
| 82 #include "chrome/browser/themes/theme_service.h" | 80 #include "chrome/browser/themes/theme_service.h" |
| 83 #include "chrome/browser/themes/theme_service_factory.h" | 81 #include "chrome/browser/themes/theme_service_factory.h" |
| 84 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 82 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 85 #include "chrome/browser/ui/webui/favicon_source.h" | 83 #include "chrome/browser/ui/webui/favicon_source.h" |
| 86 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 84 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 87 #include "chrome/browser/ui/webui/theme_source.h" | 85 #include "chrome/browser/ui/webui/theme_source.h" |
| 88 #include "chrome/common/child_process_logging.h" | 86 #include "chrome/common/child_process_logging.h" |
| 89 #include "chrome/common/chrome_notification_types.h" | 87 #include "chrome/common/chrome_notification_types.h" |
| 90 #include "chrome/common/chrome_paths.h" | 88 #include "chrome/common/chrome_paths.h" |
| 91 #include "chrome/common/chrome_switches.h" | 89 #include "chrome/common/chrome_switches.h" |
| (...skipping 59 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 app_notification_manager_->Init(); | 415 app_notification_manager_->Init(); |
| 429 | 416 |
| 430 if (extensions_enabled_) { | 417 if (extensions_enabled_) { |
| 431 if (!command_line->HasSwitch(switches::kImport) && | 418 if (!command_line->HasSwitch(switches::kImport) && |
| 432 !command_line->HasSwitch(switches::kImportFromFile)) { | 419 !command_line->HasSwitch(switches::kImportFromFile)) { |
| 433 extensions::ExternalProviderImpl::CreateExternalProviders( | 420 extensions::ExternalProviderImpl::CreateExternalProviders( |
| 434 this, profile_, &external_extension_providers_); | 421 this, profile_, &external_extension_providers_); |
| 435 } | 422 } |
| 436 } | 423 } |
| 437 | 424 |
| 438 // Use monochrome icons for Omnibox icons. | |
| 439 omnibox_popup_icon_manager_.set_monochrome(true); | |
| 440 omnibox_icon_manager_.set_monochrome(true); | |
| 441 omnibox_icon_manager_.set_padding(gfx::Insets(0, kOmniboxIconPaddingLeft, | |
| 442 0, kOmniboxIconPaddingRight)); | |
| 443 | |
| 444 // Set this as the ExtensionService for extension sorting to ensure it | 425 // Set this as the ExtensionService for extension sorting to ensure it |
| 445 // cause syncs if required. | 426 // cause syncs if required. |
| 446 extension_prefs_->extension_sorting()->SetExtensionService(this); | 427 extension_prefs_->extension_sorting()->SetExtensionService(this); |
| 447 | 428 |
| 448 #if defined(ENABLE_EXTENSIONS) | 429 #if defined(ENABLE_EXTENSIONS) |
| 449 extension_action_storage_manager_.reset( | 430 extension_action_storage_manager_.reset( |
| 450 new extensions::ExtensionActionStorageManager(profile_)); | 431 new extensions::ExtensionActionStorageManager(profile_)); |
| 451 #endif | 432 #endif |
| 452 | 433 |
| 453 // How long is the path to the Extensions directory? | 434 // How long is the path to the Extensions directory? |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 if (IsUnacknowledgedExternalExtension(extension)) { | 827 if (IsUnacknowledgedExternalExtension(extension)) { |
| 847 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", | 828 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", |
| 848 EXTERNAL_EXTENSION_UNINSTALLED, | 829 EXTERNAL_EXTENSION_UNINSTALLED, |
| 849 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); | 830 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); |
| 850 } | 831 } |
| 851 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", | 832 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", |
| 852 extension->GetType(), 100); | 833 extension->GetType(), 100); |
| 853 RecordPermissionMessagesHistogram( | 834 RecordPermissionMessagesHistogram( |
| 854 extension, "Extensions.Permissions_Uninstall"); | 835 extension, "Extensions.Permissions_Uninstall"); |
| 855 | 836 |
| 856 TemplateURLService* url_service = | |
| 857 TemplateURLServiceFactory::GetForProfile(profile_); | |
| 858 if (url_service) | |
| 859 url_service->UnregisterExtensionKeyword(extension); | |
| 860 | |
| 861 // Unload before doing more cleanup to ensure that nothing is hanging on to | 837 // Unload before doing more cleanup to ensure that nothing is hanging on to |
| 862 // any of these resources. | 838 // any of these resources. |
| 863 UnloadExtension(extension_id, extension_misc::UNLOAD_REASON_UNINSTALL); | 839 UnloadExtension(extension_id, extension_misc::UNLOAD_REASON_UNINSTALL); |
| 864 | 840 |
| 865 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), | 841 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), |
| 866 external_uninstall); | 842 external_uninstall); |
| 867 | 843 |
| 868 // Tell the backend to start deleting installed extensions on the file thread. | 844 // Tell the backend to start deleting installed extensions on the file thread. |
| 869 if (Extension::LOAD != extension->location()) { | 845 if (Extension::LOAD != extension->location()) { |
| 870 if (!GetFileTaskRunner()->PostTask( | 846 if (!GetFileTaskRunner()->PostTask( |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 // relevant objects via EXTENSION_LOADED? | 1073 // relevant objects via EXTENSION_LOADED? |
| 1098 | 1074 |
| 1099 profile_->GetExtensionSpecialStoragePolicy()-> | 1075 profile_->GetExtensionSpecialStoragePolicy()-> |
| 1100 GrantRightsForExtension(extension); | 1076 GrantRightsForExtension(extension); |
| 1101 | 1077 |
| 1102 UpdateActiveExtensionsInCrashReporter(); | 1078 UpdateActiveExtensionsInCrashReporter(); |
| 1103 | 1079 |
| 1104 ExtensionWebUI::RegisterChromeURLOverrides( | 1080 ExtensionWebUI::RegisterChromeURLOverrides( |
| 1105 profile_, extension->GetChromeURLOverrides()); | 1081 profile_, extension->GetChromeURLOverrides()); |
| 1106 | 1082 |
| 1107 TemplateURLService* url_service = | |
| 1108 TemplateURLServiceFactory::GetForProfile(profile_); | |
| 1109 if (url_service) | |
| 1110 url_service->RegisterExtensionKeyword(extension); | |
| 1111 | |
| 1112 // Load the icon for omnibox-enabled extensions so it will be ready to display | |
| 1113 // in the URL bar. | |
| 1114 if (!extension->omnibox_keyword().empty()) { | |
| 1115 omnibox_popup_icon_manager_.LoadIcon(extension); | |
| 1116 omnibox_icon_manager_.LoadIcon(extension); | |
| 1117 } | |
| 1118 | |
| 1119 // If the extension has permission to load chrome://favicon/ resources we need | 1083 // If the extension has permission to load chrome://favicon/ resources we need |
| 1120 // to make sure that the FaviconSource is registered with the | 1084 // to make sure that the FaviconSource is registered with the |
| 1121 // ChromeURLDataManager. | 1085 // ChromeURLDataManager. |
| 1122 if (extension->HasHostPermission(GURL(chrome::kChromeUIFaviconURL))) { | 1086 if (extension->HasHostPermission(GURL(chrome::kChromeUIFaviconURL))) { |
| 1123 FaviconSource* favicon_source = new FaviconSource(profile_, | 1087 FaviconSource* favicon_source = new FaviconSource(profile_, |
| 1124 FaviconSource::FAVICON); | 1088 FaviconSource::FAVICON); |
| 1125 ChromeURLDataManager::AddDataSource(profile_, favicon_source); | 1089 ChromeURLDataManager::AddDataSource(profile_, favicon_source); |
| 1126 } | 1090 } |
| 1127 | 1091 |
| 1128 #if !defined(OS_ANDROID) | 1092 #if !defined(OS_ANDROID) |
| (...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2592 const Extension* extension = extensions_.GetExtensionOrAppByURL( | 2556 const Extension* extension = extensions_.GetExtensionOrAppByURL( |
| 2593 ExtensionURLInfo(*url)); | 2557 ExtensionURLInfo(*url)); |
| 2594 if (extension && extension->is_platform_app()) { | 2558 if (extension && extension->is_platform_app()) { |
| 2595 *url = GURL(chrome::kExtensionInvalidRequestURL); | 2559 *url = GURL(chrome::kExtensionInvalidRequestURL); |
| 2596 return true; | 2560 return true; |
| 2597 } | 2561 } |
| 2598 | 2562 |
| 2599 return false; | 2563 return false; |
| 2600 } | 2564 } |
| 2601 | 2565 |
| 2602 gfx::Image ExtensionService::GetOmniboxIcon( | |
| 2603 const std::string& extension_id) { | |
| 2604 return gfx::Image(omnibox_icon_manager_.GetIcon(extension_id)); | |
| 2605 } | |
| 2606 | |
| 2607 gfx::Image ExtensionService::GetOmniboxPopupIcon( | |
| 2608 const std::string& extension_id) { | |
| 2609 return gfx::Image(omnibox_popup_icon_manager_.GetIcon(extension_id)); | |
| 2610 } | |
| 2611 | |
| 2612 bool ExtensionService::OnExternalExtensionFileFound( | 2566 bool ExtensionService::OnExternalExtensionFileFound( |
| 2613 const std::string& id, | 2567 const std::string& id, |
| 2614 const Version* version, | 2568 const Version* version, |
| 2615 const FilePath& path, | 2569 const FilePath& path, |
| 2616 Extension::Location location, | 2570 Extension::Location location, |
| 2617 int creation_flags, | 2571 int creation_flags, |
| 2618 bool mark_acknowledged) { | 2572 bool mark_acknowledged) { |
| 2619 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2573 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2620 CHECK(Extension::IdIsValid(id)); | 2574 CHECK(Extension::IdIsValid(id)); |
| 2621 if (extension_prefs_->IsExternalExtensionUninstalled(id)) | 2575 if (extension_prefs_->IsExternalExtensionUninstalled(id)) |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3125 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); | 3079 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); |
| 3126 DCHECK(extension); | 3080 DCHECK(extension); |
| 3127 if (!extension) | 3081 if (!extension) |
| 3128 continue; | 3082 continue; |
| 3129 blacklisted_extensions_.Insert(extension); | 3083 blacklisted_extensions_.Insert(extension); |
| 3130 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); | 3084 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); |
| 3131 } | 3085 } |
| 3132 | 3086 |
| 3133 IdentifyAlertableExtensions(); | 3087 IdentifyAlertableExtensions(); |
| 3134 } | 3088 } |
| OLD | NEW |