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/app_launcher_login_handler.cc

Issue 1723643002: Refactor ProfileInfoCache in c/b/ui/webui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a signed/unsigned integer conversion, one removed #include Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/sync_setup_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/app_launcher_login_handler.h" 5 #include "chrome/browser/ui/webui/app_launcher_login_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_info_cache.h" 19 #include "chrome/browser/profiles/profile_attributes_entry.h"
20 #include "chrome/browser/profiles/profile_attributes_storage.h"
20 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/profiles/profile_metrics.h" 22 #include "chrome/browser/profiles/profile_metrics.h"
22 #include "chrome/browser/signin/signin_manager_factory.h" 23 #include "chrome/browser/signin/signin_manager_factory.h"
23 #include "chrome/browser/signin/signin_promo.h" 24 #include "chrome/browser/signin/signin_promo.h"
24 #include "chrome/browser/sync/profile_sync_service_factory.h" 25 #include "chrome/browser/sync/profile_sync_service_factory.h"
25 #include "chrome/browser/ui/browser.h" 26 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_finder.h" 27 #include "chrome/browser/ui/browser_finder.h"
27 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
28 #include "chrome/browser/ui/chrome_pages.h" 29 #include "chrome/browser/ui/chrome_pages.h"
29 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" 30 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 : signin_metrics::AccessPoint::ACCESS_POINT_NTP_LINK; 172 : signin_metrics::AccessPoint::ACCESS_POINT_NTP_LINK;
172 chrome::ShowBrowserSignin(browser, access_point); 173 chrome::ShowBrowserSignin(browser, access_point);
173 } 174 }
174 175
175 void AppLauncherLoginHandler::UpdateLogin() { 176 void AppLauncherLoginHandler::UpdateLogin() {
176 std::string username = profile_info_watcher_->GetAuthenticatedUsername(); 177 std::string username = profile_info_watcher_->GetAuthenticatedUsername();
177 base::string16 header, sub_header; 178 base::string16 header, sub_header;
178 std::string icon_url; 179 std::string icon_url;
179 Profile* profile = Profile::FromWebUI(web_ui()); 180 Profile* profile = Profile::FromWebUI(web_ui());
180 if (!username.empty()) { 181 if (!username.empty()) {
181 ProfileInfoCache& cache = 182 ProfileAttributesStorage& storage =
182 g_browser_process->profile_manager()->GetProfileInfoCache(); 183 g_browser_process->profile_manager()->GetProfileAttributesStorage();
183 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 184 ProfileAttributesEntry* entry;
184 if (profile_index != std::string::npos) { 185 if (storage.GetProfileAttributesWithPath(profile->GetPath(), &entry)) {
185 // Only show the profile picture and full name for the single profile 186 // Only show the profile picture and full name for the single profile
186 // case. In the multi-profile case the profile picture is visible in the 187 // case. In the multi-profile case the profile picture is visible in the
187 // title bar and the full name can be ambiguous. 188 // title bar and the full name can be ambiguous.
188 if (cache.GetNumberOfProfiles() == 1) { 189 if (storage.GetNumberOfProfiles() == 1) {
189 base::string16 name = cache.GetGAIANameOfProfileAtIndex(profile_index); 190 base::string16 name = entry->GetGAIAName();
190 if (!name.empty()) 191 if (!name.empty())
191 header = CreateElementWithClass(name, "span", "profile-name", ""); 192 header = CreateElementWithClass(name, "span", "profile-name", "");
192 const gfx::Image* image = 193 const gfx::Image* image = entry->GetGAIAPicture();
193 cache.GetGAIAPictureOfProfileAtIndex(profile_index);
194 if (image) 194 if (image)
195 icon_url = webui::GetBitmapDataUrl(GetGAIAPictureForNTP(*image)); 195 icon_url = webui::GetBitmapDataUrl(GetGAIAPictureForNTP(*image));
196 } 196 }
197 if (header.empty()) { 197 if (header.empty()) {
198 header = CreateElementWithClass(base::UTF8ToUTF16(username), "span", 198 header = CreateElementWithClass(base::UTF8ToUTF16(username), "span",
199 "profile-name", ""); 199 "profile-name", "");
200 } 200 }
201 } 201 }
202 } else { 202 } else {
203 #if !defined(OS_CHROMEOS) 203 #if !defined(OS_CHROMEOS)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 values->SetString("login_status_message", message); 259 values->SetString("login_status_message", message);
260 values->SetString("login_status_url", 260 values->SetString("login_status_url",
261 hide_sync ? std::string() : chrome::kSyncLearnMoreURL); 261 hide_sync ? std::string() : chrome::kSyncLearnMoreURL);
262 values->SetString("login_status_advanced", 262 values->SetString("login_status_advanced",
263 hide_sync ? base::string16() : 263 hide_sync ? base::string16() :
264 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED)); 264 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_ADVANCED));
265 values->SetString("login_status_dismiss", 265 values->SetString("login_status_dismiss",
266 hide_sync ? base::string16() : 266 hide_sync ? base::string16() :
267 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK)); 267 l10n_util::GetStringUTF16(IDS_SYNC_PROMO_NTP_BUBBLE_OK));
268 } 268 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/sync_setup_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698