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

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

Issue 2832823002: Update avatar button to MD (Closed)
Patch Set: Fix for --force-device-scale-factor, vector icon, review comments Created 3 years, 8 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
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/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/app/vector_icons/vector_icons.h" 10 #include "chrome/app/vector_icons/vector_icons.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "ui/gfx/skia_util.h" 68 #include "ui/gfx/skia_util.h"
69 #include "ui/gfx/text_elider.h" 69 #include "ui/gfx/text_elider.h"
70 #include "ui/native_theme/common_theme.h" 70 #include "ui/native_theme/common_theme.h"
71 #include "ui/native_theme/native_theme.h" 71 #include "ui/native_theme/native_theme.h"
72 #include "ui/vector_icons/vector_icons.h" 72 #include "ui/vector_icons/vector_icons.h"
73 #include "ui/views/controls/button/blue_button.h" 73 #include "ui/views/controls/button/blue_button.h"
74 #include "ui/views/controls/button/image_button.h" 74 #include "ui/views/controls/button/image_button.h"
75 #include "ui/views/controls/button/label_button.h" 75 #include "ui/views/controls/button/label_button.h"
76 #include "ui/views/controls/button/label_button_border.h" 76 #include "ui/views/controls/button/label_button_border.h"
77 #include "ui/views/controls/button/md_text_button.h" 77 #include "ui/views/controls/button/md_text_button.h"
78 #include "ui/views/controls/button/menu_button.h"
79 #include "ui/views/controls/label.h" 78 #include "ui/views/controls/label.h"
80 #include "ui/views/controls/link.h" 79 #include "ui/views/controls/link.h"
81 #include "ui/views/controls/separator.h" 80 #include "ui/views/controls/separator.h"
82 #include "ui/views/controls/styled_label.h" 81 #include "ui/views/controls/styled_label.h"
83 #include "ui/views/controls/webview/webview.h" 82 #include "ui/views/controls/webview/webview.h"
84 #include "ui/views/layout/box_layout.h" 83 #include "ui/views/layout/box_layout.h"
85 #include "ui/views/layout/fill_layout.h" 84 #include "ui/views/layout/fill_layout.h"
86 #include "ui/views/layout/grid_layout.h" 85 #include "ui/views/layout/grid_layout.h"
87 #include "ui/views/layout/layout_constants.h" 86 #include "ui/views/layout/layout_constants.h"
88 #include "ui/views/widget/widget.h" 87 #include "ui/views/widget/widget.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // static 509 // static
511 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; 510 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr;
512 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 511 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
513 512
514 // static 513 // static
515 void ProfileChooserView::ShowBubble( 514 void ProfileChooserView::ShowBubble(
516 profiles::BubbleViewMode view_mode, 515 profiles::BubbleViewMode view_mode,
517 profiles::TutorialMode tutorial_mode, 516 profiles::TutorialMode tutorial_mode,
518 const signin::ManageAccountsParams& manage_accounts_params, 517 const signin::ManageAccountsParams& manage_accounts_params,
519 signin_metrics::AccessPoint access_point, 518 signin_metrics::AccessPoint access_point,
520 views::View* anchor_view, 519 views::MenuButton* calling_button,
521 Browser* browser, 520 Browser* browser,
522 bool is_source_keyboard) { 521 bool is_source_keyboard) {
523 if (IsShowing()) { 522 if (IsShowing()) {
524 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { 523 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) {
525 profile_bubble_->tutorial_mode_ = tutorial_mode; 524 profile_bubble_->tutorial_mode_ = tutorial_mode;
526 profile_bubble_->ShowViewFromMode(view_mode); 525 profile_bubble_->ShowViewFromMode(view_mode);
527 } 526 }
528 return; 527 return;
529 } 528 }
530 529
531 profile_bubble_ = 530 profile_bubble_ =
532 new ProfileChooserView(anchor_view, browser, view_mode, tutorial_mode, 531 new ProfileChooserView(calling_button, browser, view_mode, tutorial_mode,
533 manage_accounts_params.service_type, access_point); 532 manage_accounts_params.service_type, access_point);
534 views::Widget* widget = 533 views::Widget* widget =
535 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_); 534 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_);
536 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 535 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
537 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 536 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
538 widget->Show(); 537 widget->Show();
539 if (is_source_keyboard) 538 if (is_source_keyboard)
540 profile_bubble_->FocusFirstProfileButton(); 539 profile_bubble_->FocusFirstProfileButton();
541 } 540 }
542 541
543 // static 542 // static
544 bool ProfileChooserView::IsShowing() { 543 bool ProfileChooserView::IsShowing() {
545 return profile_bubble_ != NULL; 544 return profile_bubble_ != NULL;
546 } 545 }
547 546
548 // static 547 // static
549 void ProfileChooserView::Hide() { 548 void ProfileChooserView::Hide() {
550 if (IsShowing()) 549 if (IsShowing())
551 profile_bubble_->GetWidget()->Close(); 550 profile_bubble_->GetWidget()->Close();
552 } 551 }
553 552
554 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 553 ProfileChooserView::ProfileChooserView(views::MenuButton* calling_button,
555 Browser* browser, 554 Browser* browser,
556 profiles::BubbleViewMode view_mode, 555 profiles::BubbleViewMode view_mode,
557 profiles::TutorialMode tutorial_mode, 556 profiles::TutorialMode tutorial_mode,
558 signin::GAIAServiceType service_type, 557 signin::GAIAServiceType service_type,
559 signin_metrics::AccessPoint access_point) 558 signin_metrics::AccessPoint access_point)
560 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), 559 : BubbleDialogDelegateView(calling_button, views::BubbleBorder::TOP_RIGHT),
560 calling_button_(calling_button),
561 browser_(browser), 561 browser_(browser),
562 view_mode_(view_mode), 562 view_mode_(view_mode),
563 tutorial_mode_(tutorial_mode), 563 tutorial_mode_(tutorial_mode),
564 gaia_service_type_(service_type), 564 gaia_service_type_(service_type),
565 access_point_(access_point) { 565 access_point_(access_point) {
566 // The sign in webview will be clipped on the bottom corners without these 566 // The sign in webview will be clipped on the bottom corners without these
567 // margins, see related bug <http://crbug.com/593203>. 567 // margins, see related bug <http://crbug.com/593203>.
568 set_margins(gfx::Insets(0, 0, 2, 0)); 568 set_margins(gfx::Insets(0, 0, 2, 0));
569 ResetView(); 569 ResetView();
570 } 570 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; 634 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
635 } 635 }
636 636
637 // The arrow keys can be used to tab between items. 637 // The arrow keys can be used to tab between items.
638 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE)); 638 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE));
639 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE)); 639 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE));
640 640
641 ShowViewFromMode(view_mode_); 641 ShowViewFromMode(view_mode_);
642 } 642 }
643 643
644 // static
645 void ProfileChooserView::MakeCallingButtonPressedIfShowing(
Evan Stade 2017/04/27 01:30:55 it would be easier to review this patch if it didn
emx 2017/04/27 16:30:59 OK, I'm creating a new CL without this.
646 const ui::Event* click_event) {
647 if (ProfileChooserView::IsShowing()) {
648 profile_bubble_->MakeCallingButtonPressed(click_event);
649 }
650 }
651
652 void ProfileChooserView::MakeCallingButtonPressed(
653 const ui::Event* click_event) {
654 // Keep the avatar button "pressed" while the profile chooser is open
655 if (calling_button_) {
656 pressed_lock_.reset(new views::MenuButton::PressedLock(
657 calling_button_, false, ui::LocatedEvent::FromIfValid(click_event)));
658 }
659 }
660
644 void ProfileChooserView::OnNativeThemeChanged( 661 void ProfileChooserView::OnNativeThemeChanged(
645 const ui::NativeTheme* native_theme) { 662 const ui::NativeTheme* native_theme) {
646 views::BubbleDialogDelegateView::OnNativeThemeChanged(native_theme); 663 views::BubbleDialogDelegateView::OnNativeThemeChanged(native_theme);
647 set_background(views::Background::CreateSolidBackground( 664 set_background(views::Background::CreateSolidBackground(
648 GetNativeTheme()->GetSystemColor( 665 GetNativeTheme()->GetSystemColor(
649 ui::NativeTheme::kColorId_DialogBackground))); 666 ui::NativeTheme::kColorId_DialogBackground)));
650 if (auth_error_email_button_) { 667 if (auth_error_email_button_) {
651 auth_error_email_button_->SetTextColor( 668 auth_error_email_button_->SetTextColor(
652 views::LabelButton::STATE_NORMAL, 669 views::LabelButton::STATE_NORMAL,
653 native_theme->GetSystemColor(ui::NativeTheme::kColorId_LinkEnabled)); 670 native_theme->GetSystemColor(ui::NativeTheme::kColorId_LinkEnabled));
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1909 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1893 IncognitoModePrefs::DISABLED; 1910 IncognitoModePrefs::DISABLED;
1894 return incognito_available && !browser_->profile()->IsGuestSession(); 1911 return incognito_available && !browser_->profile()->IsGuestSession();
1895 } 1912 }
1896 1913
1897 void ProfileChooserView::PostActionPerformed( 1914 void ProfileChooserView::PostActionPerformed(
1898 ProfileMetrics::ProfileDesktopMenu action_performed) { 1915 ProfileMetrics::ProfileDesktopMenu action_performed) {
1899 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1916 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1900 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1917 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1901 } 1918 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698