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

Side by Side Diff: chrome/browser/ui/webui/ntp/ntp_login_handler.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month 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
OLDNEW
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/ui/webui/ntp/ntp_login_handler.h" 5 #include "chrome/browser/ui/webui/ntp/ntp_login_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 web_ui()->RegisterMessageCallback("showAdvancedLoginUI", 105 web_ui()->RegisterMessageCallback("showAdvancedLoginUI",
106 base::Bind(&NTPLoginHandler::HandleShowAdvancedLoginUI, 106 base::Bind(&NTPLoginHandler::HandleShowAdvancedLoginUI,
107 base::Unretained(this))); 107 base::Unretained(this)));
108 } 108 }
109 109
110 void NTPLoginHandler::Observe(int type, 110 void NTPLoginHandler::Observe(int type,
111 const content::NotificationSource& source, 111 const content::NotificationSource& source,
112 const content::NotificationDetails& details) { 112 const content::NotificationDetails& details) {
113 if (type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { 113 if (type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) {
114 UpdateLogin(); 114 UpdateLogin();
115 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) {
116 std::string* name = content::Details<std::string>(details).ptr();
117 if (prefs::kGoogleServicesUsername == *name)
118 UpdateLogin();
119 } else { 115 } else {
120 NOTREACHED(); 116 NOTREACHED();
121 } 117 }
122 } 118 }
123 119
120 void NTPLoginHandler::OnPreferenceChanged(PrefServiceBase* service,
121 const std::string& pref_name) {
122 if (prefs::kGoogleServicesUsername == pref_name)
123 UpdateLogin();
124 }
125
124 void NTPLoginHandler::HandleInitializeSyncLogin(const ListValue* args) { 126 void NTPLoginHandler::HandleInitializeSyncLogin(const ListValue* args) {
125 UpdateLogin(); 127 UpdateLogin();
126 } 128 }
127 129
128 void NTPLoginHandler::HandleShowSyncLoginUI(const ListValue* args) { 130 void NTPLoginHandler::HandleShowSyncLoginUI(const ListValue* args) {
129 Profile* profile = Profile::FromWebUI(web_ui()); 131 Profile* profile = Profile::FromWebUI(web_ui());
130 std::string username = profile->GetPrefs()->GetString( 132 std::string username = profile->GetPrefs()->GetString(
131 prefs::kGoogleServicesUsername); 133 prefs::kGoogleServicesUsername);
132 content::WebContents* web_contents = web_ui()->GetWebContents(); 134 content::WebContents* web_contents = web_ui()->GetWebContents();
133 Browser* browser = browser::FindBrowserWithWebContents(web_contents); 135 Browser* browser = browser::FindBrowserWithWebContents(web_contents);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); 275 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
274 values->SetString("login_status_url", 276 values->SetString("login_status_url",
275 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); 277 hide_sync ? std::string() : chrome::kSyncLearnMoreURL);
276 values->SetString("login_status_advanced", 278 values->SetString("login_status_advanced",
277 hide_sync ? string16() : 279 hide_sync ? string16() :
278 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); 280 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED));
279 values->SetString("login_status_dismiss", 281 values->SetString("login_status_dismiss",
280 hide_sync ? string16() : 282 hide_sync ? string16() :
281 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); 283 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK));
282 } 284 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/ntp_login_handler.h ('k') | chrome/browser/ui/webui/ntp/ntp_resource_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698