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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 308433002: Desktop Menu UMA for Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename variables; subViews to access profileChooserController for UMA Created 6 years, 6 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/lifetime/application_lifetime.h" 15 #include "chrome/browser/lifetime/application_lifetime.h"
16 #include "chrome/browser/profiles/avatar_menu.h" 16 #include "chrome/browser/profiles/avatar_menu.h"
17 #include "chrome/browser/profiles/avatar_menu_observer.h" 17 #include "chrome/browser/profiles/avatar_menu_observer.h"
18 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 18 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
19 #include "chrome/browser/profiles/profile_info_cache.h" 19 #include "chrome/browser/profiles/profile_info_cache.h"
20 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/profiles/profile_metrics.h" 21 #include "chrome/browser/profiles/profile_metrics.h"
22 #include "chrome/browser/profiles/profile_window.h" 22 #include "chrome/browser/profiles/profile_window.h"
23 #include "chrome/browser/profiles/profiles_state.h" 23 #include "chrome/browser/profiles/profiles_state.h"
24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
25 #include "chrome/browser/signin/signin_header_helper.h"
25 #include "chrome/browser/signin/signin_manager_factory.h" 26 #include "chrome/browser/signin/signin_manager_factory.h"
26 #include "chrome/browser/signin/signin_promo.h" 27 #include "chrome/browser/signin/signin_promo.h"
27 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_commands.h" 29 #include "chrome/browser/ui/browser_commands.h"
29 #include "chrome/browser/ui/browser_dialogs.h" 30 #include "chrome/browser/ui/browser_dialogs.h"
30 #include "chrome/browser/ui/browser_window.h" 31 #include "chrome/browser/ui/browser_window.h"
31 #include "chrome/browser/ui/chrome_pages.h" 32 #include "chrome/browser/ui/chrome_pages.h"
32 #include "chrome/browser/ui/chrome_style.h" 33 #include "chrome/browser/ui/chrome_style.h"
33 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" 34 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h"
34 #import "chrome/browser/ui/cocoa/info_bubble_view.h" 35 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 357 }
357 @end 358 @end
358 359
359 // A custom image control that shows a "Change" button when moused over. 360 // A custom image control that shows a "Change" button when moused over.
360 @interface EditableProfilePhoto : NSImageView { 361 @interface EditableProfilePhoto : NSImageView {
361 @private 362 @private
362 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController. 363 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController.
363 base::scoped_nsobject<TransparentBackgroundButton> changePhotoButton_; 364 base::scoped_nsobject<TransparentBackgroundButton> changePhotoButton_;
364 // Used to display the "Change" button on hover. 365 // Used to display the "Change" button on hover.
365 ui::ScopedCrTrackingArea trackingArea_; 366 ui::ScopedCrTrackingArea trackingArea_;
367 ProfileChooserController* controller_;
366 } 368 }
367 369
368 - (id)initWithFrame:(NSRect)frameRect 370 - (id)initWithFrame:(NSRect)frameRect
369 avatarMenu:(AvatarMenu*)avatarMenu 371 avatarMenu:(AvatarMenu*)avatarMenu
370 profileIcon:(const gfx::Image&)profileIcon 372 profileIcon:(const gfx::Image&)profileIcon
371 editingAllowed:(BOOL)editingAllowed; 373 editingAllowed:(BOOL)editingAllowed
374 withController:(ProfileChooserController*)controller;
372 375
373 // Called when the "Change" button is clicked. 376 // Called when the "Change" button is clicked.
374 - (void)editPhoto:(id)sender; 377 - (void)editPhoto:(id)sender;
375 378
376 // When hovering over the profile photo, show the "Change" button. 379 // When hovering over the profile photo, show the "Change" button.
377 - (void)mouseEntered:(NSEvent*)event; 380 - (void)mouseEntered:(NSEvent*)event;
378 381
379 // When hovering away from the profile photo, hide the "Change" button. 382 // When hovering away from the profile photo, hide the "Change" button.
380 - (void)mouseExited:(NSEvent*)event; 383 - (void)mouseExited:(NSEvent*)event;
381 @end 384 @end
382 385
383 @interface EditableProfilePhoto (Private) 386 @interface EditableProfilePhoto (Private)
384 // Create the "Change" avatar photo button. 387 // Create the "Change" avatar photo button.
385 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect; 388 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect;
386 @end 389 @end
387 390
388 @implementation EditableProfilePhoto 391 @implementation EditableProfilePhoto
389 - (id)initWithFrame:(NSRect)frameRect 392 - (id)initWithFrame:(NSRect)frameRect
390 avatarMenu:(AvatarMenu*)avatarMenu 393 avatarMenu:(AvatarMenu*)avatarMenu
391 profileIcon:(const gfx::Image&)profileIcon 394 profileIcon:(const gfx::Image&)profileIcon
392 editingAllowed:(BOOL)editingAllowed { 395 editingAllowed:(BOOL)editingAllowed
396 withController:(ProfileChooserController*)controller {
393 if ((self = [super initWithFrame:frameRect])) { 397 if ((self = [super initWithFrame:frameRect])) {
394 avatarMenu_ = avatarMenu; 398 avatarMenu_ = avatarMenu;
399 controller_ = controller;
395 [self setImage:CreateProfileImage( 400 [self setImage:CreateProfileImage(
396 profileIcon, kLargeImageSide).ToNSImage()]; 401 profileIcon, kLargeImageSide).ToNSImage()];
397 402
398 // Add a tracking area so that we can show/hide the button when hovering. 403 // Add a tracking area so that we can show/hide the button when hovering.
399 trackingArea_.reset([[CrTrackingArea alloc] 404 trackingArea_.reset([[CrTrackingArea alloc]
400 initWithRect:[self bounds] 405 initWithRect:[self bounds]
401 options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways 406 options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways
402 owner:self 407 owner:self
403 userInfo:nil]); 408 userInfo:nil]);
404 [self addTrackingArea:trackingArea_.get()]; 409 [self addTrackingArea:trackingArea_.get()];
(...skipping 18 matching lines...) Expand all
423 [path addClip]; 428 [path addClip];
424 [self.image drawAtPoint:bounds.origin 429 [self.image drawAtPoint:bounds.origin
425 fromRect:bounds 430 fromRect:bounds
426 operation:NSCompositeSourceOver 431 operation:NSCompositeSourceOver
427 fraction:1.0]; 432 fraction:1.0];
428 433
429 } 434 }
430 435
431 - (void)editPhoto:(id)sender { 436 - (void)editPhoto:(id)sender {
432 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); 437 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex());
438 [controller_
439 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE];
433 } 440 }
434 441
435 - (void)mouseEntered:(NSEvent*)event { 442 - (void)mouseEntered:(NSEvent*)event {
436 [changePhotoButton_ setHidden:NO]; 443 [changePhotoButton_ setHidden:NO];
437 } 444 }
438 445
439 - (void)mouseExited:(NSEvent*)event { 446 - (void)mouseExited:(NSEvent*)event {
440 [changePhotoButton_ setHidden:YES]; 447 [changePhotoButton_ setHidden:YES];
441 } 448 }
442 449
443 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect { 450 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect {
444 TransparentBackgroundButton* button = 451 TransparentBackgroundButton* button =
445 [[TransparentBackgroundButton alloc] initWithFrame:rect]; 452 [[TransparentBackgroundButton alloc] initWithFrame:rect];
446 [button setImage:ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( 453 [button setImage:ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
447 IDR_ICON_PROFILES_EDIT_CAMERA).AsNSImage()]; 454 IDR_ICON_PROFILES_EDIT_CAMERA).AsNSImage()];
448 [button setImagePosition:NSImageOnly]; 455 [button setImagePosition:NSImageOnly];
449 [button setTarget:self]; 456 [button setTarget:self];
450 [button setAction:@selector(editPhoto:)]; 457 [button setAction:@selector(editPhoto:)];
451 return button; 458 return button;
452 } 459 }
453 @end 460 @end
454 461
455 // A custom text control that turns into a textfield for editing when clicked. 462 // A custom text control that turns into a textfield for editing when clicked.
456 @interface EditableProfileNameButton : HoverImageButton<NSTextFieldDelegate> { 463 @interface EditableProfileNameButton : HoverImageButton<NSTextFieldDelegate> {
457 @private 464 @private
458 base::scoped_nsobject<NSTextField> profileNameTextField_; 465 base::scoped_nsobject<NSTextField> profileNameTextField_;
459 Profile* profile_; // Weak. 466 Profile* profile_; // Weak.
467 ProfileChooserController* controller_;
460 } 468 }
461 469
462 - (id)initWithFrame:(NSRect)frameRect 470 - (id)initWithFrame:(NSRect)frameRect
463 profile:(Profile*)profile 471 profile:(Profile*)profile
464 profileName:(NSString*)profileName 472 profileName:(NSString*)profileName
465 editingAllowed:(BOOL)editingAllowed; 473 editingAllowed:(BOOL)editingAllowed
474 withController:(ProfileChooserController*)controller;
466 475
467 // Called when the button is clicked. 476 // Called when the button is clicked.
468 - (void)showEditableView:(id)sender; 477 - (void)showEditableView:(id)sender;
469 478
470 // Called when the user presses "Enter" in the textfield. 479 // Called when the user presses "Enter" in the textfield.
471 - (void)controlTextDidEndEditing:(NSNotification *)obj; 480 - (void)controlTextDidEndEditing:(NSNotification *)obj;
472 @end 481 @end
473 482
474 @implementation EditableProfileNameButton 483 @implementation EditableProfileNameButton
475 - (id)initWithFrame:(NSRect)frameRect 484 - (id)initWithFrame:(NSRect)frameRect
476 profile:(Profile*)profile 485 profile:(Profile*)profile
477 profileName:(NSString*)profileName 486 profileName:(NSString*)profileName
478 editingAllowed:(BOOL)editingAllowed { 487 editingAllowed:(BOOL)editingAllowed
488 withController:(ProfileChooserController*)controller {
479 if ((self = [super initWithFrame:frameRect])) { 489 if ((self = [super initWithFrame:frameRect])) {
480 profile_ = profile; 490 profile_ = profile;
491 controller_ = controller;
481 492
482 [self setBordered:NO]; 493 [self setBordered:NO];
483 [self setFont:[NSFont labelFontOfSize:kTitleFontSize]]; 494 [self setFont:[NSFont labelFontOfSize:kTitleFontSize]];
484 [self setAlignment:NSCenterTextAlignment]; 495 [self setAlignment:NSCenterTextAlignment];
485 [[self cell] setLineBreakMode:NSLineBreakByTruncatingTail]; 496 [[self cell] setLineBreakMode:NSLineBreakByTruncatingTail];
486 [self setTitle:profileName]; 497 [self setTitle:profileName];
487 498
488 if (editingAllowed) { 499 if (editingAllowed) {
489 // Show an "edit" pencil icon when hovering over. In the default state, 500 // Show an "edit" pencil icon when hovering over. In the default state,
490 // we need to create an empty placeholder of the correct size, so that 501 // we need to create an empty placeholder of the correct size, so that
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return self; 537 return self;
527 } 538 }
528 539
529 // NSTextField objects send an NSNotification to a delegate if 540 // NSTextField objects send an NSNotification to a delegate if
530 // it implements this method: 541 // it implements this method:
531 - (void)controlTextDidEndEditing:(NSNotification *)obj { 542 - (void)controlTextDidEndEditing:(NSNotification *)obj {
532 NSString* text = [profileNameTextField_ stringValue]; 543 NSString* text = [profileNameTextField_ stringValue];
533 // Empty profile names are not allowed, and are treated as a cancel. 544 // Empty profile names are not allowed, and are treated as a cancel.
534 if ([text length] > 0) { 545 if ([text length] > 0) {
535 profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text)); 546 profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text));
547 [controller_
548 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME];
536 [self setTitle:text]; 549 [self setTitle:text];
537 } 550 }
538 [profileNameTextField_ setHidden:YES]; 551 [profileNameTextField_ setHidden:YES];
539 [profileNameTextField_ resignFirstResponder]; 552 [profileNameTextField_ resignFirstResponder];
540 } 553 }
541 554
542 - (void)showEditableView:(id)sender { 555 - (void)showEditableView:(id)sender {
543 [profileNameTextField_ setHidden:NO]; 556 [profileNameTextField_ setHidden:NO];
544 [profileNameTextField_ becomeFirstResponder]; 557 [profileNameTextField_ becomeFirstResponder];
545 } 558 }
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 // |frameOrigin|. 743 // |frameOrigin|.
731 - (NSButton*)linkButtonWithTitle:(NSString*)title 744 - (NSButton*)linkButtonWithTitle:(NSString*)title
732 frameOrigin:(NSPoint)frameOrigin 745 frameOrigin:(NSPoint)frameOrigin
733 action:(SEL)action; 746 action:(SEL)action;
734 747
735 // Creates an email account button with |title| and a remove icon. |tag| 748 // Creates an email account button with |title| and a remove icon. |tag|
736 // indicates which account the button refers to. 749 // indicates which account the button refers to.
737 - (NSButton*)accountButtonWithRect:(NSRect)rect 750 - (NSButton*)accountButtonWithRect:(NSRect)rect
738 title:(const std::string&)title 751 title:(const std::string&)title
739 tag:(int)tag; 752 tag:(int)tag;
740
741 @end 753 @end
742 754
743 @implementation ProfileChooserController 755 @implementation ProfileChooserController
744 - (profiles::BubbleViewMode) viewMode { 756 - (profiles::BubbleViewMode) viewMode {
745 return viewMode_; 757 return viewMode_;
746 } 758 }
747 759
748 - (IBAction)switchToProfile:(id)sender { 760 - (IBAction)switchToProfile:(id)sender {
749 // Check the event flags to see if a new window should be created. 761 // Check the event flags to see if a new window should be created.
750 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( 762 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent(
(...skipping 15 matching lines...) Expand all
766 - (IBAction)showAccountManagement:(id)sender { 778 - (IBAction)showAccountManagement:(id)sender {
767 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 779 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
768 } 780 }
769 781
770 - (IBAction)hideAccountManagement:(id)sender { 782 - (IBAction)hideAccountManagement:(id)sender {
771 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; 783 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
772 } 784 }
773 785
774 - (IBAction)lockProfile:(id)sender { 786 - (IBAction)lockProfile:(id)sender {
775 profiles::LockProfile(browser_->profile()); 787 profiles::LockProfile(browser_->profile());
788 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK];
776 } 789 }
777 790
778 - (IBAction)showInlineSigninPage:(id)sender { 791 - (IBAction)showInlineSigninPage:(id)sender {
779 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN]; 792 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN];
780 } 793 }
781 794
782 - (IBAction)showTabbedSigninPage:(id)sender { 795 - (IBAction)showTabbedSigninPage:(id)sender {
783 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); 796 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU);
784 } 797 }
785 798
786 - (IBAction)addAccount:(id)sender { 799 - (IBAction)addAccount:(id)sender {
787 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT]; 800 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT];
801 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT];
788 } 802 }
789 803
790 - (IBAction)navigateBackFromSigninPage:(id)sender { 804 - (IBAction)navigateBackFromSigninPage:(id)sender {
791 std::string primaryAccount = SigninManagerFactory::GetForProfile( 805 std::string primaryAccount = SigninManagerFactory::GetForProfile(
792 browser_->profile())->GetAuthenticatedUsername(); 806 browser_->profile())->GetAuthenticatedUsername();
793 [self initMenuContentsWithView:primaryAccount.empty() ? 807 [self initMenuContentsWithView:primaryAccount.empty() ?
794 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 808 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
795 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 809 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
796 } 810 }
797 811
(...skipping 11 matching lines...) Expand all
809 accountIdToRemove_ = currentProfileAccounts_[tag]; 823 accountIdToRemove_ = currentProfileAccounts_[tag];
810 } 824 }
811 825
812 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL]; 826 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL];
813 } 827 }
814 828
815 - (IBAction)removeAccount:(id)sender { 829 - (IBAction)removeAccount:(id)sender {
816 DCHECK(!accountIdToRemove_.empty()); 830 DCHECK(!accountIdToRemove_.empty());
817 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( 831 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile(
818 browser_->profile())->RevokeCredentials(accountIdToRemove_); 832 browser_->profile())->RevokeCredentials(accountIdToRemove_);
833 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT];
819 accountIdToRemove_.clear(); 834 accountIdToRemove_.clear();
820 835
821 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 836 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
822 } 837 }
823 838
824 - (IBAction)openTutorialLearnMoreURL:(id)sender { 839 - (IBAction)openTutorialLearnMoreURL:(id)sender {
825 ProfileMetrics::LogProfileUpgradeEnrollment( 840 ProfileMetrics::LogProfileUpgradeEnrollment(
826 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); 841 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE);
827 // TODO(guohui): update |learnMoreUrl| once it is decided. 842 // TODO(guohui): update |learnMoreUrl| once it is decided.
828 const GURL learnMoreUrl("https://support.google.com/chrome/?hl=en#to"); 843 const GURL learnMoreUrl("https://support.google.com/chrome/?hl=en#to");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 - (IBAction)endPreviewAndRelaunch:(id)sender { 883 - (IBAction)endPreviewAndRelaunch:(id)sender {
869 profiles::DisableNewProfileManagementPreview(); 884 profiles::DisableNewProfileManagementPreview();
870 } 885 }
871 886
872 - (void)cleanUpEmbeddedViewContents { 887 - (void)cleanUpEmbeddedViewContents {
873 webContents_.reset(); 888 webContents_.reset();
874 } 889 }
875 890
876 - (id)initWithBrowser:(Browser*)browser 891 - (id)initWithBrowser:(Browser*)browser
877 anchoredAt:(NSPoint)point 892 anchoredAt:(NSPoint)point
878 withMode:(profiles::BubbleViewMode)mode { 893 withMode:(profiles::BubbleViewMode)mode
894 withServiceType:(signin::GAIAServiceType)serviceType {
879 base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc] 895 base::scoped_nsobject<InfoBubbleWindow> window([[InfoBubbleWindow alloc]
880 initWithContentRect:ui::kWindowSizeDeterminedLater 896 initWithContentRect:ui::kWindowSizeDeterminedLater
881 styleMask:NSBorderlessWindowMask 897 styleMask:NSBorderlessWindowMask
882 backing:NSBackingStoreBuffered 898 backing:NSBackingStoreBuffered
883 defer:NO]); 899 defer:NO]);
884 900
885 if ((self = [super initWithWindow:window 901 if ((self = [super initWithWindow:window
886 parentWindow:browser->window()->GetNativeWindow() 902 parentWindow:browser->window()->GetNativeWindow()
887 anchoredAt:point])) { 903 anchoredAt:point])) {
888 browser_ = browser; 904 browser_ = browser;
889 viewMode_ = mode; 905 viewMode_ = mode;
890 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; 906 tutorialMode_ = profiles::TUTORIAL_MODE_NONE;
891 observer_.reset(new ActiveProfileObserverBridge(self, browser_)); 907 observer_.reset(new ActiveProfileObserverBridge(self, browser_));
908 serviceType_ = serviceType;
892 909
893 avatarMenu_.reset(new AvatarMenu( 910 avatarMenu_.reset(new AvatarMenu(
894 &g_browser_process->profile_manager()->GetProfileInfoCache(), 911 &g_browser_process->profile_manager()->GetProfileInfoCache(),
895 observer_.get(), 912 observer_.get(),
896 browser_)); 913 browser_));
897 avatarMenu_->RebuildMenu(); 914 avatarMenu_->RebuildMenu();
898 915
899 // Guest profiles do not have a token service. 916 // Guest profiles do not have a token service.
900 isGuestSession_ = browser_->profile()->IsGuestSession(); 917 isGuestSession_ = browser_->profile()->IsGuestSession();
901 918
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 if (!switches::IsNewProfileManagement() && 1041 if (!switches::IsNewProfileManagement() &&
1025 tutorialMode_ != lastTutorialMode) { 1042 tutorialMode_ != lastTutorialMode) {
1026 ProfileMetrics::LogProfileUpgradeEnrollment( 1043 ProfileMetrics::LogProfileUpgradeEnrollment(
1027 ProfileMetrics::PROFILE_ENROLLMENT_SHOW_PREVIEW_PROMO); 1044 ProfileMetrics::PROFILE_ENROLLMENT_SHOW_PREVIEW_PROMO);
1028 } 1045 }
1029 } else { 1046 } else {
1030 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; 1047 tutorialMode_ = profiles::TUTORIAL_MODE_NONE;
1031 } 1048 }
1032 1049
1033 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; 1050 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)];
1034 return container.autorelease();; 1051 return container.autorelease();
1035 } 1052 }
1036 1053
1037 - (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item { 1054 - (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item {
1038 if (!switches::IsNewProfileManagement()) { 1055 if (!switches::IsNewProfileManagement()) {
1039 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_ENABLE_PREVIEW 1056 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_ENABLE_PREVIEW
1040 titleMessage:IDS_PROFILES_PREVIEW_TUTORIAL_TITLE 1057 titleMessage:IDS_PROFILES_PREVIEW_TUTORIAL_TITLE
1041 contentMessage:IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT 1058 contentMessage:IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT
1042 linkMessage:IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE 1059 linkMessage:IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE
1043 buttonMessage:IDS_PROFILES_TUTORIAL_TRY_BUTTON 1060 buttonMessage:IDS_PROFILES_TUTORIAL_TRY_BUTTON
1044 linkAction:@selector(openTutorialLearnMoreURL:) 1061 linkAction:@selector(openTutorialLearnMoreURL:)
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 // Profile name, centered. 1225 // Profile name, centered.
1209 bool editingAllowed = !isGuestSession_ && !browser_->profile()->IsManaged(); 1226 bool editingAllowed = !isGuestSession_ && !browser_->profile()->IsManaged();
1210 base::scoped_nsobject<EditableProfileNameButton> profileName( 1227 base::scoped_nsobject<EditableProfileNameButton> profileName(
1211 [[EditableProfileNameButton alloc] 1228 [[EditableProfileNameButton alloc]
1212 initWithFrame:NSMakeRect(xOffset, yOffset, 1229 initWithFrame:NSMakeRect(xOffset, yOffset,
1213 availableTextWidth, 1230 availableTextWidth,
1214 kProfileButtonHeight) 1231 kProfileButtonHeight)
1215 profile:browser_->profile() 1232 profile:browser_->profile()
1216 profileName:base::SysUTF16ToNSString( 1233 profileName:base::SysUTF16ToNSString(
1217 profiles::GetAvatarNameForProfile(browser_->profile())) 1234 profiles::GetAvatarNameForProfile(browser_->profile()))
1218 editingAllowed:editingAllowed]); 1235 editingAllowed:editingAllowed
1236 withController:self]);
1219 1237
1220 [container addSubview:profileName]; 1238 [container addSubview:profileName];
1221 yOffset = NSMaxY([profileName frame]); 1239 yOffset = NSMaxY([profileName frame]);
1222 1240
1223 // Profile icon, centered. 1241 // Profile icon, centered.
1224 xOffset = (kFixedMenuWidth - kLargeImageSide) / 2; 1242 xOffset = (kFixedMenuWidth - kLargeImageSide) / 2;
1225 base::scoped_nsobject<EditableProfilePhoto> iconView( 1243 base::scoped_nsobject<EditableProfilePhoto> iconView(
1226 [[EditableProfilePhoto alloc] 1244 [[EditableProfilePhoto alloc]
1227 initWithFrame:NSMakeRect(xOffset, yOffset, 1245 initWithFrame:NSMakeRect(xOffset, yOffset,
1228 kLargeImageSide, kLargeImageSide) 1246 kLargeImageSide, kLargeImageSide)
1229 avatarMenu:avatarMenu_.get() 1247 avatarMenu:avatarMenu_.get()
1230 profileIcon:item.icon 1248 profileIcon:item.icon
1231 editingAllowed:!isGuestSession_]); 1249 editingAllowed:!isGuestSession_
1250 withController:self]);
1232 1251
1233 [container addSubview:iconView]; 1252 [container addSubview:iconView];
1234 yOffset = NSMaxY([iconView frame]); 1253 yOffset = NSMaxY([iconView frame]);
1235 1254
1236 if (switches::IsNewProfileManagementPreviewEnabled()) { 1255 if (switches::IsNewProfileManagementPreviewEnabled()) {
1237 base::scoped_nsobject<HoverImageButton> questionButton( 1256 base::scoped_nsobject<HoverImageButton> questionButton(
1238 [[HoverImageButton alloc] initWithFrame:NSZeroRect]); 1257 [[HoverImageButton alloc] initWithFrame:NSZeroRect]);
1239 [questionButton setBordered:NO]; 1258 [questionButton setBordered:NO];
1240 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1259 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1241 [questionButton setDefaultImage:rb->GetNativeImageNamed( 1260 [questionButton setDefaultImage:rb->GetNativeImageNamed(
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 [deleteButton setPressedImage:rb->GetNativeImageNamed( 1731 [deleteButton setPressedImage:rb->GetNativeImageNamed(
1713 IDR_CLOSE_1_P).ToNSImage()]; 1732 IDR_CLOSE_1_P).ToNSImage()];
1714 [deleteButton setTarget:self]; 1733 [deleteButton setTarget:self];
1715 [deleteButton setAction:@selector(showAccountRemovalView:)]; 1734 [deleteButton setAction:@selector(showAccountRemovalView:)];
1716 [deleteButton setTag:tag]; 1735 [deleteButton setTag:tag];
1717 1736
1718 [button addSubview:deleteButton]; 1737 [button addSubview:deleteButton];
1719 return button.autorelease(); 1738 return button.autorelease();
1720 } 1739 }
1721 1740
1741 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action {
1742 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_);
1743 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE;
1744 }
1745
1722 @end 1746 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698