| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // Histogram values for logging events related to externally installed | 153 // Histogram values for logging events related to externally installed |
| 154 // extensions. | 154 // extensions. |
| 155 enum ExternalExtensionEvent { | 155 enum ExternalExtensionEvent { |
| 156 EXTERNAL_EXTENSION_INSTALLED = 0, | 156 EXTERNAL_EXTENSION_INSTALLED = 0, |
| 157 EXTERNAL_EXTENSION_IGNORED, | 157 EXTERNAL_EXTENSION_IGNORED, |
| 158 EXTERNAL_EXTENSION_REENABLED, | 158 EXTERNAL_EXTENSION_REENABLED, |
| 159 EXTERNAL_EXTENSION_UNINSTALLED, | 159 EXTERNAL_EXTENSION_UNINSTALLED, |
| 160 EXTERNAL_EXTENSION_BUCKET_BOUNDARY, | 160 EXTERNAL_EXTENSION_BUCKET_BOUNDARY, |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 #if defined(OS_LINUX) | |
| 164 static const int kOmniboxIconPaddingLeft = 2; | |
| 165 static const int kOmniboxIconPaddingRight = 2; | |
| 166 #elif defined(OS_MACOSX) | |
| 167 static const int kOmniboxIconPaddingLeft = 0; | |
| 168 static const int kOmniboxIconPaddingRight = 2; | |
| 169 #else | |
| 170 static const int kOmniboxIconPaddingLeft = 0; | |
| 171 static const int kOmniboxIconPaddingRight = 0; | |
| 172 #endif | |
| 173 | |
| 174 // Prompt the user this many times before considering an extension acknowledged. | 163 // Prompt the user this many times before considering an extension acknowledged. |
| 175 static const int kMaxExtensionAcknowledgePromptCount = 3; | 164 static const int kMaxExtensionAcknowledgePromptCount = 3; |
| 176 | 165 |
| 177 // Wait this many seconds after an extensions becomes idle before updating it. | 166 // Wait this many seconds after an extensions becomes idle before updating it. |
| 178 static const int kUpdateIdleDelay = 5; | 167 static const int kUpdateIdleDelay = 5; |
| 179 | 168 |
| 180 // Wait this many seconds before trying to garbage collect extensions again. | 169 // Wait this many seconds before trying to garbage collect extensions again. |
| 181 static const int kGarbageCollectRetryDelay = 30; | 170 static const int kGarbageCollectRetryDelay = 30; |
| 182 | 171 |
| 183 const char* kNaClPluginMimeType = "application/x-nacl"; | 172 const char* kNaClPluginMimeType = "application/x-nacl"; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 app_notification_manager_->Init(); | 419 app_notification_manager_->Init(); |
| 431 | 420 |
| 432 if (extensions_enabled_) { | 421 if (extensions_enabled_) { |
| 433 if (!command_line->HasSwitch(switches::kImport) && | 422 if (!command_line->HasSwitch(switches::kImport) && |
| 434 !command_line->HasSwitch(switches::kImportFromFile)) { | 423 !command_line->HasSwitch(switches::kImportFromFile)) { |
| 435 extensions::ExternalProviderImpl::CreateExternalProviders( | 424 extensions::ExternalProviderImpl::CreateExternalProviders( |
| 436 this, profile_, &external_extension_providers_); | 425 this, profile_, &external_extension_providers_); |
| 437 } | 426 } |
| 438 } | 427 } |
| 439 | 428 |
| 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 | 429 // Set this as the ExtensionService for extension sorting to ensure it |
| 447 // cause syncs if required. | 430 // cause syncs if required. |
| 448 extension_prefs_->extension_sorting()->SetExtensionService(this); | 431 extension_prefs_->extension_sorting()->SetExtensionService(this); |
| 449 | 432 |
| 450 #if defined(ENABLE_EXTENSIONS) | 433 #if defined(ENABLE_EXTENSIONS) |
| 451 extension_action_storage_manager_.reset( | 434 extension_action_storage_manager_.reset( |
| 452 new extensions::ExtensionActionStorageManager(profile_)); | 435 new extensions::ExtensionActionStorageManager(profile_)); |
| 453 #endif | 436 #endif |
| 454 | 437 |
| 455 // How long is the path to the Extensions directory? | 438 // How long is the path to the Extensions directory? |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 UpdateActiveExtensionsInCrashReporter(); | 1091 UpdateActiveExtensionsInCrashReporter(); |
| 1109 | 1092 |
| 1110 ExtensionWebUI::RegisterChromeURLOverrides( | 1093 ExtensionWebUI::RegisterChromeURLOverrides( |
| 1111 profile_, extension->GetChromeURLOverrides()); | 1094 profile_, extension->GetChromeURLOverrides()); |
| 1112 | 1095 |
| 1113 TemplateURLService* url_service = | 1096 TemplateURLService* url_service = |
| 1114 TemplateURLServiceFactory::GetForProfile(profile_); | 1097 TemplateURLServiceFactory::GetForProfile(profile_); |
| 1115 if (url_service) | 1098 if (url_service) |
| 1116 url_service->RegisterExtensionKeyword(extension); | 1099 url_service->RegisterExtensionKeyword(extension); |
| 1117 | 1100 |
| 1118 // Load the icon for omnibox-enabled extensions so it will be ready to display | |
| 1119 // in the URL bar. | |
| 1120 if (!extension->omnibox_keyword().empty()) { | |
| 1121 omnibox_popup_icon_manager_.LoadIcon(extension); | |
| 1122 omnibox_icon_manager_.LoadIcon(extension); | |
| 1123 } | |
| 1124 | |
| 1125 // If the extension has permission to load chrome://favicon/ resources we need | 1101 // If the extension has permission to load chrome://favicon/ resources we need |
| 1126 // to make sure that the FaviconSource is registered with the | 1102 // to make sure that the FaviconSource is registered with the |
| 1127 // ChromeURLDataManager. | 1103 // ChromeURLDataManager. |
| 1128 if (extension->HasHostPermission(GURL(chrome::kChromeUIFaviconURL))) { | 1104 if (extension->HasHostPermission(GURL(chrome::kChromeUIFaviconURL))) { |
| 1129 FaviconSource* favicon_source = new FaviconSource(profile_, | 1105 FaviconSource* favicon_source = new FaviconSource(profile_, |
| 1130 FaviconSource::FAVICON); | 1106 FaviconSource::FAVICON); |
| 1131 ChromeURLDataManager::AddDataSource(profile_, favicon_source); | 1107 ChromeURLDataManager::AddDataSource(profile_, favicon_source); |
| 1132 } | 1108 } |
| 1133 | 1109 |
| 1134 #if !defined(OS_ANDROID) | 1110 #if !defined(OS_ANDROID) |
| (...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2618 const Extension* extension = extensions_.GetExtensionOrAppByURL( | 2594 const Extension* extension = extensions_.GetExtensionOrAppByURL( |
| 2619 ExtensionURLInfo(*url)); | 2595 ExtensionURLInfo(*url)); |
| 2620 if (extension && extension->is_platform_app()) { | 2596 if (extension && extension->is_platform_app()) { |
| 2621 *url = GURL(chrome::kExtensionInvalidRequestURL); | 2597 *url = GURL(chrome::kExtensionInvalidRequestURL); |
| 2622 return true; | 2598 return true; |
| 2623 } | 2599 } |
| 2624 | 2600 |
| 2625 return false; | 2601 return false; |
| 2626 } | 2602 } |
| 2627 | 2603 |
| 2628 gfx::Image ExtensionService::GetOmniboxIcon( | |
| 2629 const std::string& extension_id) { | |
| 2630 return gfx::Image(omnibox_icon_manager_.GetIcon(extension_id)); | |
| 2631 } | |
| 2632 | |
| 2633 gfx::Image ExtensionService::GetOmniboxPopupIcon( | |
| 2634 const std::string& extension_id) { | |
| 2635 return gfx::Image(omnibox_popup_icon_manager_.GetIcon(extension_id)); | |
| 2636 } | |
| 2637 | |
| 2638 bool ExtensionService::OnExternalExtensionFileFound( | 2604 bool ExtensionService::OnExternalExtensionFileFound( |
| 2639 const std::string& id, | 2605 const std::string& id, |
| 2640 const Version* version, | 2606 const Version* version, |
| 2641 const FilePath& path, | 2607 const FilePath& path, |
| 2642 Extension::Location location, | 2608 Extension::Location location, |
| 2643 int creation_flags, | 2609 int creation_flags, |
| 2644 bool mark_acknowledged) { | 2610 bool mark_acknowledged) { |
| 2645 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2611 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2646 CHECK(Extension::IdIsValid(id)); | 2612 CHECK(Extension::IdIsValid(id)); |
| 2647 if (extension_prefs_->IsExternalExtensionUninstalled(id)) | 2613 if (extension_prefs_->IsExternalExtensionUninstalled(id)) |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3151 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); | 3117 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); |
| 3152 DCHECK(extension); | 3118 DCHECK(extension); |
| 3153 if (!extension) | 3119 if (!extension) |
| 3154 continue; | 3120 continue; |
| 3155 blacklisted_extensions_.Insert(extension); | 3121 blacklisted_extensions_.Insert(extension); |
| 3156 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); | 3122 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); |
| 3157 } | 3123 } |
| 3158 | 3124 |
| 3159 IdentifyAlertableExtensions(); | 3125 IdentifyAlertableExtensions(); |
| 3160 } | 3126 } |
| OLD | NEW |