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

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

Issue 1226093005: Give ProfileChooserView signin button focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Override WidgetDelegate::GetInitiallyFocusedView(). Created 5 years, 5 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/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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get()); 501 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get());
502 } 502 }
503 return; 503 return;
504 } 504 }
505 505
506 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser, 506 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser,
507 view_mode, tutorial_mode, manage_accounts_params.service_type); 507 view_mode, tutorial_mode, manage_accounts_params.service_type);
508 views::BubbleDelegateView::CreateBubble(profile_bubble_); 508 views::BubbleDelegateView::CreateBubble(profile_bubble_);
509 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); 509 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_);
510 profile_bubble_->SetAlignment(border_alignment); 510 profile_bubble_->SetAlignment(border_alignment);
511 profile_bubble_->initially_focused_view_ =
msw 2015/07/13 21:37:30 Why is this controlled here? Let ProfileChooserVie
wjmaclean 2015/07/14 12:26:18 Done.
512 (view_mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER)
msw 2015/07/13 21:37:30 I don't think there's a need for this conditional
wjmaclean 2015/07/14 12:26:18 Done.
513 ? profile_bubble_->signin_current_profile_link_
514 : nullptr;
515 profile_bubble_->GetWidget()->set_focus_on_creation(true);
msw 2015/07/13 21:37:30 Why is this needed? The button should be focused o
wjmaclean 2015/07/14 12:26:18 Done.
511 profile_bubble_->GetWidget()->Show(); 516 profile_bubble_->GetWidget()->Show();
512 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 517 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
513 } 518 }
514 519
515 // static 520 // static
516 bool ProfileChooserView::IsShowing() { 521 bool ProfileChooserView::IsShowing() {
517 return profile_bubble_ != NULL; 522 return profile_bubble_ != NULL;
518 } 523 }
519 524
520 // static 525 // static
(...skipping 15 matching lines...) Expand all
536 } 541 }
537 542
538 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 543 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
539 views::BubbleBorder::Arrow arrow, 544 views::BubbleBorder::Arrow arrow,
540 Browser* browser, 545 Browser* browser,
541 profiles::BubbleViewMode view_mode, 546 profiles::BubbleViewMode view_mode,
542 profiles::TutorialMode tutorial_mode, 547 profiles::TutorialMode tutorial_mode,
543 signin::GAIAServiceType service_type) 548 signin::GAIAServiceType service_type)
544 : BubbleDelegateView(anchor_view, arrow), 549 : BubbleDelegateView(anchor_view, arrow),
545 browser_(browser), 550 browser_(browser),
551 initially_focused_view_(nullptr),
546 view_mode_(view_mode), 552 view_mode_(view_mode),
547 tutorial_mode_(tutorial_mode), 553 tutorial_mode_(tutorial_mode),
548 gaia_service_type_(service_type) { 554 gaia_service_type_(service_type) {
549 // Reset the default margins inherited from the BubbleDelegateView. 555 // Reset the default margins inherited from the BubbleDelegateView.
550 // Add a small bottom inset so that the bubble's rounded corners show up. 556 // Add a small bottom inset so that the bubble's rounded corners show up.
551 set_margins(gfx::Insets(0, 0, 1, 0)); 557 set_margins(gfx::Insets(0, 0, 1, 0));
552 set_background(views::Background::CreateSolidBackground( 558 set_background(views::Background::CreateSolidBackground(
553 GetNativeTheme()->GetSystemColor( 559 GetNativeTheme()->GetSystemColor(
554 ui::NativeTheme::kColorId_DialogBackground))); 560 ui::NativeTheme::kColorId_DialogBackground)));
555 ResetView(); 561 ResetView();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 bool ProfileChooserView::AcceleratorPressed( 736 bool ProfileChooserView::AcceleratorPressed(
731 const ui::Accelerator& accelerator) { 737 const ui::Accelerator& accelerator) {
732 if (accelerator.key_code() != ui::VKEY_DOWN && 738 if (accelerator.key_code() != ui::VKEY_DOWN &&
733 accelerator.key_code() != ui::VKEY_UP) 739 accelerator.key_code() != ui::VKEY_UP)
734 return BubbleDelegateView::AcceleratorPressed(accelerator); 740 return BubbleDelegateView::AcceleratorPressed(accelerator);
735 // Move the focus up or down. 741 // Move the focus up or down.
736 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); 742 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN);
737 return true; 743 return true;
738 } 744 }
739 745
746 views::View* ProfileChooserView::GetInitiallyFocusedView() {
747 return initially_focused_view_;
748 }
749
740 bool ProfileChooserView::HandleContextMenu( 750 bool ProfileChooserView::HandleContextMenu(
741 const content::ContextMenuParams& params) { 751 const content::ContextMenuParams& params) {
742 // Suppresses the context menu because some features, such as inspecting 752 // Suppresses the context menu because some features, such as inspecting
743 // elements, are not appropriate in a bubble. 753 // elements, are not appropriate in a bubble.
744 return true; 754 return true;
745 } 755 }
746 756
747 void ProfileChooserView::ButtonPressed(views::Button* sender, 757 void ProfileChooserView::ButtonPressed(views::Button* sender,
748 const ui::Event& event) { 758 const ui::Event& event) {
749 if (sender == users_button_) { 759 if (sender == users_button_) {
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1758 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1749 IncognitoModePrefs::DISABLED; 1759 IncognitoModePrefs::DISABLED;
1750 return incognito_available && !browser_->profile()->IsGuestSession(); 1760 return incognito_available && !browser_->profile()->IsGuestSession();
1751 } 1761 }
1752 1762
1753 void ProfileChooserView::PostActionPerformed( 1763 void ProfileChooserView::PostActionPerformed(
1754 ProfileMetrics::ProfileDesktopMenu action_performed) { 1764 ProfileMetrics::ProfileDesktopMenu action_performed) {
1755 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1765 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1756 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1766 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1757 } 1767 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698