Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 #include "base/values.h" | 28 #include "base/values.h" |
| 29 #include "base/version.h" | 29 #include "base/version.h" |
| 30 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
| 31 #include "chrome/browser/devtools/devtools_window.h" | 31 #include "chrome/browser/devtools/devtools_window.h" |
| 32 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" | 32 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
| 33 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" | 33 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" |
| 34 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 34 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 35 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 35 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
| 36 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 36 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 37 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 37 #include "chrome/browser/extensions/api/storage/settings_frontend.h" |
| 38 #include "chrome/browser/extensions/app_notification_manager.h" | |
| 39 #include "chrome/browser/extensions/app_sync_data.h" | 38 #include "chrome/browser/extensions/app_sync_data.h" |
| 40 #include "chrome/browser/extensions/browser_event_router.h" | 39 #include "chrome/browser/extensions/browser_event_router.h" |
| 41 #include "chrome/browser/extensions/component_loader.h" | 40 #include "chrome/browser/extensions/component_loader.h" |
| 42 #include "chrome/browser/extensions/crx_installer.h" | 41 #include "chrome/browser/extensions/crx_installer.h" |
| 43 #include "chrome/browser/extensions/data_deleter.h" | 42 #include "chrome/browser/extensions/data_deleter.h" |
| 44 #include "chrome/browser/extensions/extension_disabled_ui.h" | 43 #include "chrome/browser/extensions/extension_disabled_ui.h" |
| 45 #include "chrome/browser/extensions/extension_error_reporter.h" | 44 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 46 #include "chrome/browser/extensions/extension_error_ui.h" | 45 #include "chrome/browser/extensions/extension_error_ui.h" |
| 47 #include "chrome/browser/extensions/extension_host.h" | 46 #include "chrome/browser/extensions/extension_host.h" |
| 48 #include "chrome/browser/extensions/extension_install_ui.h" | 47 #include "chrome/browser/extensions/extension_install_ui.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 blacklist_(blacklist), | 340 blacklist_(blacklist), |
| 342 settings_frontend_(extensions::SettingsFrontend::Create(profile)), | 341 settings_frontend_(extensions::SettingsFrontend::Create(profile)), |
| 343 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 342 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 344 install_directory_(install_directory), | 343 install_directory_(install_directory), |
| 345 extensions_enabled_(extensions_enabled), | 344 extensions_enabled_(extensions_enabled), |
| 346 show_extensions_prompts_(true), | 345 show_extensions_prompts_(true), |
| 347 install_updates_when_idle_(true), | 346 install_updates_when_idle_(true), |
| 348 ready_(false), | 347 ready_(false), |
| 349 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 348 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 350 menu_manager_(profile), | 349 menu_manager_(profile), |
| 351 app_notification_manager_( | |
| 352 new extensions::AppNotificationManager(profile)), | |
| 353 event_routers_initialized_(false), | 350 event_routers_initialized_(false), |
| 354 update_once_all_providers_are_ready_(false), | 351 update_once_all_providers_are_ready_(false), |
| 355 browser_terminating_(false), | 352 browser_terminating_(false), |
| 356 installs_delayed_(false), | 353 installs_delayed_(false), |
| 357 wipeout_is_active_(false), | 354 wipeout_is_active_(false), |
| 358 wipeout_count_(0u), | 355 wipeout_count_(0u), |
| 359 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 356 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 360 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 357 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 361 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 358 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 362 | 359 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 profile, | 397 profile, |
| 401 blacklist, | 398 blacklist, |
| 402 update_frequency)); | 399 update_frequency)); |
| 403 } | 400 } |
| 404 | 401 |
| 405 component_loader_.reset( | 402 component_loader_.reset( |
| 406 new extensions::ComponentLoader(this, | 403 new extensions::ComponentLoader(this, |
| 407 profile->GetPrefs(), | 404 profile->GetPrefs(), |
| 408 g_browser_process->local_state())); | 405 g_browser_process->local_state())); |
| 409 | 406 |
| 410 app_notification_manager_->Init(); | |
| 411 | |
| 412 if (extensions_enabled_) { | 407 if (extensions_enabled_) { |
| 413 CHECK(!ProfileManager::IsImportProcess(*command_line)); | 408 CHECK(!ProfileManager::IsImportProcess(*command_line)); |
| 414 extensions::ExternalProviderImpl::CreateExternalProviders( | 409 extensions::ExternalProviderImpl::CreateExternalProviders( |
| 415 this, profile_, &external_extension_providers_); | 410 this, profile_, &external_extension_providers_); |
| 416 } | 411 } |
| 417 | 412 |
| 418 // Set this as the ExtensionService for extension sorting to ensure it | 413 // Set this as the ExtensionService for extension sorting to ensure it |
| 419 // cause syncs if required. | 414 // cause syncs if required. |
| 420 extension_prefs_->extension_sorting()->SetExtensionService(this); | 415 extension_prefs_->extension_sorting()->SetExtensionService(this); |
| 421 | 416 |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1384 IsExtensionEnabled(extension.id()), | 1379 IsExtensionEnabled(extension.id()), |
| 1385 IsIncognitoEnabled(extension.id())); | 1380 IsIncognitoEnabled(extension.id())); |
| 1386 } | 1381 } |
| 1387 | 1382 |
| 1388 extensions::AppSyncData ExtensionService::GetAppSyncData( | 1383 extensions::AppSyncData ExtensionService::GetAppSyncData( |
| 1389 const Extension& extension) const { | 1384 const Extension& extension) const { |
| 1390 return extensions::AppSyncData( | 1385 return extensions::AppSyncData( |
| 1391 extension, | 1386 extension, |
| 1392 IsExtensionEnabled(extension.id()), | 1387 IsExtensionEnabled(extension.id()), |
| 1393 IsIncognitoEnabled(extension.id()), | 1388 IsIncognitoEnabled(extension.id()), |
| 1394 extension_prefs_->GetAppNotificationClientId(extension.id()), | |
| 1395 extension_prefs_->IsAppNotificationDisabled(extension.id()), | |
| 1396 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal( | 1389 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal( |
| 1397 extension.id()), | 1390 extension.id()), |
| 1398 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id())); | 1391 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id())); |
| 1399 } | 1392 } |
| 1400 | 1393 |
| 1401 std::vector<extensions::ExtensionSyncData> | 1394 std::vector<extensions::ExtensionSyncData> |
| 1402 ExtensionService::GetExtensionSyncDataList() const { | 1395 ExtensionService::GetExtensionSyncDataList() const { |
| 1403 std::vector<extensions::ExtensionSyncData> extension_sync_list; | 1396 std::vector<extensions::ExtensionSyncData> extension_sync_list; |
| 1404 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_, | 1397 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_, |
| 1405 &extension_sync_list); | 1398 &extension_sync_list); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1444 CheckForUpdatesSoon(); | 1437 CheckForUpdatesSoon(); |
| 1445 return false; | 1438 return false; |
| 1446 } | 1439 } |
| 1447 | 1440 |
| 1448 return true; | 1441 return true; |
| 1449 } | 1442 } |
| 1450 | 1443 |
| 1451 bool ExtensionService::ProcessAppSyncData( | 1444 bool ExtensionService::ProcessAppSyncData( |
| 1452 const extensions::AppSyncData& app_sync_data) { | 1445 const extensions::AppSyncData& app_sync_data) { |
| 1453 const std::string& id = app_sync_data.id(); | 1446 const std::string& id = app_sync_data.id(); |
| 1454 const Extension* extension = GetInstalledExtension(id); | |
| 1455 bool extension_installed = (extension != NULL); | |
| 1456 | 1447 |
| 1457 if (app_sync_data.app_launch_ordinal().IsValid() && | 1448 if (app_sync_data.app_launch_ordinal().IsValid() && |
| 1458 app_sync_data.page_ordinal().IsValid()) { | 1449 app_sync_data.page_ordinal().IsValid()) { |
| 1459 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal( | 1450 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal( |
| 1460 id, | 1451 id, |
| 1461 app_sync_data.app_launch_ordinal()); | 1452 app_sync_data.app_launch_ordinal()); |
| 1462 extension_prefs_->extension_sorting()->SetPageOrdinal( | 1453 extension_prefs_->extension_sorting()->SetPageOrdinal( |
| 1463 id, | 1454 id, |
| 1464 app_sync_data.page_ordinal()); | 1455 app_sync_data.page_ordinal()); |
| 1465 } | 1456 } |
| 1466 | 1457 |
| 1467 if (extension_installed) { | |
| 1468 if (app_sync_data.notifications_disabled() != | |
| 1469 extension_prefs_->IsAppNotificationDisabled(id)) { | |
| 1470 extension_prefs_->SetAppNotificationDisabled( | |
| 1471 id, app_sync_data.notifications_disabled()); | |
| 1472 } | |
| 1473 } | |
| 1474 | |
| 1475 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), | 1458 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), |
| 1476 syncer::APPS)) { | 1459 syncer::APPS)) { |
| 1477 app_sync_bundle_.AddPendingApp(id, app_sync_data); | 1460 app_sync_bundle_.AddPendingApp(id, app_sync_data); |
| 1478 CheckForUpdatesSoon(); | 1461 CheckForUpdatesSoon(); |
| 1479 return false; | 1462 return false; |
| 1480 } | 1463 } |
| 1481 | 1464 |
| 1482 return true; | 1465 return true; |
| 1483 } | 1466 } |
| 1484 | 1467 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1625 std::string id = extension_id; | 1608 std::string id = extension_id; |
| 1626 if (extension_is_enabled) | 1609 if (extension_is_enabled) |
| 1627 ReloadExtension(id); | 1610 ReloadExtension(id); |
| 1628 | 1611 |
| 1629 // Reloading the extension invalidates the |extension| pointer. | 1612 // Reloading the extension invalidates the |extension| pointer. |
| 1630 extension = GetInstalledExtension(id); | 1613 extension = GetInstalledExtension(id); |
| 1631 if (extension) | 1614 if (extension) |
| 1632 SyncExtensionChangeIfNeeded(*extension); | 1615 SyncExtensionChangeIfNeeded(*extension); |
| 1633 } | 1616 } |
| 1634 | 1617 |
| 1635 void ExtensionService::SetAppNotificationSetupDone( | |
| 1636 const std::string& extension_id, | |
| 1637 const std::string& oauth_client_id) { | |
| 1638 const Extension* extension = GetInstalledExtension(extension_id); | |
| 1639 // This method is called when the user sets up app notifications. | |
| 1640 // So it is not expected to be called until the extension is installed. | |
| 1641 if (!extension) { | |
| 1642 NOTREACHED(); | |
| 1643 return; | |
| 1644 } | |
| 1645 extension_prefs_->SetAppNotificationClientId(extension_id, oauth_client_id); | |
| 1646 SyncExtensionChangeIfNeeded(*extension); | |
| 1647 } | |
| 1648 | |
| 1649 void ExtensionService::SetAppNotificationDisabled( | |
| 1650 const std::string& extension_id, | |
| 1651 bool value) { | |
| 1652 const Extension* extension = GetInstalledExtension(extension_id); | |
| 1653 // This method is called when the user enables/disables app notifications. | |
| 1654 // So it is not expected to be called until the extension is installed. | |
| 1655 if (!extension) { | |
| 1656 NOTREACHED(); | |
| 1657 return; | |
| 1658 } | |
| 1659 if (value) | |
| 1660 UMA_HISTOGRAM_COUNTS("Apps.SetAppNotificationsDisabled", 1); | |
| 1661 else | |
| 1662 UMA_HISTOGRAM_COUNTS("Apps.SetAppNotificationsEnabled", 1); | |
|
not at google - send to devlin
2013/03/08 23:44:10
need to remember to remove this UMA.
| |
| 1663 extension_prefs_->SetAppNotificationDisabled(extension_id, value); | |
| 1664 SyncExtensionChangeIfNeeded(*extension); | |
| 1665 } | |
| 1666 | |
| 1667 bool ExtensionService::CanCrossIncognito(const Extension* extension) const { | 1618 bool ExtensionService::CanCrossIncognito(const Extension* extension) const { |
| 1668 // We allow the extension to see events and data from another profile iff it | 1619 // We allow the extension to see events and data from another profile iff it |
| 1669 // uses "spanning" behavior and it has incognito access. "split" mode | 1620 // uses "spanning" behavior and it has incognito access. "split" mode |
| 1670 // extensions only see events for a matching profile. | 1621 // extensions only see events for a matching profile. |
| 1671 CHECK(extension); | 1622 CHECK(extension); |
| 1672 return IsIncognitoEnabled(extension->id()) && | 1623 return IsIncognitoEnabled(extension->id()) && |
| 1673 !extension->incognito_split_mode(); | 1624 !extension->incognito_split_mode(); |
| 1674 } | 1625 } |
| 1675 | 1626 |
| 1676 bool ExtensionService::CanLoadInIncognito(const Extension* extension) const { | 1627 bool ExtensionService::CanLoadInIncognito(const Extension* extension) const { |
| (...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3128 if (!extension) | 3079 if (!extension) |
| 3129 continue; | 3080 continue; |
| 3130 blacklisted_extensions_.Insert(extension); | 3081 blacklisted_extensions_.Insert(extension); |
| 3131 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); | 3082 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); |
| 3132 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", | 3083 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", |
| 3133 extension->location(), Manifest::NUM_LOCATIONS); | 3084 extension->location(), Manifest::NUM_LOCATIONS); |
| 3134 } | 3085 } |
| 3135 | 3086 |
| 3136 IdentifyAlertableExtensions(); | 3087 IdentifyAlertableExtensions(); |
| 3137 } | 3088 } |
| OLD | NEW |