Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/metrics/user_metrics.h" | 8 #include "base/metrics/user_metrics.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1491 sync_ui_util::AvatarSyncErrorType error = | 1491 sync_ui_util::AvatarSyncErrorType error = |
| 1492 sync_ui_util::GetMessagesForAvatarSyncError( | 1492 sync_ui_util::GetMessagesForAvatarSyncError( |
| 1493 browser_->profile(), &content_string_id, &button_string_id); | 1493 browser_->profile(), &content_string_id, &button_string_id); |
| 1494 switch (error) { | 1494 switch (error) { |
| 1495 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR: | 1495 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR: |
| 1496 button_out = &sync_error_signout_button_; | 1496 button_out = &sync_error_signout_button_; |
| 1497 break; | 1497 break; |
| 1498 case sync_ui_util::UNRECOVERABLE_ERROR: | 1498 case sync_ui_util::UNRECOVERABLE_ERROR: |
| 1499 button_out = &sync_error_signin_again_button_; | 1499 button_out = &sync_error_signin_again_button_; |
| 1500 break; | 1500 break; |
| 1501 case sync_ui_util::SUPERVISED_USER_AUTH_ERROR: | |
| 1502 *button_out = nullptr; | |
| 1503 break; | |
| 1501 case sync_ui_util::AUTH_ERROR: | 1504 case sync_ui_util::AUTH_ERROR: |
| 1502 button_out = &sync_error_signin_button_; | 1505 button_out = &sync_error_signin_button_; |
| 1503 break; | 1506 break; |
| 1504 case sync_ui_util::UPGRADE_CLIENT_ERROR: | 1507 case sync_ui_util::UPGRADE_CLIENT_ERROR: |
| 1505 button_out = &sync_error_upgrade_button_; | 1508 button_out = &sync_error_upgrade_button_; |
| 1506 break; | 1509 break; |
| 1507 case sync_ui_util::PASSPHRASE_ERROR: | 1510 case sync_ui_util::PASSPHRASE_ERROR: |
| 1508 button_out = &sync_error_passphrase_button_; | 1511 button_out = &sync_error_passphrase_button_; |
| 1509 break; | 1512 break; |
| 1510 case sync_ui_util::NO_SYNC_ERROR: | 1513 case sync_ui_util::NO_SYNC_ERROR: |
| 1511 return nullptr; | 1514 return nullptr; |
| 1512 default: | 1515 default: |
| 1513 NOTREACHED(); | 1516 NOTREACHED(); |
| 1514 } | 1517 } |
| 1515 return CreateSyncErrorView(content_string_id, button_string_id, button_out); | |
| 1516 } | |
| 1517 | 1518 |
| 1518 views::View* ProfileChooserView::CreateSyncErrorView( | |
| 1519 const int content_string_id, | |
| 1520 const int button_string_id, | |
| 1521 views::LabelButton** button_out) { | |
| 1522 // Sets an overall horizontal layout. | 1519 // Sets an overall horizontal layout. |
| 1523 views::View* view = new views::View(); | 1520 views::View* view = new views::View(); |
| 1524 views::BoxLayout* layout = new views::BoxLayout( | 1521 views::BoxLayout* layout = new views::BoxLayout( |
| 1525 views::BoxLayout::kHorizontal, kMaterialMenuEdgeMargin, | 1522 views::BoxLayout::kHorizontal, kMaterialMenuEdgeMargin, |
| 1526 kMaterialMenuEdgeMargin, views::kUnrelatedControlHorizontalSpacing); | 1523 kMaterialMenuEdgeMargin, views::kUnrelatedControlHorizontalSpacing); |
| 1527 layout->set_cross_axis_alignment( | 1524 layout->set_cross_axis_alignment( |
| 1528 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); | 1525 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); |
| 1529 view->SetLayoutManager(layout); | 1526 view->SetLayoutManager(layout); |
| 1530 | 1527 |
| 1531 // Adds the sync problem icon. | 1528 // Adds the sync problem icon. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1550 title_label->SetEnabledColor(gfx::kGoogleRed700); | 1547 title_label->SetEnabledColor(gfx::kGoogleRed700); |
| 1551 vertical_view->AddChildView(title_label); | 1548 vertical_view->AddChildView(title_label); |
| 1552 | 1549 |
| 1553 // Adds body content. | 1550 // Adds body content. |
| 1554 views::Label* content_label = | 1551 views::Label* content_label = |
| 1555 new views::Label(l10n_util::GetStringUTF16(content_string_id)); | 1552 new views::Label(l10n_util::GetStringUTF16(content_string_id)); |
| 1556 content_label->SetMultiLine(true); | 1553 content_label->SetMultiLine(true); |
| 1557 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1554 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1558 vertical_view->AddChildView(content_label); | 1555 vertical_view->AddChildView(content_label); |
| 1559 | 1556 |
| 1560 // Adds a padding row between error title/content and the button. | 1557 // Adds an action button if an action exists. |
| 1561 SizedContainer* padding = | 1558 if (button_string_id) { |
| 1562 new SizedContainer(gfx::Size(0, views::kRelatedControlVerticalSpacing)); | 1559 DCHECK(button_out); |
| 1563 vertical_view->AddChildView(padding); | 1560 // Adds a padding row between error title/content and the button. |
| 1561 SizedContainer* padding = | |
| 1562 new SizedContainer(gfx::Size(0, views::kRelatedControlVerticalSpacing)); | |
| 1563 vertical_view->AddChildView(padding); | |
| 1564 | 1564 |
| 1565 // Adds an action button. | 1565 *button_out = views::MdTextButton::CreateSecondaryUiBlueButton( |
| 1566 *button_out = views::MdTextButton::CreateSecondaryUiBlueButton( | 1566 this, l10n_util::GetStringUTF16(button_string_id)); |
| 1567 this, l10n_util::GetStringUTF16(button_string_id)); | 1567 vertical_view->AddChildView(*button_out); |
| 1568 vertical_view->AddChildView(*button_out); | 1568 view->SetBorder(views::Border::CreateEmptyBorder( |
| 1569 0, 0, views::kRelatedControlSmallVerticalSpacing, 0)); | |
| 1570 } else { | |
| 1571 *button_out = nullptr; | |
|
sky
2016/08/23 13:20:39
The reason I suggested setting *button_to null her
Jane
2016/08/23 15:04:40
Done. I see, thanks!
(I actually realized that set
| |
| 1572 } | |
| 1569 | 1573 |
| 1570 view->AddChildView(vertical_view); | 1574 view->AddChildView(vertical_view); |
| 1571 view->SetBorder(views::Border::CreateEmptyBorder( | |
| 1572 0, 0, views::kRelatedControlSmallVerticalSpacing, 0)); | |
| 1573 | |
| 1574 return view; | 1575 return view; |
| 1575 } | 1576 } |
| 1576 | 1577 |
| 1577 views::View* ProfileChooserView::CreateCurrentProfileView( | 1578 views::View* ProfileChooserView::CreateCurrentProfileView( |
| 1578 const AvatarMenu::Item& avatar_item, | 1579 const AvatarMenu::Item& avatar_item, |
| 1579 bool is_guest) { | 1580 bool is_guest) { |
| 1580 views::View* view = new views::View(); | 1581 views::View* view = new views::View(); |
| 1581 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; | 1582 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; |
| 1582 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); | 1583 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); |
| 1583 layout->SetInsets(views::kButtonVEdgeMarginNew, | 1584 layout->SetInsets(views::kButtonVEdgeMarginNew, |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2303 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2304 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2304 IncognitoModePrefs::DISABLED; | 2305 IncognitoModePrefs::DISABLED; |
| 2305 return incognito_available && !browser_->profile()->IsGuestSession(); | 2306 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 2306 } | 2307 } |
| 2307 | 2308 |
| 2308 void ProfileChooserView::PostActionPerformed( | 2309 void ProfileChooserView::PostActionPerformed( |
| 2309 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2310 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 2310 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2311 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 2311 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2312 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 2312 } | 2313 } |
| OLD | NEW |