Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 12680004: Remove chrome/ code to handle App Notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflicts. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/tab_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 blacklist_(blacklist), 341 blacklist_(blacklist),
343 settings_frontend_(extensions::SettingsFrontend::Create(profile)), 342 settings_frontend_(extensions::SettingsFrontend::Create(profile)),
344 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)), 343 pending_extension_manager_(*ALLOW_THIS_IN_INITIALIZER_LIST(this)),
345 install_directory_(install_directory), 344 install_directory_(install_directory),
346 extensions_enabled_(extensions_enabled), 345 extensions_enabled_(extensions_enabled),
347 show_extensions_prompts_(true), 346 show_extensions_prompts_(true),
348 install_updates_when_idle_(true), 347 install_updates_when_idle_(true),
349 ready_(false), 348 ready_(false),
350 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 349 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
351 menu_manager_(profile), 350 menu_manager_(profile),
352 app_notification_manager_(
353 new extensions::AppNotificationManager(profile)),
354 event_routers_initialized_(false), 351 event_routers_initialized_(false),
355 update_once_all_providers_are_ready_(false), 352 update_once_all_providers_are_ready_(false),
356 browser_terminating_(false), 353 browser_terminating_(false),
357 installs_delayed_(false), 354 installs_delayed_(false),
358 wipeout_is_active_(false), 355 wipeout_is_active_(false),
359 wipeout_count_(0u), 356 wipeout_count_(0u),
360 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 357 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
361 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 358 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
362 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 359 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
363 360
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 profile, 398 profile,
402 blacklist, 399 blacklist,
403 update_frequency)); 400 update_frequency));
404 } 401 }
405 402
406 component_loader_.reset( 403 component_loader_.reset(
407 new extensions::ComponentLoader(this, 404 new extensions::ComponentLoader(this,
408 profile->GetPrefs(), 405 profile->GetPrefs(),
409 g_browser_process->local_state())); 406 g_browser_process->local_state()));
410 407
411 app_notification_manager_->Init();
412
413 if (extensions_enabled_) { 408 if (extensions_enabled_) {
414 CHECK(!ProfileManager::IsImportProcess(*command_line)); 409 CHECK(!ProfileManager::IsImportProcess(*command_line));
415 extensions::ExternalProviderImpl::CreateExternalProviders( 410 extensions::ExternalProviderImpl::CreateExternalProviders(
416 this, profile_, &external_extension_providers_); 411 this, profile_, &external_extension_providers_);
417 } 412 }
418 413
419 // Set this as the ExtensionService for extension sorting to ensure it 414 // Set this as the ExtensionService for extension sorting to ensure it
420 // cause syncs if required. 415 // cause syncs if required.
421 extension_prefs_->extension_sorting()->SetExtensionService(this); 416 extension_prefs_->extension_sorting()->SetExtensionService(this);
422 417
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 IsExtensionEnabled(extension.id()), 1390 IsExtensionEnabled(extension.id()),
1396 IsIncognitoEnabled(extension.id())); 1391 IsIncognitoEnabled(extension.id()));
1397 } 1392 }
1398 1393
1399 extensions::AppSyncData ExtensionService::GetAppSyncData( 1394 extensions::AppSyncData ExtensionService::GetAppSyncData(
1400 const Extension& extension) const { 1395 const Extension& extension) const {
1401 return extensions::AppSyncData( 1396 return extensions::AppSyncData(
1402 extension, 1397 extension,
1403 IsExtensionEnabled(extension.id()), 1398 IsExtensionEnabled(extension.id()),
1404 IsIncognitoEnabled(extension.id()), 1399 IsIncognitoEnabled(extension.id()),
1405 extension_prefs_->GetAppNotificationClientId(extension.id()),
1406 extension_prefs_->IsAppNotificationDisabled(extension.id()),
1407 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal( 1400 extension_prefs_->extension_sorting()->GetAppLaunchOrdinal(
1408 extension.id()), 1401 extension.id()),
1409 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id())); 1402 extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id()));
1410 } 1403 }
1411 1404
1412 std::vector<extensions::ExtensionSyncData> 1405 std::vector<extensions::ExtensionSyncData>
1413 ExtensionService::GetExtensionSyncDataList() const { 1406 ExtensionService::GetExtensionSyncDataList() const {
1414 std::vector<extensions::ExtensionSyncData> extension_sync_list; 1407 std::vector<extensions::ExtensionSyncData> extension_sync_list;
1415 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_, 1408 extension_sync_bundle_.GetExtensionSyncDataListHelper(extensions_,
1416 &extension_sync_list); 1409 &extension_sync_list);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 CheckForUpdatesSoon(); 1448 CheckForUpdatesSoon();
1456 return false; 1449 return false;
1457 } 1450 }
1458 1451
1459 return true; 1452 return true;
1460 } 1453 }
1461 1454
1462 bool ExtensionService::ProcessAppSyncData( 1455 bool ExtensionService::ProcessAppSyncData(
1463 const extensions::AppSyncData& app_sync_data) { 1456 const extensions::AppSyncData& app_sync_data) {
1464 const std::string& id = app_sync_data.id(); 1457 const std::string& id = app_sync_data.id();
1465 const Extension* extension = GetInstalledExtension(id);
1466 bool extension_installed = (extension != NULL);
1467 1458
1468 if (app_sync_data.app_launch_ordinal().IsValid() && 1459 if (app_sync_data.app_launch_ordinal().IsValid() &&
1469 app_sync_data.page_ordinal().IsValid()) { 1460 app_sync_data.page_ordinal().IsValid()) {
1470 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal( 1461 extension_prefs_->extension_sorting()->SetAppLaunchOrdinal(
1471 id, 1462 id,
1472 app_sync_data.app_launch_ordinal()); 1463 app_sync_data.app_launch_ordinal());
1473 extension_prefs_->extension_sorting()->SetPageOrdinal( 1464 extension_prefs_->extension_sorting()->SetPageOrdinal(
1474 id, 1465 id,
1475 app_sync_data.page_ordinal()); 1466 app_sync_data.page_ordinal());
1476 } 1467 }
1477 1468
1478 if (extension_installed) {
1479 if (app_sync_data.notifications_disabled() !=
1480 extension_prefs_->IsAppNotificationDisabled(id)) {
1481 extension_prefs_->SetAppNotificationDisabled(
1482 id, app_sync_data.notifications_disabled());
1483 }
1484 }
1485
1486 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), 1469 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(),
1487 syncer::APPS)) { 1470 syncer::APPS)) {
1488 app_sync_bundle_.AddPendingApp(id, app_sync_data); 1471 app_sync_bundle_.AddPendingApp(id, app_sync_data);
1489 CheckForUpdatesSoon(); 1472 CheckForUpdatesSoon();
1490 return false; 1473 return false;
1491 } 1474 }
1492 1475
1493 return true; 1476 return true;
1494 } 1477 }
1495 1478
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 std::string id = extension_id; 1619 std::string id = extension_id;
1637 if (extension_is_enabled) 1620 if (extension_is_enabled)
1638 ReloadExtension(id); 1621 ReloadExtension(id);
1639 1622
1640 // Reloading the extension invalidates the |extension| pointer. 1623 // Reloading the extension invalidates the |extension| pointer.
1641 extension = GetInstalledExtension(id); 1624 extension = GetInstalledExtension(id);
1642 if (extension) 1625 if (extension)
1643 SyncExtensionChangeIfNeeded(*extension); 1626 SyncExtensionChangeIfNeeded(*extension);
1644 } 1627 }
1645 1628
1646 void ExtensionService::SetAppNotificationSetupDone(
1647 const std::string& extension_id,
1648 const std::string& oauth_client_id) {
1649 const Extension* extension = GetInstalledExtension(extension_id);
1650 // This method is called when the user sets up app notifications.
1651 // So it is not expected to be called until the extension is installed.
1652 if (!extension) {
1653 NOTREACHED();
1654 return;
1655 }
1656 extension_prefs_->SetAppNotificationClientId(extension_id, oauth_client_id);
1657 SyncExtensionChangeIfNeeded(*extension);
1658 }
1659
1660 void ExtensionService::SetAppNotificationDisabled(
1661 const std::string& extension_id,
1662 bool value) {
1663 const Extension* extension = GetInstalledExtension(extension_id);
1664 // This method is called when the user enables/disables app notifications.
1665 // So it is not expected to be called until the extension is installed.
1666 if (!extension) {
1667 NOTREACHED();
1668 return;
1669 }
1670 if (value)
1671 UMA_HISTOGRAM_COUNTS("Apps.SetAppNotificationsDisabled", 1);
1672 else
1673 UMA_HISTOGRAM_COUNTS("Apps.SetAppNotificationsEnabled", 1);
1674 extension_prefs_->SetAppNotificationDisabled(extension_id, value);
1675 SyncExtensionChangeIfNeeded(*extension);
1676 }
1677
1678 bool ExtensionService::CanCrossIncognito(const Extension* extension) const { 1629 bool ExtensionService::CanCrossIncognito(const Extension* extension) const {
1679 // We allow the extension to see events and data from another profile iff it 1630 // We allow the extension to see events and data from another profile iff it
1680 // uses "spanning" behavior and it has incognito access. "split" mode 1631 // uses "spanning" behavior and it has incognito access. "split" mode
1681 // extensions only see events for a matching profile. 1632 // extensions only see events for a matching profile.
1682 CHECK(extension); 1633 CHECK(extension);
1683 return IsIncognitoEnabled(extension->id()) && 1634 return IsIncognitoEnabled(extension->id()) &&
1684 !extension->incognito_split_mode(); 1635 !extension->incognito_split_mode();
1685 } 1636 }
1686 1637
1687 bool ExtensionService::CanLoadInIncognito(const Extension* extension) const { 1638 bool ExtensionService::CanLoadInIncognito(const Extension* extension) const {
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 if (!extension) 3090 if (!extension)
3140 continue; 3091 continue;
3141 blacklisted_extensions_.Insert(extension); 3092 blacklisted_extensions_.Insert(extension);
3142 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); 3093 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST);
3143 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled", 3094 UMA_HISTOGRAM_ENUMERATION("ExtensionBlacklist.BlacklistInstalled",
3144 extension->location(), Manifest::NUM_LOCATIONS); 3095 extension->location(), Manifest::NUM_LOCATIONS);
3145 } 3096 }
3146 3097
3147 IdentifyAlertableExtensions(); 3098 IdentifyAlertableExtensions();
3148 } 3099 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698