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

Unified Diff: chrome/browser/ui/webui/ntp/ntp_login_handler.cc

Issue 895803003: [Profiles] Remove the NotificationService from the ProfileInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 10 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
Index: chrome/browser/ui/webui/ntp/ntp_login_handler.cc
diff --git a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
index e9b8a9a3f7027547cf41f369fcc0ea97ce03bcc5..c53b1ba7873a880000f211d1f8102d4f53c46b1e 100644
--- a/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_login_handler.cc
@@ -14,7 +14,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -35,8 +34,6 @@
#include "chrome/grit/generated_resources.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/host_zoom_map.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/page_zoom.h"
@@ -82,18 +79,24 @@ NTPLoginHandler::NTPLoginHandler() {
}
NTPLoginHandler::~NTPLoginHandler() {
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ // The profile_manager might be NULL in testing environments.
+ if (profile_manager)
+ profile_manager->GetProfileInfoCache().RemoveObserver(this);
}
void NTPLoginHandler::RegisterMessages() {
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ // The profile_manager might be NULL in testing environments.
+ if (profile_manager)
+ profile_manager->GetProfileInfoCache().AddObserver(this);
+
PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
signin_allowed_pref_.Init(prefs::kSigninAllowed,
pref_service,
base::Bind(&NTPLoginHandler::UpdateLogin,
base::Unretained(this)));
- registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
- content::NotificationService::AllSources());
-
web_ui()->RegisterMessageCallback("initializeSyncLogin",
base::Bind(&NTPLoginHandler::HandleInitializeSyncLogin,
base::Unretained(this)));
@@ -108,10 +111,8 @@ void NTPLoginHandler::RegisterMessages() {
base::Unretained(this)));
}
-void NTPLoginHandler::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type);
+void NTPLoginHandler::OnProfileUserNameChanged(
+ const base::FilePath& profile_path) {
UpdateLogin();
}
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_login_handler.h ('k') | chrome/browser/ui/webui/options/browser_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698