| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 22 #include "chrome/browser/extensions/component_loader.h" | 22 #include "chrome/browser/extensions/component_loader.h" |
| 23 #include "chrome/browser/extensions/crx_installer.h" | |
| 24 #include "chrome/browser/extensions/data_deleter.h" | 23 #include "chrome/browser/extensions/data_deleter.h" |
| 25 #include "chrome/browser/extensions/extension_assets_manager.h" | 24 #include "chrome/browser/extensions/extension_assets_manager.h" |
| 26 #include "chrome/browser/extensions/extension_disabled_ui.h" | 25 #include "chrome/browser/extensions/extension_disabled_ui.h" |
| 27 #include "chrome/browser/extensions/extension_error_controller.h" | 26 #include "chrome/browser/extensions/extension_error_controller.h" |
| 28 #include "chrome/browser/extensions/extension_install_ui.h" | 27 #include "chrome/browser/extensions/extension_install_ui.h" |
| 29 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 30 #include "chrome/browser/extensions/extension_sync_service.h" | 29 #include "chrome/browser/extensions/extension_sync_service.h" |
| 31 #include "chrome/browser/extensions/extension_util.h" | 30 #include "chrome/browser/extensions/extension_util.h" |
| 32 #include "chrome/browser/extensions/external_install_manager.h" | 31 #include "chrome/browser/extensions/external_install_manager.h" |
| 33 #include "chrome/browser/extensions/external_provider_impl.h" | 32 #include "chrome/browser/extensions/external_provider_impl.h" |
| 34 #include "chrome/browser/extensions/install_verifier.h" | 33 #include "chrome/browser/extensions/install_verifier.h" |
| 35 #include "chrome/browser/extensions/installed_loader.h" | 34 #include "chrome/browser/extensions/installed_loader.h" |
| 36 #include "chrome/browser/extensions/pending_extension_manager.h" | 35 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 37 #include "chrome/browser/extensions/permissions_updater.h" | 36 #include "chrome/browser/extensions/permissions_updater.h" |
| 38 #include "chrome/browser/extensions/shared_module_service.h" | 37 #include "chrome/browser/extensions/shared_module_service.h" |
| 39 #include "chrome/browser/extensions/unpacked_installer.h" | 38 #include "chrome/browser/extensions/unpacked_installer.h" |
| 40 #include "chrome/browser/extensions/updater/extension_cache.h" | 39 #include "chrome/browser/extensions/updater/extension_cache.h" |
| 41 #include "chrome/browser/extensions/updater/extension_updater.h" | |
| 42 #include "chrome/browser/profiles/profile.h" | 40 #include "chrome/browser/profiles/profile.h" |
| 43 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 41 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 44 #include "chrome/browser/ui/webui/favicon_source.h" | 42 #include "chrome/browser/ui/webui/favicon_source.h" |
| 45 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 43 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 46 #include "chrome/browser/ui/webui/theme_source.h" | 44 #include "chrome/browser/ui/webui/theme_source.h" |
| 47 #include "chrome/common/chrome_switches.h" | 45 #include "chrome/common/chrome_switches.h" |
| 48 #include "chrome/common/crash_keys.h" | 46 #include "chrome/common/crash_keys.h" |
| 49 #include "chrome/common/extensions/extension_constants.h" | 47 #include "chrome/common/extensions/extension_constants.h" |
| 50 #include "chrome/common/extensions/features/feature_channel.h" | 48 #include "chrome/common/extensions/features/feature_channel.h" |
| 51 #include "chrome/common/extensions/manifest_url_handler.h" | 49 #include "chrome/common/extensions/manifest_url_handler.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 73 #include "extensions/common/one_shot_event.h" | 71 #include "extensions/common/one_shot_event.h" |
| 74 #include "extensions/common/permissions/permission_message_provider.h" | 72 #include "extensions/common/permissions/permission_message_provider.h" |
| 75 #include "extensions/common/permissions/permissions_data.h" | 73 #include "extensions/common/permissions/permissions_data.h" |
| 76 | 74 |
| 77 #if defined(OS_CHROMEOS) | 75 #if defined(OS_CHROMEOS) |
| 78 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 76 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
| 79 #include "webkit/browser/fileapi/file_system_backend.h" | 77 #include "webkit/browser/fileapi/file_system_backend.h" |
| 80 #include "webkit/browser/fileapi/file_system_context.h" | 78 #include "webkit/browser/fileapi/file_system_context.h" |
| 81 #endif | 79 #endif |
| 82 | 80 |
| 81 // TODO(thestig): Eventually remove the #ifdefs when ExtensionService is no |
| 82 // longer used on mobile. |
| 83 #if defined(ENABLE_EXTENSIONS) |
| 84 #include "chrome/browser/extensions/crx_installer.h" |
| 85 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 86 #endif |
| 87 |
| 83 using content::BrowserContext; | 88 using content::BrowserContext; |
| 84 using content::BrowserThread; | 89 using content::BrowserThread; |
| 85 using content::DevToolsAgentHost; | 90 using content::DevToolsAgentHost; |
| 86 using extensions::CrxInstaller; | 91 using extensions::CrxInstaller; |
| 87 using extensions::Extension; | 92 using extensions::Extension; |
| 88 using extensions::ExtensionIdSet; | 93 using extensions::ExtensionIdSet; |
| 89 using extensions::ExtensionInfo; | 94 using extensions::ExtensionInfo; |
| 90 using extensions::ExtensionRegistry; | 95 using extensions::ExtensionRegistry; |
| 91 using extensions::ExtensionSet; | 96 using extensions::ExtensionSet; |
| 92 using extensions::FeatureSwitch; | 97 using extensions::FeatureSwitch; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 107 // Histogram values for logging events related to externally installed | 112 // Histogram values for logging events related to externally installed |
| 108 // extensions. | 113 // extensions. |
| 109 enum ExternalExtensionEvent { | 114 enum ExternalExtensionEvent { |
| 110 EXTERNAL_EXTENSION_INSTALLED = 0, | 115 EXTERNAL_EXTENSION_INSTALLED = 0, |
| 111 EXTERNAL_EXTENSION_IGNORED, | 116 EXTERNAL_EXTENSION_IGNORED, |
| 112 EXTERNAL_EXTENSION_REENABLED, | 117 EXTERNAL_EXTENSION_REENABLED, |
| 113 EXTERNAL_EXTENSION_UNINSTALLED, | 118 EXTERNAL_EXTENSION_UNINSTALLED, |
| 114 EXTERNAL_EXTENSION_BUCKET_BOUNDARY, | 119 EXTERNAL_EXTENSION_BUCKET_BOUNDARY, |
| 115 }; | 120 }; |
| 116 | 121 |
| 122 #if defined(ENABLE_EXTENSIONS) |
| 117 // Prompt the user this many times before considering an extension acknowledged. | 123 // Prompt the user this many times before considering an extension acknowledged. |
| 118 static const int kMaxExtensionAcknowledgePromptCount = 3; | 124 const int kMaxExtensionAcknowledgePromptCount = 3; |
| 125 #endif |
| 119 | 126 |
| 120 // Wait this many seconds after an extensions becomes idle before updating it. | 127 // Wait this many seconds after an extensions becomes idle before updating it. |
| 121 static const int kUpdateIdleDelay = 5; | 128 const int kUpdateIdleDelay = 5; |
| 122 | 129 |
| 123 static bool IsCWSSharedModule(const Extension* extension) { | 130 bool IsCWSSharedModule(const Extension* extension) { |
| 124 return extension->from_webstore() && | 131 return extension->from_webstore() && |
| 125 SharedModuleInfo::IsSharedModule(extension); | 132 SharedModuleInfo::IsSharedModule(extension); |
| 126 } | 133 } |
| 127 | 134 |
| 128 class SharedModuleProvider : public extensions::ManagementPolicy::Provider { | 135 class SharedModuleProvider : public extensions::ManagementPolicy::Provider { |
| 129 public: | 136 public: |
| 130 SharedModuleProvider() {} | 137 SharedModuleProvider() {} |
| 131 virtual ~SharedModuleProvider() {} | 138 virtual ~SharedModuleProvider() {} |
| 132 | 139 |
| 133 virtual std::string GetDebugPolicyProviderName() const OVERRIDE { | 140 virtual std::string GetDebugPolicyProviderName() const OVERRIDE { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 pref_change_registrar_.Init(profile->GetPrefs()); | 321 pref_change_registrar_.Init(profile->GetPrefs()); |
| 315 base::Closure callback = | 322 base::Closure callback = |
| 316 base::Bind(&ExtensionService::OnExtensionInstallPrefChanged, | 323 base::Bind(&ExtensionService::OnExtensionInstallPrefChanged, |
| 317 base::Unretained(this)); | 324 base::Unretained(this)); |
| 318 pref_change_registrar_.Add(extensions::pref_names::kInstallAllowList, | 325 pref_change_registrar_.Add(extensions::pref_names::kInstallAllowList, |
| 319 callback); | 326 callback); |
| 320 pref_change_registrar_.Add(extensions::pref_names::kInstallDenyList, | 327 pref_change_registrar_.Add(extensions::pref_names::kInstallDenyList, |
| 321 callback); | 328 callback); |
| 322 pref_change_registrar_.Add(extensions::pref_names::kAllowedTypes, callback); | 329 pref_change_registrar_.Add(extensions::pref_names::kAllowedTypes, callback); |
| 323 | 330 |
| 331 #if defined(ENABLE_EXTENSIONS) |
| 324 // Set up the ExtensionUpdater | 332 // Set up the ExtensionUpdater |
| 325 if (autoupdate_enabled) { | 333 if (autoupdate_enabled) { |
| 326 int update_frequency = extensions::kDefaultUpdateFrequencySeconds; | 334 int update_frequency = extensions::kDefaultUpdateFrequencySeconds; |
| 327 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { | 335 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { |
| 328 base::StringToInt(command_line->GetSwitchValueASCII( | 336 base::StringToInt(command_line->GetSwitchValueASCII( |
| 329 switches::kExtensionsUpdateFrequency), | 337 switches::kExtensionsUpdateFrequency), |
| 330 &update_frequency); | 338 &update_frequency); |
| 331 } | 339 } |
| 332 updater_.reset(new extensions::ExtensionUpdater( | 340 updater_.reset(new extensions::ExtensionUpdater( |
| 333 this, | 341 this, |
| 334 extension_prefs, | 342 extension_prefs, |
| 335 profile->GetPrefs(), | 343 profile->GetPrefs(), |
| 336 profile, | 344 profile, |
| 337 update_frequency, | 345 update_frequency, |
| 338 extensions::ExtensionCache::GetInstance())); | 346 extensions::ExtensionCache::GetInstance())); |
| 339 } | 347 } |
| 348 #endif |
| 340 | 349 |
| 341 component_loader_.reset( | 350 component_loader_.reset( |
| 342 new extensions::ComponentLoader(this, | 351 new extensions::ComponentLoader(this, |
| 343 profile->GetPrefs(), | 352 profile->GetPrefs(), |
| 344 g_browser_process->local_state(), | 353 g_browser_process->local_state(), |
| 345 profile)); | 354 profile)); |
| 346 | 355 |
| 347 if (extensions_enabled_) { | 356 if (extensions_enabled_) { |
| 348 extensions::ExternalProviderImpl::CreateExternalProviders( | 357 extensions::ExternalProviderImpl::CreateExternalProviders( |
| 349 this, profile_, &external_extension_providers_); | 358 this, profile_, &external_extension_providers_); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION) | 510 state == extensions::BLACKLISTED_CWS_POLICY_VIOLATION) |
| 502 greylist_.Insert(*it); | 511 greylist_.Insert(*it); |
| 503 } | 512 } |
| 504 } | 513 } |
| 505 | 514 |
| 506 bool ExtensionService::UpdateExtension(const std::string& id, | 515 bool ExtensionService::UpdateExtension(const std::string& id, |
| 507 const base::FilePath& extension_path, | 516 const base::FilePath& extension_path, |
| 508 bool file_ownership_passed, | 517 bool file_ownership_passed, |
| 509 CrxInstaller** out_crx_installer) { | 518 CrxInstaller** out_crx_installer) { |
| 510 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 519 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 520 #if defined(ENABLE_EXTENSIONS) |
| 511 if (browser_terminating_) { | 521 if (browser_terminating_) { |
| 512 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown"; | 522 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown"; |
| 513 // Leak the temp file at extension_path. We don't want to add to the disk | 523 // Leak the temp file at extension_path. We don't want to add to the disk |
| 514 // I/O burden at shutdown, we can't rely on the I/O completing anyway, and | 524 // I/O burden at shutdown, we can't rely on the I/O completing anyway, and |
| 515 // the file is in the OS temp directory which should be cleaned up for us. | 525 // the file is in the OS temp directory which should be cleaned up for us. |
| 516 return false; | 526 return false; |
| 517 } | 527 } |
| 518 | 528 |
| 519 const extensions::PendingExtensionInfo* pending_extension_info = | 529 const extensions::PendingExtensionInfo* pending_extension_info = |
| 520 pending_extension_manager()->GetById(id); | 530 pending_extension_manager()->GetById(id); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 installer->set_creation_flags(creation_flags); | 599 installer->set_creation_flags(creation_flags); |
| 590 | 600 |
| 591 installer->set_delete_source(file_ownership_passed); | 601 installer->set_delete_source(file_ownership_passed); |
| 592 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); | 602 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
| 593 installer->InstallCrx(extension_path); | 603 installer->InstallCrx(extension_path); |
| 594 | 604 |
| 595 if (out_crx_installer) | 605 if (out_crx_installer) |
| 596 *out_crx_installer = installer.get(); | 606 *out_crx_installer = installer.get(); |
| 597 | 607 |
| 598 return true; | 608 return true; |
| 609 #else |
| 610 return false; |
| 611 #endif |
| 599 } | 612 } |
| 600 | 613 |
| 601 void ExtensionService::ReloadExtension( | 614 void ExtensionService::ReloadExtension( |
| 602 // "transient" because the process of reloading may cause the reference | 615 // "transient" because the process of reloading may cause the reference |
| 603 // to become invalid. Instead, use |extension_id|, a copy. | 616 // to become invalid. Instead, use |extension_id|, a copy. |
| 604 const std::string& transient_extension_id) { | 617 const std::string& transient_extension_id) { |
| 605 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 618 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 606 | 619 |
| 607 // If the extension is already reloading, don't reload again. | 620 // If the extension is already reloading, don't reload again. |
| 608 if (extension_prefs_->GetDisableReasons(transient_extension_id) & | 621 if (extension_prefs_->GetDisableReasons(transient_extension_id) & |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1170 | 1183 |
| 1171 for (size_t i = 0; i < to_unload.size(); ++i) | 1184 for (size_t i = 0; i < to_unload.size(); ++i) |
| 1172 UnloadExtension(to_unload[i], UnloadedExtensionInfo::REASON_DISABLE); | 1185 UnloadExtension(to_unload[i], UnloadedExtensionInfo::REASON_DISABLE); |
| 1173 | 1186 |
| 1174 for (std::map<std::string, Extension::DisableReason>::const_iterator i = | 1187 for (std::map<std::string, Extension::DisableReason>::const_iterator i = |
| 1175 to_disable.begin(); i != to_disable.end(); ++i) | 1188 to_disable.begin(); i != to_disable.end(); ++i) |
| 1176 DisableExtension(i->first, i->second); | 1189 DisableExtension(i->first, i->second); |
| 1177 } | 1190 } |
| 1178 | 1191 |
| 1179 void ExtensionService::CheckForUpdatesSoon() { | 1192 void ExtensionService::CheckForUpdatesSoon() { |
| 1193 #if defined(ENABLE_EXTENSIONS) |
| 1180 // This can legitimately happen in unit tests. | 1194 // This can legitimately happen in unit tests. |
| 1181 if (!updater_.get()) | 1195 if (!updater_.get()) |
| 1182 return; | 1196 return; |
| 1183 | 1197 |
| 1184 if (AreAllExternalProvidersReady()) { | 1198 if (AreAllExternalProvidersReady()) { |
| 1185 updater_->CheckSoon(); | 1199 updater_->CheckSoon(); |
| 1186 } else { | 1200 } else { |
| 1187 // Sync can start updating before all the external providers are ready | 1201 // Sync can start updating before all the external providers are ready |
| 1188 // during startup. Start the update as soon as those providers are ready, | 1202 // during startup. Start the update as soon as those providers are ready, |
| 1189 // but not before. | 1203 // but not before. |
| 1190 update_once_all_providers_are_ready_ = true; | 1204 update_once_all_providers_are_ready_ = true; |
| 1191 } | 1205 } |
| 1206 #endif |
| 1192 } | 1207 } |
| 1193 | 1208 |
| 1194 // Some extensions will autoupdate themselves externally from Chrome. These | 1209 // Some extensions will autoupdate themselves externally from Chrome. These |
| 1195 // are typically part of some larger client application package. To support | 1210 // are typically part of some larger client application package. To support |
| 1196 // these, the extension will register its location in the the preferences file | 1211 // these, the extension will register its location in the the preferences file |
| 1197 // (and also, on Windows, in the registry) and this code will periodically | 1212 // (and also, on Windows, in the registry) and this code will periodically |
| 1198 // check that location for a .crx file, which it will then install locally if | 1213 // check that location for a .crx file, which it will then install locally if |
| 1199 // a new version is available. | 1214 // a new version is available. |
| 1200 // Errors are reported through ExtensionErrorReporter. Succcess is not | 1215 // Errors are reported through ExtensionErrorReporter. Succcess is not |
| 1201 // reported. | 1216 // reported. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 for (i = external_extension_providers_.begin(); | 1254 for (i = external_extension_providers_.begin(); |
| 1240 i != external_extension_providers_.end(); ++i) { | 1255 i != external_extension_providers_.end(); ++i) { |
| 1241 if (!i->get()->IsReady()) | 1256 if (!i->get()->IsReady()) |
| 1242 return false; | 1257 return false; |
| 1243 } | 1258 } |
| 1244 return true; | 1259 return true; |
| 1245 } | 1260 } |
| 1246 | 1261 |
| 1247 void ExtensionService::OnAllExternalProvidersReady() { | 1262 void ExtensionService::OnAllExternalProvidersReady() { |
| 1248 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1263 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1264 #if defined(ENABLE_EXTENSIONS) |
| 1249 base::TimeDelta elapsed = base::Time::Now() - profile_->GetStartTime(); | 1265 base::TimeDelta elapsed = base::Time::Now() - profile_->GetStartTime(); |
| 1250 UMA_HISTOGRAM_TIMES("Extension.ExternalProvidersReadyAfter", elapsed); | 1266 UMA_HISTOGRAM_TIMES("Extension.ExternalProvidersReadyAfter", elapsed); |
| 1251 | 1267 |
| 1252 // Install any pending extensions. | 1268 // Install any pending extensions. |
| 1253 if (update_once_all_providers_are_ready_ && updater()) { | 1269 if (update_once_all_providers_are_ready_ && updater()) { |
| 1254 update_once_all_providers_are_ready_ = false; | 1270 update_once_all_providers_are_ready_ = false; |
| 1255 extensions::ExtensionUpdater::CheckParams params; | 1271 extensions::ExtensionUpdater::CheckParams params; |
| 1256 params.callback = external_updates_finished_callback_; | 1272 params.callback = external_updates_finished_callback_; |
| 1257 updater()->CheckNow(params); | 1273 updater()->CheckNow(params); |
| 1258 } | 1274 } |
| 1259 | 1275 |
| 1260 // Uninstall all the unclaimed extensions. | 1276 // Uninstall all the unclaimed extensions. |
| 1261 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> extensions_info( | 1277 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> extensions_info( |
| 1262 extension_prefs_->GetInstalledExtensionsInfo()); | 1278 extension_prefs_->GetInstalledExtensionsInfo()); |
| 1263 for (size_t i = 0; i < extensions_info->size(); ++i) { | 1279 for (size_t i = 0; i < extensions_info->size(); ++i) { |
| 1264 ExtensionInfo* info = extensions_info->at(i).get(); | 1280 ExtensionInfo* info = extensions_info->at(i).get(); |
| 1265 if (Manifest::IsExternalLocation(info->extension_location)) | 1281 if (Manifest::IsExternalLocation(info->extension_location)) |
| 1266 CheckExternalUninstall(info->extension_id); | 1282 CheckExternalUninstall(info->extension_id); |
| 1267 } | 1283 } |
| 1268 | 1284 |
| 1269 error_controller_->ShowErrorIfNeeded(); | 1285 error_controller_->ShowErrorIfNeeded(); |
| 1270 | 1286 |
| 1271 UpdateExternalExtensionAlert(); | 1287 UpdateExternalExtensionAlert(); |
| 1288 #endif |
| 1272 } | 1289 } |
| 1273 | 1290 |
| 1274 void ExtensionService::AcknowledgeExternalExtension(const std::string& id) { | 1291 void ExtensionService::AcknowledgeExternalExtension(const std::string& id) { |
| 1275 extension_prefs_->AcknowledgeExternalExtension(id); | 1292 extension_prefs_->AcknowledgeExternalExtension(id); |
| 1276 UpdateExternalExtensionAlert(); | 1293 UpdateExternalExtensionAlert(); |
| 1277 } | 1294 } |
| 1278 | 1295 |
| 1279 bool ExtensionService::IsUnacknowledgedExternalExtension( | 1296 bool ExtensionService::IsUnacknowledgedExternalExtension( |
| 1280 const Extension* extension) { | 1297 const Extension* extension) { |
| 1281 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) | 1298 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) |
| 1282 return false; | 1299 return false; |
| 1283 | 1300 |
| 1284 return (Manifest::IsExternalLocation(extension->location()) && | 1301 return (Manifest::IsExternalLocation(extension->location()) && |
| 1285 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id()) && | 1302 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id()) && |
| 1286 !(extension_prefs_->GetDisableReasons(extension->id()) & | 1303 !(extension_prefs_->GetDisableReasons(extension->id()) & |
| 1287 Extension::DISABLE_SIDELOAD_WIPEOUT)); | 1304 Extension::DISABLE_SIDELOAD_WIPEOUT)); |
| 1288 } | 1305 } |
| 1289 | 1306 |
| 1290 void ExtensionService::UpdateExternalExtensionAlert() { | 1307 void ExtensionService::UpdateExternalExtensionAlert() { |
| 1308 #if defined(ENABLE_EXTENSIONS) |
| 1291 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) | 1309 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) |
| 1292 return; | 1310 return; |
| 1293 | 1311 |
| 1294 const Extension* extension = NULL; | 1312 const Extension* extension = NULL; |
| 1295 const ExtensionSet& disabled_extensions = registry_->disabled_extensions(); | 1313 const ExtensionSet& disabled_extensions = registry_->disabled_extensions(); |
| 1296 for (ExtensionSet::const_iterator iter = disabled_extensions.begin(); | 1314 for (ExtensionSet::const_iterator iter = disabled_extensions.begin(); |
| 1297 iter != disabled_extensions.end(); ++iter) { | 1315 iter != disabled_extensions.end(); ++iter) { |
| 1298 const Extension* e = iter->get(); | 1316 const Extension* e = iter->get(); |
| 1299 if (IsUnacknowledgedExternalExtension(e)) { | 1317 if (IsUnacknowledgedExternalExtension(e)) { |
| 1300 extension = e; | 1318 extension = e; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1328 } | 1346 } |
| 1329 if (is_first_run_) | 1347 if (is_first_run_) |
| 1330 extension_prefs_->SetExternalInstallFirstRun(extension->id()); | 1348 extension_prefs_->SetExternalInstallFirstRun(extension->id()); |
| 1331 // first_run is true if the extension was installed during a first run | 1349 // first_run is true if the extension was installed during a first run |
| 1332 // (even if it's post-first run now). | 1350 // (even if it's post-first run now). |
| 1333 bool first_run = extension_prefs_->IsExternalInstallFirstRun( | 1351 bool first_run = extension_prefs_->IsExternalInstallFirstRun( |
| 1334 extension->id()); | 1352 extension->id()); |
| 1335 external_install_manager_->AddExternalInstallError(extension, first_run); | 1353 external_install_manager_->AddExternalInstallError(extension, first_run); |
| 1336 } | 1354 } |
| 1337 } | 1355 } |
| 1356 #endif // defined(ENABLE_EXTENSIONS) |
| 1338 } | 1357 } |
| 1339 | 1358 |
| 1340 void ExtensionService::UnloadExtension( | 1359 void ExtensionService::UnloadExtension( |
| 1341 const std::string& extension_id, | 1360 const std::string& extension_id, |
| 1342 UnloadedExtensionInfo::Reason reason) { | 1361 UnloadedExtensionInfo::Reason reason) { |
| 1343 // Make sure the extension gets deleted after we return from this function. | 1362 // Make sure the extension gets deleted after we return from this function. |
| 1344 int include_mask = | 1363 int include_mask = |
| 1345 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED; | 1364 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED; |
| 1346 scoped_refptr<const Extension> extension( | 1365 scoped_refptr<const Extension> extension( |
| 1347 registry_->GetExtensionById(extension_id, include_mask)); | 1366 registry_->GetExtensionById(extension_id, include_mask)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 | 1431 |
| 1413 void ExtensionService::SetReadyAndNotifyListeners() { | 1432 void ExtensionService::SetReadyAndNotifyListeners() { |
| 1414 ready_->Signal(); | 1433 ready_->Signal(); |
| 1415 content::NotificationService::current()->Notify( | 1434 content::NotificationService::current()->Notify( |
| 1416 chrome::NOTIFICATION_EXTENSIONS_READY, | 1435 chrome::NOTIFICATION_EXTENSIONS_READY, |
| 1417 content::Source<Profile>(profile_), | 1436 content::Source<Profile>(profile_), |
| 1418 content::NotificationService::NoDetails()); | 1437 content::NotificationService::NoDetails()); |
| 1419 } | 1438 } |
| 1420 | 1439 |
| 1421 void ExtensionService::OnLoadedInstalledExtensions() { | 1440 void ExtensionService::OnLoadedInstalledExtensions() { |
| 1441 #if defined(ENABLE_EXTENSIONS) |
| 1422 if (updater_) | 1442 if (updater_) |
| 1423 updater_->Start(); | 1443 updater_->Start(); |
| 1424 | 1444 |
| 1425 OnBlacklistUpdated(); | 1445 OnBlacklistUpdated(); |
| 1446 #endif |
| 1426 } | 1447 } |
| 1427 | 1448 |
| 1428 void ExtensionService::AddExtension(const Extension* extension) { | 1449 void ExtensionService::AddExtension(const Extension* extension) { |
| 1429 // TODO(jstritar): We may be able to get rid of this branch by overriding the | 1450 // TODO(jstritar): We may be able to get rid of this branch by overriding the |
| 1430 // default extension state to DISABLED when the --disable-extensions flag | 1451 // default extension state to DISABLED when the --disable-extensions flag |
| 1431 // is set (http://crbug.com/29067). | 1452 // is set (http://crbug.com/29067). |
| 1432 if (!extensions_enabled() && | 1453 if (!extensions_enabled() && |
| 1433 !extension->is_theme() && | 1454 !extension->is_theme() && |
| 1434 extension->location() != Manifest::COMPONENT && | 1455 extension->location() != Manifest::COMPONENT && |
| 1435 !Manifest::IsExternalLocation(extension->location())) { | 1456 !Manifest::IsExternalLocation(extension->location())) { |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 } | 2046 } |
| 2026 | 2047 |
| 2027 bool ExtensionService::OnExternalExtensionFileFound( | 2048 bool ExtensionService::OnExternalExtensionFileFound( |
| 2028 const std::string& id, | 2049 const std::string& id, |
| 2029 const Version* version, | 2050 const Version* version, |
| 2030 const base::FilePath& path, | 2051 const base::FilePath& path, |
| 2031 Manifest::Location location, | 2052 Manifest::Location location, |
| 2032 int creation_flags, | 2053 int creation_flags, |
| 2033 bool mark_acknowledged) { | 2054 bool mark_acknowledged) { |
| 2034 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2055 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2056 #if defined(ENABLE_EXTENSIONS) |
| 2035 CHECK(Extension::IdIsValid(id)); | 2057 CHECK(Extension::IdIsValid(id)); |
| 2036 if (extension_prefs_->IsExternalExtensionUninstalled(id)) | 2058 if (extension_prefs_->IsExternalExtensionUninstalled(id)) |
| 2037 return false; | 2059 return false; |
| 2038 | 2060 |
| 2039 // Before even bothering to unpack, check and see if we already have this | 2061 // Before even bothering to unpack, check and see if we already have this |
| 2040 // version. This is important because these extensions are going to get | 2062 // version. This is important because these extensions are going to get |
| 2041 // installed on every startup. | 2063 // installed on every startup. |
| 2042 const Extension* existing = GetExtensionById(id, true); | 2064 const Extension* existing = GetExtensionById(id, true); |
| 2043 | 2065 |
| 2044 if (existing) { | 2066 if (existing) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 installer->InstallCrx(path); | 2110 installer->InstallCrx(path); |
| 2089 #endif | 2111 #endif |
| 2090 | 2112 |
| 2091 // Depending on the source, a new external extension might not need a user | 2113 // Depending on the source, a new external extension might not need a user |
| 2092 // notification on installation. For such extensions, mark them acknowledged | 2114 // notification on installation. For such extensions, mark them acknowledged |
| 2093 // now to suppress the notification. | 2115 // now to suppress the notification. |
| 2094 if (mark_acknowledged) | 2116 if (mark_acknowledged) |
| 2095 AcknowledgeExternalExtension(id); | 2117 AcknowledgeExternalExtension(id); |
| 2096 | 2118 |
| 2097 return true; | 2119 return true; |
| 2120 #else |
| 2121 return false; |
| 2122 #endif // defined(ENABLE_EXTENSIONS) |
| 2098 } | 2123 } |
| 2099 | 2124 |
| 2100 void ExtensionService::DidCreateRenderViewForBackgroundPage( | 2125 void ExtensionService::DidCreateRenderViewForBackgroundPage( |
| 2101 extensions::ExtensionHost* host) { | 2126 extensions::ExtensionHost* host) { |
| 2102 OrphanedDevTools::iterator iter = | 2127 OrphanedDevTools::iterator iter = |
| 2103 orphaned_dev_tools_.find(host->extension_id()); | 2128 orphaned_dev_tools_.find(host->extension_id()); |
| 2104 if (iter == orphaned_dev_tools_.end()) | 2129 if (iter == orphaned_dev_tools_.end()) |
| 2105 return; | 2130 return; |
| 2106 | 2131 |
| 2107 iter->second->ConnectRenderViewHost(host->render_view_host()); | 2132 iter->second->ConnectRenderViewHost(host->render_view_host()); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2456 } | 2481 } |
| 2457 | 2482 |
| 2458 void ExtensionService::OnProfileDestructionStarted() { | 2483 void ExtensionService::OnProfileDestructionStarted() { |
| 2459 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2484 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2460 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2485 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2461 it != ids_to_unload.end(); | 2486 it != ids_to_unload.end(); |
| 2462 ++it) { | 2487 ++it) { |
| 2463 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2488 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2464 } | 2489 } |
| 2465 } | 2490 } |
| OLD | NEW |