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(); |
} |