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