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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 const ui::Event& event) { | 516 const ui::Event& event) { |
517 // Disable button after clicking so that it doesn't get clicked twice and | 517 // Disable button after clicking so that it doesn't get clicked twice and |
518 // start a second action... which can crash Chrome. But don't disable if it | 518 // start a second action... which can crash Chrome. But don't disable if it |
519 // has no parent (like in tests) because that will also crash. | 519 // has no parent (like in tests) because that will also crash. |
520 if (sender->parent()) | 520 if (sender->parent()) |
521 sender->SetEnabled(false); | 521 sender->SetEnabled(false); |
522 | 522 |
523 if (sender == guest_button_) { | 523 if (sender == guest_button_) { |
524 profiles::SwitchToGuestProfile(browser_->host_desktop_type(), | 524 profiles::SwitchToGuestProfile(browser_->host_desktop_type(), |
525 profiles::ProfileSwitchingDoneCallback()); | 525 profiles::ProfileSwitchingDoneCallback()); |
| 526 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST); |
526 } else if (sender == end_guest_button_) { | 527 } else if (sender == end_guest_button_) { |
527 profiles::CloseGuestProfileWindows(); | 528 profiles::CloseGuestProfileWindows(); |
528 } else if (sender == users_button_) { | 529 } else if (sender == users_button_) { |
529 // Only non-guest users appear in the User Manager. | 530 // Only non-guest users appear in the User Manager. |
530 base::FilePath profile_path; | 531 base::FilePath profile_path; |
531 if (!end_guest_button_) { | 532 if (!end_guest_button_) { |
532 size_t active_index = avatar_menu_->GetActiveProfileIndex(); | 533 size_t active_index = avatar_menu_->GetActiveProfileIndex(); |
533 profile_path = avatar_menu_->GetItemAt(active_index).profile_path; | 534 profile_path = avatar_menu_->GetItemAt(active_index).profile_path; |
534 } | 535 } |
535 chrome::ShowUserManager(profile_path); | 536 chrome::ShowUserManager(profile_path); |
536 } else if (sender == add_user_button_) { | 537 } else if (sender == add_user_button_) { |
537 profiles::CreateAndSwitchToNewProfile( | 538 profiles::CreateAndSwitchToNewProfile( |
538 browser_->host_desktop_type(), | 539 browser_->host_desktop_type(), |
539 profiles::ProfileSwitchingDoneCallback()); | 540 profiles::ProfileSwitchingDoneCallback()); |
| 541 ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_ICON); |
540 } else if (sender == add_account_button_) { | 542 } else if (sender == add_account_button_) { |
541 ShowView(GAIA_ADD_ACCOUNT_VIEW, avatar_menu_.get()); | 543 ShowView(GAIA_ADD_ACCOUNT_VIEW, avatar_menu_.get()); |
542 } else if (sender == current_profile_photo_->change_photo_button()) { | 544 } else if (sender == current_profile_photo_->change_photo_button()) { |
543 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 545 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
544 } else { | 546 } else { |
545 // One of the "other profiles" buttons was pressed. | 547 // One of the "other profiles" buttons was pressed. |
546 ButtonIndexes::const_iterator match = | 548 ButtonIndexes::const_iterator match = |
547 open_other_profile_indexes_map_.find(sender); | 549 open_other_profile_indexes_map_.find(sender); |
548 DCHECK(match != open_other_profile_indexes_map_.end()); | 550 DCHECK(match != open_other_profile_indexes_map_.end()); |
549 avatar_menu_->SwitchToProfile( | 551 avatar_menu_->SwitchToProfile( |
550 match->second, | 552 match->second, |
551 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW); | 553 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW); |
| 554 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_ICON); |
552 } | 555 } |
553 } | 556 } |
554 | 557 |
555 void ProfileChooserView::OnMenuButtonClicked(views::View* source, | 558 void ProfileChooserView::OnMenuButtonClicked(views::View* source, |
556 const gfx::Point& point) { | 559 const gfx::Point& point) { |
557 AccountButtonIndexes::const_iterator match = | 560 AccountButtonIndexes::const_iterator match = |
558 current_profile_accounts_map_.find(source); | 561 current_profile_accounts_map_.find(source); |
559 DCHECK(match != current_profile_accounts_map_.end()); | 562 DCHECK(match != current_profile_accounts_map_.end()); |
560 | 563 |
561 MutableProfileOAuth2TokenService* oauth2_token_service = | 564 MutableProfileOAuth2TokenService* oauth2_token_service = |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 email_button->set_menu_marker( | 839 email_button->set_menu_marker( |
837 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia()); | 840 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia()); |
838 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 841 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
839 } | 842 } |
840 layout->StartRow(1, 0); | 843 layout->StartRow(1, 0); |
841 layout->AddView(email_button); | 844 layout->AddView(email_button); |
842 | 845 |
843 // Save the original email address, as the button text could be elided. | 846 // Save the original email address, as the button text could be elided. |
844 current_profile_accounts_map_[email_button] = account; | 847 current_profile_accounts_map_[email_button] = account; |
845 } | 848 } |
OLD | NEW |