| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_chooser_view.h" | 5 #include "chrome/browser/ui/views/profile_chooser_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile_info_util.h" | 9 #include "chrome/browser/profiles/profile_info_util.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // as this may have been triggered by a sign out action, in which case | 259 // as this may have been triggered by a sign out action, in which case |
| 260 // the view is being destroyed. | 260 // the view is being destroyed. |
| 261 ShowView(PROFILE_CHOOSER_VIEW, avatar_menu); | 261 ShowView(PROFILE_CHOOSER_VIEW, avatar_menu); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void ProfileChooserView::ShowView(BubbleViewMode view_to_display, | 264 void ProfileChooserView::ShowView(BubbleViewMode view_to_display, |
| 265 AvatarMenu* avatar_menu) { | 265 AvatarMenu* avatar_menu) { |
| 266 // The account management view should only be displayed if the active profile | 266 // The account management view should only be displayed if the active profile |
| 267 // is signed in. | 267 // is signed in. |
| 268 if (view_to_display == ACCOUNT_MANAGEMENT_VIEW) { | 268 if (view_to_display == ACCOUNT_MANAGEMENT_VIEW) { |
| 269 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( | 269 const AvatarMenu::Item& active_item = avatar_menu->GetActiveProfileItem(); |
| 270 avatar_menu->GetActiveProfileIndex()); | |
| 271 DCHECK(active_item.signed_in); | 270 DCHECK(active_item.signed_in); |
| 272 } | 271 } |
| 273 | 272 |
| 274 ResetLinksAndButtons(); | 273 ResetLinksAndButtons(); |
| 275 RemoveAllChildViews(true); | 274 RemoveAllChildViews(true); |
| 276 | 275 |
| 277 views::GridLayout* layout = CreateSingleColumnLayout(this); | 276 views::GridLayout* layout = CreateSingleColumnLayout(this); |
| 278 layout->set_minimum_size(gfx::Size(kMinMenuWidth, 0)); | 277 layout->set_minimum_size(gfx::Size(kMinMenuWidth, 0)); |
| 279 | 278 |
| 280 if (view_to_display == GAIA_SIGNIN_VIEW) { | 279 if (view_to_display == GAIA_SIGNIN_VIEW) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 if (CommandLine::ForCurrentProcess()->HasSwitch( | 384 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 386 switches::kEnableInlineSignin)) { | 385 switches::kEnableInlineSignin)) { |
| 387 ShowView(GAIA_SIGNIN_VIEW, avatar_menu_.get()); | 386 ShowView(GAIA_SIGNIN_VIEW, avatar_menu_.get()); |
| 388 } else { | 387 } else { |
| 389 GURL page = signin::GetPromoURL(signin::SOURCE_MENU, false); | 388 GURL page = signin::GetPromoURL(signin::SOURCE_MENU, false); |
| 390 chrome::ShowSingletonTab(browser_, page); | 389 chrome::ShowSingletonTab(browser_, page); |
| 391 } | 390 } |
| 392 } else { | 391 } else { |
| 393 DCHECK(sender == change_photo_link_); | 392 DCHECK(sender == change_photo_link_); |
| 394 avatar_menu_->EditProfile( | 393 avatar_menu_->EditProfile( |
| 395 avatar_menu_->GetActiveProfileIndex()); | 394 avatar_menu_->GetActiveProfileItem().menu_index); |
| 396 } | 395 } |
| 397 } | 396 } |
| 398 | 397 |
| 399 views::View* ProfileChooserView::CreateCurrentProfileView( | 398 views::View* ProfileChooserView::CreateCurrentProfileView( |
| 400 const AvatarMenu::Item& avatar_item, | 399 const AvatarMenu::Item& avatar_item, |
| 401 bool is_guest) { | 400 bool is_guest) { |
| 402 views::View* view = new views::View(); | 401 views::View* view = new views::View(); |
| 403 views::GridLayout* layout = CreateDoubleColumnLayout(view); | 402 views::GridLayout* layout = CreateDoubleColumnLayout(view); |
| 404 layout->SetInsets(views::kButtonVEdgeMarginNew, | 403 layout->SetInsets(views::kButtonVEdgeMarginNew, |
| 405 views::kButtonHEdgeMarginNew, | 404 views::kButtonHEdgeMarginNew, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 604 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 606 | 605 |
| 607 views::BlueButton* add_account_button = new views::BlueButton( | 606 views::BlueButton* add_account_button = new views::BlueButton( |
| 608 NULL, | 607 NULL, |
| 609 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, | 608 l10n_util::GetStringFUTF16(IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, |
| 610 avatar_item.name)); | 609 avatar_item.name)); |
| 611 layout->StartRow(1, 0); | 610 layout->StartRow(1, 0); |
| 612 layout->AddView(add_account_button); | 611 layout->AddView(add_account_button); |
| 613 return view; | 612 return view; |
| 614 } | 613 } |
| OLD | NEW |