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

Unified Diff: chrome/browser/background/background_mode_manager.cc

Issue 1128033002: Avoiding use of NOTIFICATION_EXTENSION_READY_DEPRECATED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Review Comments Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/background/background_mode_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/background/background_mode_manager.cc
diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc
index 4e4a2e76ec839cfebad839e7a849bc3d18e43efe..db6b3c1bc567fefe938764c333112934d89789bf 100644
--- a/chrome/browser/background/background_mode_manager.cc
+++ b/chrome/browser/background/background_mode_manager.cc
@@ -50,6 +50,7 @@
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
+#include "extensions/common/one_shot_event.h"
#include "extensions/common/permissions/permission_set.h"
#include "grit/chrome_unscaled_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -253,7 +254,8 @@ BackgroundModeManager::BackgroundModeManager(
keep_alive_for_startup_(false),
keep_alive_for_test_(false),
background_mode_suspended_(false),
- keeping_alive_(false) {
+ keeping_alive_(false),
+ weak_factory_(this) {
// We should never start up if there is no browser process or if we are
// currently quitting.
CHECK(g_browser_process != NULL);
@@ -350,9 +352,10 @@ void BackgroundModeManager::RegisterProfile(Profile* profile) {
// Check for the presence of background apps after all extensions have been
// loaded, to handle the case where an extension has been manually removed
// while Chrome was not running.
- registrar_.Add(this,
- extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
- content::Source<Profile>(profile));
+ extensions::ExtensionSystem::Get(profile)->ready().Post(
+ FROM_HERE,
+ base::Bind(&BackgroundModeManager::OnExtensionsReady,
+ weak_factory_.GetWeakPtr()));
bmd->applications_->AddObserver(this);
@@ -385,11 +388,6 @@ void BackgroundModeManager::Observe(
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
- case extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED:
- // Extensions are loaded, so we don't need to manually keep the browser
- // process alive any more when running in no-startup-window mode.
- DecrementKeepAliveCountForStartup();
- break;
case chrome::NOTIFICATION_APP_TERMINATING:
// Make sure we aren't still keeping the app alive (only happens if we
// don't receive an EXTENSIONS_READY notification for some reason).
@@ -413,6 +411,12 @@ void BackgroundModeManager::Observe(
}
}
+void BackgroundModeManager::OnExtensionsReady() {
+ // Extensions are loaded, so we don't need to manually keep the browser
+ // process alive any more when running in no-startup-window mode.
+ DecrementKeepAliveCountForStartup();
+}
+
void BackgroundModeManager::OnBackgroundModeEnabledPrefChanged() {
if (IsBackgroundModePrefEnabled())
EnableBackgroundMode();
« no previous file with comments | « chrome/browser/background/background_mode_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698