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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 471333003: Make sure avatar menu does not use account_id for display purposes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/lifetime/application_lifetime.h" 10 #include "chrome/browser/lifetime/application_lifetime.h"
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( 1284 views::View* ProfileChooserView::CreateCurrentProfileAccountsView(
1285 const AvatarMenu::Item& avatar_item) { 1285 const AvatarMenu::Item& avatar_item) {
1286 DCHECK(avatar_item.signed_in); 1286 DCHECK(avatar_item.signed_in);
1287 views::View* view = new views::View(); 1287 views::View* view = new views::View();
1288 view->set_background(views::Background::CreateSolidBackground( 1288 view->set_background(views::Background::CreateSolidBackground(
1289 profiles::kAvatarBubbleAccountsBackgroundColor)); 1289 profiles::kAvatarBubbleAccountsBackgroundColor));
1290 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1290 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
1291 1291
1292 Profile* profile = browser_->profile(); 1292 Profile* profile = browser_->profile();
1293 std::string primary_account = 1293 std::string primary_account =
1294 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); 1294 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId();
1295 DCHECK(!primary_account.empty()); 1295 DCHECK(!primary_account.empty());
1296 std::vector<std::string>accounts = 1296 std::vector<std::string>accounts =
1297 profiles::GetSecondaryAccountsForProfile(profile, primary_account); 1297 profiles::GetSecondaryAccountsForProfile(profile, primary_account);
1298 1298
1299 // Get state of authentication error, if any. 1299 // Get state of authentication error, if any.
1300 std::string error_account_id = GetAuthErrorAccountId(profile); 1300 std::string error_account_id = GetAuthErrorAccountId(profile);
1301 1301
1302 // The primary account should always be listed first. 1302 // The primary account should always be listed first.
1303 // TODO(rogerta): we still need to further differentiate the primary account 1303 // TODO(rogerta): we still need to further differentiate the primary account
1304 // from the others in the UI, so more work is likely required here: 1304 // from the others in the UI, so more work is likely required here:
(...skipping 13 matching lines...) Expand all
1318 0, views::kButtonVEdgeMarginNew, 1318 0, views::kButtonVEdgeMarginNew,
1319 views::kRelatedControlVerticalSpacing, 0)); 1319 views::kRelatedControlVerticalSpacing, 0));
1320 layout->StartRow(1, 0); 1320 layout->StartRow(1, 0);
1321 layout->AddView(add_account_link_); 1321 layout->AddView(add_account_link_);
1322 } 1322 }
1323 1323
1324 return view; 1324 return view;
1325 } 1325 }
1326 1326
1327 void ProfileChooserView::CreateAccountButton(views::GridLayout* layout, 1327 void ProfileChooserView::CreateAccountButton(views::GridLayout* layout,
1328 const std::string& account, 1328 const std::string& account_id,
1329 bool is_primary_account, 1329 bool is_primary_account,
1330 bool reauth_required, 1330 bool reauth_required,
1331 int width) { 1331 int width) {
1332 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(),
1333 account_id);
1332 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1334 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1333 const gfx::ImageSkia* delete_default_image = 1335 const gfx::ImageSkia* delete_default_image =
1334 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia(); 1336 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia();
1335 const int kDeleteButtonWidth = delete_default_image->width(); 1337 const int kDeleteButtonWidth = delete_default_image->width();
1336 const gfx::ImageSkia warning_default_image = reauth_required ? 1338 const gfx::ImageSkia warning_default_image = reauth_required ?
1337 *rb->GetImageNamed(IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR).ToImageSkia() : 1339 *rb->GetImageNamed(IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR).ToImageSkia() :
1338 gfx::ImageSkia(); 1340 gfx::ImageSkia();
1339 const int kWarningButtonWidth = reauth_required ? 1341 const int kWarningButtonWidth = reauth_required ?
1340 warning_default_image.width() + views::kRelatedButtonHSpacing : 0; 1342 warning_default_image.width() + views::kRelatedButtonHSpacing : 0;
1341 int available_width = width - 2 * views::kButtonHEdgeMarginNew 1343 int available_width = width - 2 * views::kButtonHEdgeMarginNew
1342 - kDeleteButtonWidth - kWarningButtonWidth; 1344 - kDeleteButtonWidth - kWarningButtonWidth;
1343 views::LabelButton* email_button = new BackgroundColorHoverButton( 1345 views::LabelButton* email_button = new BackgroundColorHoverButton(
1344 reauth_required ? this : NULL, 1346 reauth_required ? this : NULL,
1345 base::UTF8ToUTF16(account), 1347 base::UTF8ToUTF16(email),
1346 warning_default_image); 1348 warning_default_image);
1347 email_button->SetElideBehavior(gfx::ELIDE_EMAIL); 1349 email_button->SetElideBehavior(gfx::ELIDE_EMAIL);
1348 email_button->SetMinSize(gfx::Size(0, kButtonHeight)); 1350 email_button->SetMinSize(gfx::Size(0, kButtonHeight));
1349 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight)); 1351 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight));
1350 layout->StartRow(1, 0); 1352 layout->StartRow(1, 0);
1351 layout->AddView(email_button); 1353 layout->AddView(email_button);
1352 1354
1353 if (reauth_required) 1355 if (reauth_required)
1354 reauth_account_button_map_[email_button] = account; 1356 reauth_account_button_map_[email_button] = account_id;
1355 1357
1356 // Delete button. 1358 // Delete button.
1357 if (!browser_->profile()->IsSupervised()) { 1359 if (!browser_->profile()->IsSupervised()) {
1358 views::ImageButton* delete_button = new views::ImageButton(this); 1360 views::ImageButton* delete_button = new views::ImageButton(this);
1359 delete_button->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, 1361 delete_button->SetImageAlignment(views::ImageButton::ALIGN_RIGHT,
1360 views::ImageButton::ALIGN_MIDDLE); 1362 views::ImageButton::ALIGN_MIDDLE);
1361 delete_button->SetImage(views::ImageButton::STATE_NORMAL, 1363 delete_button->SetImage(views::ImageButton::STATE_NORMAL,
1362 delete_default_image); 1364 delete_default_image);
1363 delete_button->SetImage(views::ImageButton::STATE_HOVERED, 1365 delete_button->SetImage(views::ImageButton::STATE_HOVERED,
1364 rb->GetImageSkiaNamed(IDR_CLOSE_1_H)); 1366 rb->GetImageSkiaNamed(IDR_CLOSE_1_H));
1365 delete_button->SetImage(views::ImageButton::STATE_PRESSED, 1367 delete_button->SetImage(views::ImageButton::STATE_PRESSED,
1366 rb->GetImageSkiaNamed(IDR_CLOSE_1_P)); 1368 rb->GetImageSkiaNamed(IDR_CLOSE_1_P));
1367 delete_button->SetBounds( 1369 delete_button->SetBounds(
1368 width - views::kButtonHEdgeMarginNew - kDeleteButtonWidth, 1370 width - views::kButtonHEdgeMarginNew - kDeleteButtonWidth,
1369 0, kDeleteButtonWidth, kButtonHeight); 1371 0, kDeleteButtonWidth, kButtonHeight);
1370 1372
1371 email_button->set_notify_enter_exit_on_child(true); 1373 email_button->set_notify_enter_exit_on_child(true);
1372 email_button->AddChildView(delete_button); 1374 email_button->AddChildView(delete_button);
1373 1375
1374 // Save the original email address, as the button text could be elided. 1376 // Save the original email address, as the button text could be elided.
1375 delete_account_button_map_[delete_button] = account; 1377 delete_account_button_map_[delete_button] = account_id;
1376 } 1378 }
1377 } 1379 }
1378 1380
1379 views::View* ProfileChooserView::CreateGaiaSigninView() { 1381 views::View* ProfileChooserView::CreateGaiaSigninView() {
1380 GURL url; 1382 GURL url;
1381 int message_id; 1383 int message_id;
1382 1384
1383 switch (view_mode_) { 1385 switch (view_mode_) {
1384 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: 1386 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
1385 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_SIGN_IN, 1387 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_SIGN_IN,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 views::View* ProfileChooserView::CreateAccountRemovalView() { 1424 views::View* ProfileChooserView::CreateAccountRemovalView() {
1423 views::View* view = new views::View(); 1425 views::View* view = new views::View();
1424 views::GridLayout* layout = CreateSingleColumnLayout( 1426 views::GridLayout* layout = CreateSingleColumnLayout(
1425 view, kFixedAccountRemovalViewWidth - 2 * views::kButtonHEdgeMarginNew); 1427 view, kFixedAccountRemovalViewWidth - 2 * views::kButtonHEdgeMarginNew);
1426 layout->SetInsets(0, 1428 layout->SetInsets(0,
1427 views::kButtonHEdgeMarginNew, 1429 views::kButtonHEdgeMarginNew,
1428 views::kButtonVEdgeMarginNew, 1430 views::kButtonVEdgeMarginNew,
1429 views::kButtonHEdgeMarginNew); 1431 views::kButtonHEdgeMarginNew);
1430 1432
1431 const std::string& primary_account = SigninManagerFactory::GetForProfile( 1433 const std::string& primary_account = SigninManagerFactory::GetForProfile(
1432 browser_->profile())->GetAuthenticatedUsername(); 1434 browser_->profile())->GetAuthenticatedUsername();
guohui 2014/08/21 19:01:53 you changed account_id_to_remove_ to use the accou
Roger Tawa OOO till Jul 10th 2014/08/21 20:39:25 Done.
guohui 2014/08/21 20:42:41 you need to convert account id to display email at
Roger Tawa OOO till Jul 10th 2014/08/21 20:59:34 Done.
1433 bool is_primary_account = primary_account == account_id_to_remove_; 1435 bool is_primary_account = primary_account == account_id_to_remove_;
1434 1436
1435 // Adds main text. 1437 // Adds main text.
1436 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1438 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1437 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1439 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1438 const gfx::FontList& small_font_list = 1440 const gfx::FontList& small_font_list =
1439 rb->GetFontList(ui::ResourceBundle::SmallFont); 1441 rb->GetFontList(ui::ResourceBundle::SmallFont);
1440 1442
1441 if (is_primary_account) { 1443 if (is_primary_account) {
1442 std::vector<size_t> offsets; 1444 std::vector<size_t> offsets;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1615 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1614 IncognitoModePrefs::DISABLED; 1616 IncognitoModePrefs::DISABLED;
1615 return incognito_available && !browser_->profile()->IsGuestSession(); 1617 return incognito_available && !browser_->profile()->IsGuestSession();
1616 } 1618 }
1617 1619
1618 void ProfileChooserView::PostActionPerformed( 1620 void ProfileChooserView::PostActionPerformed(
1619 ProfileMetrics::ProfileDesktopMenu action_performed) { 1621 ProfileMetrics::ProfileDesktopMenu action_performed) {
1620 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1622 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1621 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1623 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1622 } 1624 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698