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

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

Issue 33753002: Sooper experimental refactoring of the profile info cache. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 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
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void NTPLoginHandler::UpdateLogin() { 199 void NTPLoginHandler::UpdateLogin() {
200 Profile* profile = Profile::FromWebUI(web_ui()); 200 Profile* profile = Profile::FromWebUI(web_ui());
201 std::string username = profile->GetPrefs()->GetString( 201 std::string username = profile->GetPrefs()->GetString(
202 prefs::kGoogleServicesUsername); 202 prefs::kGoogleServicesUsername);
203 203
204 string16 header, sub_header; 204 string16 header, sub_header;
205 std::string icon_url; 205 std::string icon_url;
206 if (!username.empty()) { 206 if (!username.empty()) {
207 ProfileInfoCache& cache = 207 ProfileInfoCache& cache =
208 g_browser_process->profile_manager()->GetProfileInfoCache(); 208 g_browser_process->profile_manager()->GetProfileInfoCache();
209 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 209
210 if (profile_index != std::string::npos) { 210 ProfileInfoEntry entry;
211 if (cache.GetInfoForProfile(profile->GetPath(), &entry)) {
211 // Only show the profile picture and full name for the single profile 212 // Only show the profile picture and full name for the single profile
212 // case. In the multi-profile case the profile picture is visible in the 213 // case. In the multi-profile case the profile picture is visible in the
213 // title bar and the full name can be ambiguous. 214 // title bar and the full name can be ambiguous.
214 if (cache.GetNumberOfProfiles() == 1) { 215 if (cache.GetNumberOfProfiles() == 1) {
215 string16 name = cache.GetGAIANameOfProfileAtIndex(profile_index); 216 string16 name = entry.GAIA_full_name();
216 if (!name.empty()) 217 if (!name.empty())
217 header = CreateSpanWithClass(name, "profile-name"); 218 header = CreateSpanWithClass(name, "profile-name");
218 const gfx::Image* image = 219 const gfx::Image* image =
219 cache.GetGAIAPictureOfProfileAtIndex(profile_index); 220 cache.GetGAIAPictureOfProfile(entry.path());
220 if (image) 221 if (image)
221 icon_url = webui::GetBitmapDataUrl(GetGAIAPictureForNTP(*image)); 222 icon_url = webui::GetBitmapDataUrl(GetGAIAPictureForNTP(*image));
222 } 223 }
223 if (header.empty()) 224 if (header.empty())
224 header = CreateSpanWithClass(UTF8ToUTF16(username), "profile-name"); 225 header = CreateSpanWithClass(UTF8ToUTF16(username), "profile-name");
225 } 226 }
226 } else { 227 } else {
227 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) 228 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
228 // Android uses a custom sign in promo. Don't call the function 229 // Android uses a custom sign in promo. Don't call the function
229 // signin::ShouldShowPromo() since it does a bunch of checks that are not 230 // signin::ShouldShowPromo() since it does a bunch of checks that are not
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 values->SetString("login_status_message", message); 281 values->SetString("login_status_message", message);
281 values->SetString("login_status_url", 282 values->SetString("login_status_url",
282 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); 283 hide_sync ? std::string() : chrome::kSyncLearnMoreURL);
283 values->SetString("login_status_advanced", 284 values->SetString("login_status_advanced",
284 hide_sync ? string16() : 285 hide_sync ? string16() :
285 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); 286 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED));
286 values->SetString("login_status_dismiss", 287 values->SetString("login_status_dismiss",
287 hide_sync ? string16() : 288 hide_sync ? string16() :
288 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); 289 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK));
289 } 290 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profile_chooser_view.cc ('k') | chrome/browser/ui/webui/options/browser_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698