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

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

Issue 458893003: Fix crash in guest mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/first_run/first_run.h" 10 #include "chrome/browser/first_run/first_run.h"
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // Refresh the account management view when an account is removed from the 599 // Refresh the account management view when an account is removed from the
600 // profile. 600 // profile.
601 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) 601 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT)
602 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 602 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
603 } 603 }
604 604
605 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, 605 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display,
606 AvatarMenu* avatar_menu) { 606 AvatarMenu* avatar_menu) {
607 // The account management view should only be displayed if the active profile 607 // The account management view should only be displayed if the active profile
608 // is signed in. 608 // is signed in.
609 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt(
610 avatar_menu->GetActiveProfileIndex());
611 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { 609 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
612 DCHECK(switches::IsEnableAccountConsistency()); 610 DCHECK(switches::IsEnableAccountConsistency());
611 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt(
612 avatar_menu->GetActiveProfileIndex());
613 DCHECK(active_item.signed_in); 613 DCHECK(active_item.signed_in);
614 } 614 }
615 615
616 if (browser_->profile()->IsSupervised() && 616 if (browser_->profile()->IsSupervised() &&
617 (view_to_display == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || 617 (view_to_display == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
618 view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL)) { 618 view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL)) {
619 LOG(WARNING) << "Supervised user attempted to add/remove account"; 619 LOG(WARNING) << "Supervised user attempted to add/remove account";
620 return; 620 return;
621 } 621 }
622 622
(...skipping 11 matching lines...) Expand all
634 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: 634 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH:
635 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); 635 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth);
636 sub_view = CreateGaiaSigninView(); 636 sub_view = CreateGaiaSigninView();
637 break; 637 break;
638 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: 638 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL:
639 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); 639 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth);
640 sub_view = CreateAccountRemovalView(); 640 sub_view = CreateAccountRemovalView();
641 break; 641 break;
642 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: 642 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER:
643 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); 643 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth);
644 sub_view = CreateSwitchUserView(active_item); 644 sub_view = CreateSwitchUserView();
645 break; 645 break;
646 default: 646 default:
647 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); 647 layout = CreateSingleColumnLayout(this, kFixedMenuWidth);
648 sub_view = CreateProfileChooserView(avatar_menu, last_tutorial_mode); 648 sub_view = CreateProfileChooserView(avatar_menu, last_tutorial_mode);
649 } 649 }
650 layout->StartRow(1, 0); 650 layout->StartRow(1, 0);
651 layout->AddView(sub_view); 651 layout->AddView(sub_view);
652 Layout(); 652 Layout();
653 if (GetBubbleFrameView()) 653 if (GetBubbleFrameView())
654 SizeToContents(); 654 SizeToContents();
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 profiles::TUTORIAL_MODE_CONFIRM_SIGNIN, 1431 profiles::TUTORIAL_MODE_CONFIRM_SIGNIN,
1432 l10n_util::GetStringUTF16(IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE), 1432 l10n_util::GetStringUTF16(IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE),
1433 l10n_util::GetStringUTF16( 1433 l10n_util::GetStringUTF16(
1434 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT), 1434 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT),
1435 l10n_util::GetStringUTF16(IDS_PROFILES_SYNC_SETTINGS_LINK), 1435 l10n_util::GetStringUTF16(IDS_PROFILES_SYNC_SETTINGS_LINK),
1436 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), 1436 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON),
1437 &tutorial_sync_settings_link_, 1437 &tutorial_sync_settings_link_,
1438 &tutorial_sync_settings_ok_button_); 1438 &tutorial_sync_settings_ok_button_);
1439 } 1439 }
1440 1440
1441 views::View* ProfileChooserView::CreateSwitchUserView( 1441 views::View* ProfileChooserView::CreateSwitchUserView() {
1442 const AvatarMenu::Item& avatar_item) {
1443 views::View* view = new views::View(); 1442 views::View* view = new views::View();
1444 views::GridLayout* layout = CreateSingleColumnLayout( 1443 views::GridLayout* layout = CreateSingleColumnLayout(
1445 view, kFixedSwitchUserViewWidth); 1444 view, kFixedSwitchUserViewWidth);
1446 views::ColumnSet* columns = layout->AddColumnSet(1); 1445 views::ColumnSet* columns = layout->AddColumnSet(1);
1447 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); 1446 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
1448 int label_width = 1447 int label_width =
1449 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew; 1448 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew;
1450 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 1449 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
1451 views::GridLayout::FIXED, label_width, label_width); 1450 views::GridLayout::FIXED, label_width, label_width);
1452 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); 1451 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
1453 1452
1454 // Adds main text. 1453 // Adds main text.
1455 layout->StartRowWithPadding(1, 1, 0, views::kUnrelatedControlVerticalSpacing); 1454 layout->StartRowWithPadding(1, 1, 0, views::kUnrelatedControlVerticalSpacing);
1456 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1455 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1457 const gfx::FontList& small_font_list = 1456 const gfx::FontList& small_font_list =
1458 rb->GetFontList(ui::ResourceBundle::SmallFont); 1457 rb->GetFontList(ui::ResourceBundle::SmallFont);
1458 const AvatarMenu::Item& avatar_item =
1459 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex());
1459 views::Label* content_label = new views::Label( 1460 views::Label* content_label = new views::Label(
1460 l10n_util::GetStringFUTF16( 1461 l10n_util::GetStringFUTF16(
1461 IDS_PROFILES_NOT_YOU_CONTENT_TEXT, avatar_item.name)); 1462 IDS_PROFILES_NOT_YOU_CONTENT_TEXT, avatar_item.name));
1462 content_label->SetMultiLine(true); 1463 content_label->SetMultiLine(true);
1463 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1464 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1464 content_label->SetFontList(small_font_list); 1465 content_label->SetFontList(small_font_list);
1465 layout->AddView(content_label); 1466 layout->AddView(content_label);
1466 1467
1467 // Adds "Add person" button. 1468 // Adds "Add person" button.
1468 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1469 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing);
(...skipping 29 matching lines...) Expand all
1498 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1499 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1499 IncognitoModePrefs::DISABLED; 1500 IncognitoModePrefs::DISABLED;
1500 return incognito_available && !browser_->profile()->IsGuestSession(); 1501 return incognito_available && !browser_->profile()->IsGuestSession();
1501 } 1502 }
1502 1503
1503 void ProfileChooserView::PostActionPerformed( 1504 void ProfileChooserView::PostActionPerformed(
1504 ProfileMetrics::ProfileDesktopMenu action_performed) { 1505 ProfileMetrics::ProfileDesktopMenu action_performed) {
1505 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1506 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1506 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1507 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1507 } 1508 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698