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

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

Issue 476763007: [Win] Add tab and keyboard navigation to the new avatar bubble (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/lifetime/application_lifetime.h" 10 #include "chrome/browser/lifetime/application_lifetime.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 BackgroundColorHoverButton(views::ButtonListener* listener, 134 BackgroundColorHoverButton(views::ButtonListener* listener,
135 const base::string16& text, 135 const base::string16& text,
136 const gfx::ImageSkia& icon) 136 const gfx::ImageSkia& icon)
137 : views::LabelButton(listener, text) { 137 : views::LabelButton(listener, text) {
138 SetImageLabelSpacing(views::kItemLabelSpacing); 138 SetImageLabelSpacing(views::kItemLabelSpacing);
139 SetBorder(views::Border::CreateEmptyBorder( 139 SetBorder(views::Border::CreateEmptyBorder(
140 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew)); 140 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew));
141 SetMinSize(gfx::Size(0, 141 SetMinSize(gfx::Size(0,
142 kButtonHeight + views::kRelatedControlVerticalSpacing)); 142 kButtonHeight + views::kRelatedControlVerticalSpacing));
143 SetImage(STATE_NORMAL, icon); 143 SetImage(STATE_NORMAL, icon);
144 SetFocusable(true);
144 } 145 }
145 146
146 virtual ~BackgroundColorHoverButton() {} 147 virtual ~BackgroundColorHoverButton() {}
147 148
148 private: 149 private:
149 // views::LabelButton: 150 // views::LabelButton:
150 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 151 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
151 if ((state() == STATE_PRESSED) || 152 if ((state() == STATE_PRESSED) ||
152 (state() == STATE_HOVERED) || 153 (state() == STATE_HOVERED) ||
153 HasFocus()) { 154 HasFocus()) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 views::LabelButton::Layout(); 196 views::LabelButton::Layout();
196 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); 197 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER);
197 } 198 }
198 199
199 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); 200 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton);
200 }; 201 };
201 202
202 // EditableProfilePhoto ------------------------------------------------- 203 // EditableProfilePhoto -------------------------------------------------
203 204
204 // A custom Image control that shows a "change" button when moused over. 205 // A custom Image control that shows a "change" button when moused over.
205 class EditableProfilePhoto : public views::ImageView { 206 class EditableProfilePhoto : public views::ImageButton {
206 public: 207 public:
207 EditableProfilePhoto(views::ButtonListener* listener, 208 EditableProfilePhoto(views::ButtonListener* listener,
208 const gfx::Image& icon, 209 const gfx::Image& icon,
209 bool is_editing_allowed, 210 bool is_editing_allowed,
210 const gfx::Rect& bounds) 211 const gfx::Rect& bounds)
211 : views::ImageView(), 212 : views::ImageButton(listener),
212 change_photo_button_(NULL) { 213 photo_overlay_(NULL) {
213 gfx::Image image = profiles::GetSizedAvatarIcon( 214 gfx::Image image = profiles::GetSizedAvatarIcon(
214 icon, true, kLargeImageSide, kLargeImageSide); 215 icon, true, kLargeImageSide, kLargeImageSide);
215 SetImage(image.ToImageSkia()); 216 SetImage(views::LabelButton::STATE_NORMAL, image.ToImageSkia());
216 SetBoundsRect(bounds); 217 SetBoundsRect(bounds);
217 218
218 // Calculate the circular mask that will be used to display the photo. 219 // Calculate the circular mask that will be used to display the photo.
219 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), 220 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2),
220 SkIntToScalar(bounds.height() / 2), 221 SkIntToScalar(bounds.height() / 2),
221 SkIntToScalar(bounds.width() / 2)); 222 SkIntToScalar(bounds.width() / 2));
222 223
223 if (!is_editing_allowed) 224 if (!is_editing_allowed) {
225 SetEnabled(false);
224 return; 226 return;
227 }
225 228
229 SetFocusable(true);
226 set_notify_enter_exit_on_child(true); 230 set_notify_enter_exit_on_child(true);
227 231
228 // Button overlay that appears when hovering over the image. 232 // Photo overlay that appears when hovering over the button.
229 change_photo_button_ = new views::LabelButton(listener, base::string16()); 233 photo_overlay_ = new views::ImageView();
230 change_photo_button_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
231 change_photo_button_->SetBorder(views::Border::NullBorder());
232 234
233 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); 235 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255);
234 change_photo_button_->set_background( 236 photo_overlay_->set_background(
235 views::Background::CreateSolidBackground(kBackgroundColor)); 237 views::Background::CreateSolidBackground(kBackgroundColor));
236 change_photo_button_->SetImage(views::LabelButton::STATE_NORMAL, 238 photo_overlay_->SetImage(*ui::ResourceBundle::GetSharedInstance().
237 *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 239 GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_CAMERA));
238 IDR_ICON_PROFILES_EDIT_CAMERA));
239 240
240 change_photo_button_->SetSize(bounds.size()); 241 photo_overlay_->SetSize(bounds.size());
241 change_photo_button_->SetVisible(false); 242 photo_overlay_->SetVisible(false);
242 AddChildView(change_photo_button_); 243 AddChildView(photo_overlay_);
243 } 244 }
244 245
245 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 246 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
246 // Display the profile picture as a circle. 247 // Display the profile picture as a circle.
247 canvas->ClipPath(circular_mask_, true); 248 canvas->ClipPath(circular_mask_, true);
248 views::ImageView::OnPaint(canvas); 249 views::ImageButton::OnPaint(canvas);
249 } 250 }
250 251
251 virtual void PaintChildren(gfx::Canvas* canvas, 252 virtual void PaintChildren(gfx::Canvas* canvas,
252 const views::CullSet& cull_set) OVERRIDE { 253 const views::CullSet& cull_set) OVERRIDE {
253 // Display any children (the "change photo" overlay) as a circle. 254 // Display any children (the "change photo" overlay) as a circle.
254 canvas->ClipPath(circular_mask_, true); 255 canvas->ClipPath(circular_mask_, true);
255 View::PaintChildren(canvas, cull_set); 256 View::PaintChildren(canvas, cull_set);
256 } 257 }
257 258
258 views::LabelButton* change_photo_button() { return change_photo_button_; }
259
260 private: 259 private:
261 // views::View: 260 // views::View:
262 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE { 261 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE {
263 if (change_photo_button_) 262 if (photo_overlay_)
264 change_photo_button_->SetVisible(true); 263 photo_overlay_->SetVisible(true);
265 } 264 }
266 265
267 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE { 266 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE {
268 if (change_photo_button_) 267 if (photo_overlay_)
269 change_photo_button_->SetVisible(false); 268 photo_overlay_->SetVisible(false);
269 }
270
271 virtual void OnFocus() OVERRIDE {
272 views::ImageButton::OnFocus();
273 if (photo_overlay_)
274 photo_overlay_->SetVisible(true);
275 }
276
277 virtual void OnBlur() OVERRIDE {
278 views::ImageButton::OnBlur();
279 if (photo_overlay_)
280 photo_overlay_->SetVisible(false);
msw 2014/08/19 22:39:06 Hmm, does this still work as intended with hoverin
noms (inactive) 2014/08/20 16:43:52 No, not excellently. I have removed the focus in m
msw 2014/08/20 19:29:25 What? That seems quite bad... if the user focuses
noms (inactive) 2014/08/20 20:25:32 Oh, no, it would have just cleared the focus on th
270 } 281 }
271 282
272 gfx::Path circular_mask_; 283 gfx::Path circular_mask_;
273 284
274 // Button that is shown when hovering over the image view. Can be NULL if 285 // Image that is shown when hovering over the image button. Can be NULL if
275 // the photo isn't allowed to be edited (e.g. for guest profiles). 286 // the photo isn't allowed to be edited (e.g. for guest profiles).
276 views::LabelButton* change_photo_button_; 287 views::ImageView* photo_overlay_;
277 288
278 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); 289 DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto);
279 }; 290 };
280 291
281 // EditableProfileName ------------------------------------------------- 292 // EditableProfileName -------------------------------------------------
282 293
283 // A custom text control that turns into a textfield for editing when clicked. 294 // A custom text control that turns into a textfield for editing when clicked.
284 class EditableProfileName : public RightAlignedIconLabelButton, 295 class EditableProfileName : public RightAlignedIconLabelButton,
285 public views::ButtonListener { 296 public views::ButtonListener {
286 public: 297 public:
287 EditableProfileName(views::TextfieldController* controller, 298 EditableProfileName(views::TextfieldController* controller,
288 const base::string16& text, 299 const base::string16& text,
289 bool is_editing_allowed) 300 bool is_editing_allowed)
290 : RightAlignedIconLabelButton(this, text), 301 : RightAlignedIconLabelButton(this, text),
291 profile_name_textfield_(NULL) { 302 profile_name_textfield_(NULL) {
292 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 303 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
293 const gfx::FontList& medium_font_list = 304 const gfx::FontList& medium_font_list =
294 rb->GetFontList(ui::ResourceBundle::MediumFont); 305 rb->GetFontList(ui::ResourceBundle::MediumFont);
295 SetFontList(medium_font_list); 306 SetFontList(medium_font_list);
296 SetHorizontalAlignment(gfx::ALIGN_CENTER); 307 SetHorizontalAlignment(gfx::ALIGN_CENTER);
297 308
298 if (!is_editing_allowed) { 309 if (!is_editing_allowed) {
299 SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); 310 SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0));
300 return; 311 return;
301 } 312 }
302 313
314 SetFocusable(true);
303 // Show an "edit" pencil icon when hovering over. In the default state, 315 // Show an "edit" pencil icon when hovering over. In the default state,
304 // we need to create an empty placeholder of the correct size, so that 316 // we need to create an empty placeholder of the correct size, so that
305 // the text doesn't jump around when the hovered icon appears. 317 // the text doesn't jump around when the hovered icon appears.
306 gfx::ImageSkia hover_image = 318 gfx::ImageSkia hover_image =
307 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_HOVER); 319 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_HOVER);
308 SetImage(STATE_NORMAL, CreateSquarePlaceholderImage(hover_image.width())); 320 SetImage(STATE_NORMAL, CreateSquarePlaceholderImage(hover_image.width()));
309 SetImage(STATE_HOVERED, hover_image); 321 SetImage(STATE_HOVERED, hover_image);
310 SetImage(STATE_PRESSED, 322 SetImage(STATE_PRESSED,
311 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_PRESSED)); 323 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_PRESSED));
312 // To center the text, we need to offest it by the width of the icon we 324 // To center the text, we need to offest it by the width of the icon we
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // part of the new profile name typed in the textfield. 367 // part of the new profile name typed in the textfield.
356 return false; 368 return false;
357 } 369 }
358 370
359 virtual void Layout() OVERRIDE { 371 virtual void Layout() OVERRIDE {
360 if (profile_name_textfield_) 372 if (profile_name_textfield_)
361 profile_name_textfield_->SetBounds(0, 0, width(), height()); 373 profile_name_textfield_->SetBounds(0, 0, width(), height());
362 RightAlignedIconLabelButton::Layout(); 374 RightAlignedIconLabelButton::Layout();
363 } 375 }
364 376
377 virtual void OnFocus() OVERRIDE {
378 RightAlignedIconLabelButton::OnBlur();
msw 2014/08/19 22:39:06 nit: I imagine you mean to call OnFocus?
noms (inactive) 2014/08/20 16:43:52 Done.
379 SetState(views::CustomButton::STATE_HOVERED);
msw 2014/08/19 22:39:06 Hmm, does this still work as intended with clickin
noms (inactive) 2014/08/20 16:43:52 The clicking works fine. The only thing that happe
msw 2014/08/20 19:29:25 That sounds fine.
380 }
381
382 virtual void OnBlur() OVERRIDE {
383 RightAlignedIconLabelButton::OnBlur();
384 SetState(views::CustomButton::STATE_NORMAL);
msw 2014/08/19 22:39:05 Hmm, does this still work as intended with hoverin
noms (inactive) 2014/08/20 16:43:52 See above. On 2014/08/19 22:39:05, msw wrote:
385 }
386
365 // Textfield that is shown when editing the profile name. Can be NULL if 387 // Textfield that is shown when editing the profile name. Can be NULL if
366 // the profile name isn't allowed to be edited (e.g. for guest profiles). 388 // the profile name isn't allowed to be edited (e.g. for guest profiles).
367 views::Textfield* profile_name_textfield_; 389 views::Textfield* profile_name_textfield_;
368 390
369 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); 391 DISALLOW_COPY_AND_ASSIGN(EditableProfileName);
370 }; 392 };
371 393
372 // A title card with one back button right aligned and one label center aligned. 394 // A title card with one back button right aligned and one label center aligned.
373 class TitleCard : public views::View { 395 class TitleCard : public views::View {
374 public: 396 public:
375 TitleCard(const base::string16& message, views::ButtonListener* listener, 397 TitleCard(const base::string16& message, views::ButtonListener* listener,
376 views::ImageButton** back_button) { 398 views::ImageButton** back_button) {
377 back_button_ = new views::ImageButton(listener); 399 back_button_ = new views::ImageButton(listener);
378 back_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, 400 back_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
379 views::ImageButton::ALIGN_MIDDLE); 401 views::ImageButton::ALIGN_MIDDLE);
380 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 402 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
381 back_button_->SetImage(views::ImageButton::STATE_NORMAL, 403 back_button_->SetImage(views::ImageButton::STATE_NORMAL,
382 rb->GetImageSkiaNamed(IDR_BACK)); 404 rb->GetImageSkiaNamed(IDR_BACK));
383 back_button_->SetImage(views::ImageButton::STATE_HOVERED, 405 back_button_->SetImage(views::ImageButton::STATE_HOVERED,
384 rb->GetImageSkiaNamed(IDR_BACK_H)); 406 rb->GetImageSkiaNamed(IDR_BACK_H));
385 back_button_->SetImage(views::ImageButton::STATE_PRESSED, 407 back_button_->SetImage(views::ImageButton::STATE_PRESSED,
386 rb->GetImageSkiaNamed(IDR_BACK_P)); 408 rb->GetImageSkiaNamed(IDR_BACK_P));
387 back_button_->SetImage(views::ImageButton::STATE_DISABLED, 409 back_button_->SetImage(views::ImageButton::STATE_DISABLED,
388 rb->GetImageSkiaNamed(IDR_BACK_D)); 410 rb->GetImageSkiaNamed(IDR_BACK_D));
411 back_button_->SetFocusable(true);
389 *back_button = back_button_; 412 *back_button = back_button_;
390 413
391 title_label_ = new views::Label(message); 414 title_label_ = new views::Label(message);
392 title_label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 415 title_label_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
393 const gfx::FontList& medium_font_list = 416 const gfx::FontList& medium_font_list =
394 rb->GetFontList(ui::ResourceBundle::MediumFont); 417 rb->GetFontList(ui::ResourceBundle::MediumFont);
395 title_label_->SetFontList(medium_font_list); 418 title_label_->SetFontList(medium_font_list);
396 419
397 AddChildView(back_button_); 420 AddChildView(back_button_);
398 AddChildView(title_label_); 421 AddChildView(title_label_);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 // If view mode is PROFILE_CHOOSER but there is an auth error, force 585 // If view mode is PROFILE_CHOOSER but there is an auth error, force
563 // ACCOUNT_MANAGEMENT mode. 586 // ACCOUNT_MANAGEMENT mode.
564 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && 587 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER &&
565 HasAuthError(browser_->profile()) && 588 HasAuthError(browser_->profile()) &&
566 switches::IsEnableAccountConsistency() && 589 switches::IsEnableAccountConsistency() &&
567 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). 590 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()).
568 signed_in) { 591 signed_in) {
569 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; 592 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
570 } 593 }
571 594
595 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE));
596 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE));
597
572 ShowView(view_mode_, avatar_menu_.get()); 598 ShowView(view_mode_, avatar_menu_.get());
573 } 599 }
574 600
575 void ProfileChooserView::OnAvatarMenuChanged( 601 void ProfileChooserView::OnAvatarMenuChanged(
576 AvatarMenu* avatar_menu) { 602 AvatarMenu* avatar_menu) {
577 // Do not refresh the avatar menu if the user is on a signin related view. 603 // Do not refresh the avatar menu if the user is on a signin related view.
578 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || 604 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN ||
579 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || 605 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
580 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { 606 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) {
581 return; 607 return;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 } 680 }
655 // Clears tutorial mode for all non-profile-chooser views. 681 // Clears tutorial mode for all non-profile-chooser views.
656 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) 682 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER)
657 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; 683 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
658 684
659 layout->StartRow(1, 0); 685 layout->StartRow(1, 0);
660 layout->AddView(sub_view); 686 layout->AddView(sub_view);
661 Layout(); 687 Layout();
662 if (GetBubbleFrameView()) 688 if (GetBubbleFrameView())
663 SizeToContents(); 689 SizeToContents();
690
691 if (users_button_)
692 users_button_->RequestFocus();
noms (inactive) 2014/08/19 20:15:00 This doesn't do what I think it should do. Ideally
msw 2014/08/19 22:39:06 Try overloading GetInitiallyFocusedView.
noms (inactive) 2014/08/20 16:43:52 We've decided that's not needed right now (and it
664 } 693 }
665 694
666 void ProfileChooserView::WindowClosing() { 695 void ProfileChooserView::WindowClosing() {
667 DCHECK_EQ(profile_bubble_, this); 696 DCHECK_EQ(profile_bubble_, this);
668 profile_bubble_ = NULL; 697 profile_bubble_ = NULL;
669 698
670 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { 699 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) {
671 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 700 LoginUIServiceFactory::GetForProfile(browser_->profile())->
672 SyncConfirmationUIClosed(false /* configure_sync_first */); 701 SyncConfirmationUIClosed(false /* configure_sync_first */);
673 } 702 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 std::string primary_account = 751 std::string primary_account =
723 SigninManagerFactory::GetForProfile(browser_->profile())-> 752 SigninManagerFactory::GetForProfile(browser_->profile())->
724 GetAuthenticatedUsername(); 753 GetAuthenticatedUsername();
725 // The account management view is only available with the 754 // The account management view is only available with the
726 // --enable-account-consistency flag. 755 // --enable-account-consistency flag.
727 bool account_management_available = !primary_account.empty() && 756 bool account_management_available = !primary_account.empty() &&
728 switches::IsEnableAccountConsistency(); 757 switches::IsEnableAccountConsistency();
729 ShowView(account_management_available ? 758 ShowView(account_management_available ?
730 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : 759 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT :
731 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 760 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
732 } else if (current_profile_photo_ && 761 } else if (current_profile_photo_ && sender == current_profile_photo_) {
msw 2014/08/19 22:39:05 nit: Is the |current_profile_photo_| NULL check st
noms (inactive) 2014/08/20 16:43:52 Done.
733 sender == current_profile_photo_->change_photo_button()) {
734 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); 762 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex());
735 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); 763 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE);
736 } else if (sender == signin_current_profile_link_) { 764 } else if (sender == signin_current_profile_link_) {
737 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); 765 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get());
738 } else if (sender == add_person_button_) { 766 } else if (sender == add_person_button_) {
739 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 767 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
740 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); 768 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON);
741 chrome::ShowUserManager(browser_->profile()->GetPath()); 769 chrome::ShowUserManager(browser_->profile()->GetPath());
742 } else if (sender == disconnect_button_) { 770 } else if (sender == disconnect_button_) {
743 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 771 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 return true; 872 return true;
845 873
846 profiles::UpdateProfileName(profile, new_profile_name); 874 profiles::UpdateProfileName(profile, new_profile_name);
847 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); 875 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME);
848 current_profile_name_->ShowReadOnlyView(); 876 current_profile_name_->ShowReadOnlyView();
849 return true; 877 return true;
850 } 878 }
851 return false; 879 return false;
852 } 880 }
853 881
882 bool ProfileChooserView::AcceleratorPressed(
883 const ui::Accelerator& accelerator) {
884 if (accelerator.key_code() != ui::VKEY_DOWN &&
885 accelerator.key_code() != ui::VKEY_UP)
886 return BubbleDelegateView::AcceleratorPressed(accelerator);
887 // Move the focus up or down.
888 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN);
msw 2014/08/19 22:39:06 The old avatar just used up/down to focus the vari
noms (inactive) 2014/08/20 16:43:52 Done. I think I was just being too keen on keeping
889 return true;
890 }
891
854 views::View* ProfileChooserView::CreateProfileChooserView( 892 views::View* ProfileChooserView::CreateProfileChooserView(
855 AvatarMenu* avatar_menu) { 893 AvatarMenu* avatar_menu) {
856 views::View* view = new views::View(); 894 views::View* view = new views::View();
857 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 895 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
858 // Separate items into active and alternatives. 896 // Separate items into active and alternatives.
859 Indexes other_profiles; 897 Indexes other_profiles;
860 views::View* tutorial_view = NULL; 898 views::View* tutorial_view = NULL;
861 views::View* current_profile_view = NULL; 899 views::View* current_profile_view = NULL;
862 views::View* current_profile_accounts = NULL; 900 views::View* current_profile_accounts = NULL;
863 views::View* option_buttons_view = NULL; 901 views::View* option_buttons_view = NULL;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR).ToImageSkia(); 1164 IDR_ICON_PROFILES_ACCOUNT_BUTTON_ERROR).ToImageSkia();
1127 auth_error_email_button_ = 1165 auth_error_email_button_ =
1128 new RightAlignedIconLabelButton(this, avatar_item.sync_state); 1166 new RightAlignedIconLabelButton(this, avatar_item.sync_state);
1129 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); 1167 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL);
1130 auth_error_email_button_->SetBorder(views::Border::NullBorder()); 1168 auth_error_email_button_->SetBorder(views::Border::NullBorder());
1131 auth_error_email_button_->SetImage( 1169 auth_error_email_button_->SetImage(
1132 views::LabelButton::STATE_NORMAL, warning_image); 1170 views::LabelButton::STATE_NORMAL, warning_image);
1133 auth_error_email_button_->SetTextColor( 1171 auth_error_email_button_->SetTextColor(
1134 views::LabelButton::STATE_NORMAL, 1172 views::LabelButton::STATE_NORMAL,
1135 views::Link::GetDefaultEnabledColor()); 1173 views::Link::GetDefaultEnabledColor());
1174 auth_error_email_button_->SetFocusable(true);
1136 layout->AddView(auth_error_email_button_); 1175 layout->AddView(auth_error_email_button_);
1137 } else { 1176 } else {
1138 views::Label* email_label = new views::Label(avatar_item.sync_state); 1177 views::Label* email_label = new views::Label(avatar_item.sync_state);
1139 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); 1178 email_label->SetElideBehavior(gfx::ELIDE_EMAIL);
1140 email_label->SetEnabled(false); 1179 email_label->SetEnabled(false);
1141 layout->AddView(email_label); 1180 layout->AddView(email_label);
1142 } 1181 }
1143 } 1182 }
1144 } else { 1183 } else {
1145 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( 1184 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1625 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1587 IncognitoModePrefs::DISABLED; 1626 IncognitoModePrefs::DISABLED;
1588 return incognito_available && !browser_->profile()->IsGuestSession(); 1627 return incognito_available && !browser_->profile()->IsGuestSession();
1589 } 1628 }
1590 1629
1591 void ProfileChooserView::PostActionPerformed( 1630 void ProfileChooserView::PostActionPerformed(
1592 ProfileMetrics::ProfileDesktopMenu action_performed) { 1631 ProfileMetrics::ProfileDesktopMenu action_performed) {
1593 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1632 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1594 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1633 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1595 } 1634 }
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