| 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 10 matching lines...) Expand all Loading... |
| 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" | 23 #include "chrome/browser/extensions/crx_installer.h" |
| 24 #include "chrome/browser/extensions/data_deleter.h" | 24 #include "chrome/browser/extensions/data_deleter.h" |
| 25 #include "chrome/browser/extensions/extension_disabled_ui.h" | 25 #include "chrome/browser/extensions/extension_disabled_ui.h" |
| 26 #include "chrome/browser/extensions/extension_error_controller.h" | 26 #include "chrome/browser/extensions/extension_error_controller.h" |
| 27 #include "chrome/browser/extensions/extension_install_ui.h" | 27 #include "chrome/browser/extensions/extension_install_ui.h" |
| 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 29 #include "chrome/browser/extensions/extension_sync_service.h" | 29 #include "chrome/browser/extensions/extension_sync_service.h" |
| 30 #include "chrome/browser/extensions/extension_util.h" | 30 #include "chrome/browser/extensions/extension_util.h" |
| 31 #include "chrome/browser/extensions/external_install_ui.h" | 31 #include "chrome/browser/extensions/external_install_manager.h" |
| 32 #include "chrome/browser/extensions/external_provider_impl.h" | 32 #include "chrome/browser/extensions/external_provider_impl.h" |
| 33 #include "chrome/browser/extensions/install_verifier.h" | 33 #include "chrome/browser/extensions/install_verifier.h" |
| 34 #include "chrome/browser/extensions/installed_loader.h" | 34 #include "chrome/browser/extensions/installed_loader.h" |
| 35 #include "chrome/browser/extensions/pending_extension_manager.h" | 35 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 36 #include "chrome/browser/extensions/permissions_updater.h" | 36 #include "chrome/browser/extensions/permissions_updater.h" |
| 37 #include "chrome/browser/extensions/shared_module_service.h" | 37 #include "chrome/browser/extensions/shared_module_service.h" |
| 38 #include "chrome/browser/extensions/unpacked_installer.h" | 38 #include "chrome/browser/extensions/unpacked_installer.h" |
| 39 #include "chrome/browser/extensions/updater/extension_cache.h" | 39 #include "chrome/browser/extensions/updater/extension_cache.h" |
| 40 #include "chrome/browser/extensions/updater/extension_updater.h" | 40 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 41 #include "chrome/browser/profiles/profile.h" | 41 #include "chrome/browser/profiles/profile.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 pending_extension_manager_(profile), | 278 pending_extension_manager_(profile), |
| 279 install_directory_(install_directory), | 279 install_directory_(install_directory), |
| 280 extensions_enabled_(extensions_enabled), | 280 extensions_enabled_(extensions_enabled), |
| 281 show_extensions_prompts_(true), | 281 show_extensions_prompts_(true), |
| 282 install_updates_when_idle_(true), | 282 install_updates_when_idle_(true), |
| 283 ready_(ready), | 283 ready_(ready), |
| 284 update_once_all_providers_are_ready_(false), | 284 update_once_all_providers_are_ready_(false), |
| 285 browser_terminating_(false), | 285 browser_terminating_(false), |
| 286 installs_delayed_for_gc_(false), | 286 installs_delayed_for_gc_(false), |
| 287 is_first_run_(false), | 287 is_first_run_(false), |
| 288 external_install_manager_( |
| 289 new extensions::ExternalInstallManager(profile_)), |
| 288 shared_module_service_(new extensions::SharedModuleService(profile_)) { | 290 shared_module_service_(new extensions::SharedModuleService(profile_)) { |
| 289 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 291 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 290 | 292 |
| 291 // Figure out if extension installation should be enabled. | 293 // Figure out if extension installation should be enabled. |
| 292 if (extensions::ExtensionsBrowserClient::Get()->AreExtensionsDisabled( | 294 if (extensions::ExtensionsBrowserClient::Get()->AreExtensionsDisabled( |
| 293 *command_line, profile)) | 295 *command_line, profile)) |
| 294 extensions_enabled_ = false; | 296 extensions_enabled_ = false; |
| 295 | 297 |
| 296 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 298 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| 297 content::NotificationService::AllBrowserContextsAndSources()); | 299 content::NotificationService::AllBrowserContextsAndSources()); |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 for (ExtensionSet::const_iterator iter = disabled_extensions.begin(); | 1332 for (ExtensionSet::const_iterator iter = disabled_extensions.begin(); |
| 1331 iter != disabled_extensions.end(); ++iter) { | 1333 iter != disabled_extensions.end(); ++iter) { |
| 1332 const Extension* e = iter->get(); | 1334 const Extension* e = iter->get(); |
| 1333 if (IsUnacknowledgedExternalExtension(e)) { | 1335 if (IsUnacknowledgedExternalExtension(e)) { |
| 1334 extension = e; | 1336 extension = e; |
| 1335 break; | 1337 break; |
| 1336 } | 1338 } |
| 1337 } | 1339 } |
| 1338 | 1340 |
| 1339 if (extension) { | 1341 if (extension) { |
| 1340 if (!extensions::HasExternalInstallError(this)) { | 1342 if (!external_install_manager_->HasExternalInstallError()) { |
| 1341 if (extension_prefs_->IncrementAcknowledgePromptCount(extension->id()) > | 1343 if (extension_prefs_->IncrementAcknowledgePromptCount(extension->id()) > |
| 1342 kMaxExtensionAcknowledgePromptCount) { | 1344 kMaxExtensionAcknowledgePromptCount) { |
| 1343 // Stop prompting for this extension, and check if there's another | 1345 // Stop prompting for this extension, and check if there's another |
| 1344 // one that needs prompting. | 1346 // one that needs prompting. |
| 1345 extension_prefs_->AcknowledgeExternalExtension(extension->id()); | 1347 extension_prefs_->AcknowledgeExternalExtension(extension->id()); |
| 1346 UpdateExternalExtensionAlert(); | 1348 UpdateExternalExtensionAlert(); |
| 1347 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", | 1349 UMA_HISTOGRAM_ENUMERATION("Extensions.ExternalExtensionEvent", |
| 1348 EXTERNAL_EXTENSION_IGNORED, | 1350 EXTERNAL_EXTENSION_IGNORED, |
| 1349 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); | 1351 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); |
| 1350 if (extensions::ManifestURL::UpdatesFromGallery(extension)) { | 1352 if (extensions::ManifestURL::UpdatesFromGallery(extension)) { |
| 1351 UMA_HISTOGRAM_ENUMERATION( | 1353 UMA_HISTOGRAM_ENUMERATION( |
| 1352 "Extensions.ExternalExtensionEventWebstore", | 1354 "Extensions.ExternalExtensionEventWebstore", |
| 1353 EXTERNAL_EXTENSION_IGNORED, | 1355 EXTERNAL_EXTENSION_IGNORED, |
| 1354 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); | 1356 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); |
| 1355 } else { | 1357 } else { |
| 1356 UMA_HISTOGRAM_ENUMERATION( | 1358 UMA_HISTOGRAM_ENUMERATION( |
| 1357 "Extensions.ExternalExtensionEventNonWebstore", | 1359 "Extensions.ExternalExtensionEventNonWebstore", |
| 1358 EXTERNAL_EXTENSION_IGNORED, | 1360 EXTERNAL_EXTENSION_IGNORED, |
| 1359 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); | 1361 EXTERNAL_EXTENSION_BUCKET_BOUNDARY); |
| 1360 } | 1362 } |
| 1361 return; | 1363 return; |
| 1362 } | 1364 } |
| 1363 if (is_first_run_) | 1365 if (is_first_run_) |
| 1364 extension_prefs_->SetExternalInstallFirstRun(extension->id()); | 1366 extension_prefs_->SetExternalInstallFirstRun(extension->id()); |
| 1365 // first_run is true if the extension was installed during a first run | 1367 // first_run is true if the extension was installed during a first run |
| 1366 // (even if it's post-first run now). | 1368 // (even if it's post-first run now). |
| 1367 bool first_run = extension_prefs_->IsExternalInstallFirstRun( | 1369 bool first_run = extension_prefs_->IsExternalInstallFirstRun( |
| 1368 extension->id()); | 1370 extension->id()); |
| 1369 extensions::AddExternalInstallError(this, extension, first_run); | 1371 external_install_manager_->AddExternalInstallError(extension, first_run); |
| 1370 } | 1372 } |
| 1371 } else { | |
| 1372 extensions::RemoveExternalInstallError(this); | |
| 1373 } | 1373 } |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 void ExtensionService::UnloadExtension( | 1376 void ExtensionService::UnloadExtension( |
| 1377 const std::string& extension_id, | 1377 const std::string& extension_id, |
| 1378 UnloadedExtensionInfo::Reason reason) { | 1378 UnloadedExtensionInfo::Reason reason) { |
| 1379 // Make sure the extension gets deleted after we return from this function. | 1379 // Make sure the extension gets deleted after we return from this function. |
| 1380 int include_mask = | 1380 int include_mask = |
| 1381 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED; | 1381 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::TERMINATED; |
| 1382 scoped_refptr<const Extension> extension( | 1382 scoped_refptr<const Extension> extension( |
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 } | 2543 } |
| 2544 | 2544 |
| 2545 void ExtensionService::OnProfileDestructionStarted() { | 2545 void ExtensionService::OnProfileDestructionStarted() { |
| 2546 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2546 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2547 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2547 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2548 it != ids_to_unload.end(); | 2548 it != ids_to_unload.end(); |
| 2549 ++it) { | 2549 ++it) { |
| 2550 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2550 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2551 } | 2551 } |
| 2552 } | 2552 } |
| OLD | NEW |