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

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

Issue 422443008: New avatar menu: Don't show "Go incognito" if incognito is disabled by policy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit 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 | « no previous file | chrome/browser/ui/views/profiles/profile_chooser_view.h » ('j') | 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 #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/prefs/incognito_mode_prefs.h"
16 #include "chrome/browser/profiles/avatar_menu.h" 17 #include "chrome/browser/profiles/avatar_menu.h"
17 #include "chrome/browser/profiles/avatar_menu_observer.h" 18 #include "chrome/browser/profiles/avatar_menu_observer.h"
18 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 19 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
19 #include "chrome/browser/profiles/profile_info_cache.h" 20 #include "chrome/browser/profiles/profile_info_cache.h"
20 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/profiles/profile_metrics.h" 22 #include "chrome/browser/profiles/profile_metrics.h"
22 #include "chrome/browser/profiles/profile_window.h" 23 #include "chrome/browser/profiles/profile_window.h"
23 #include "chrome/browser/profiles/profiles_state.h" 24 #include "chrome/browser/profiles/profiles_state.h"
24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
25 #include "chrome/browser/signin/signin_header_helper.h" 26 #include "chrome/browser/signin/signin_header_helper.h"
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 frameOrigin:(NSPoint)frameOrigin 769 frameOrigin:(NSPoint)frameOrigin
769 action:(SEL)action; 770 action:(SEL)action;
770 771
771 // Creates an email account button with |title| and a remove icon. If 772 // Creates an email account button with |title| and a remove icon. If
772 // |reauthRequired| is true, the button also displays a warning icon. |tag| 773 // |reauthRequired| is true, the button also displays a warning icon. |tag|
773 // indicates which account the button refers to. 774 // indicates which account the button refers to.
774 - (NSButton*)accountButtonWithRect:(NSRect)rect 775 - (NSButton*)accountButtonWithRect:(NSRect)rect
775 title:(const std::string&)title 776 title:(const std::string&)title
776 tag:(int)tag 777 tag:(int)tag
777 reauthRequired:(BOOL)reauthRequired; 778 reauthRequired:(BOOL)reauthRequired;
779
780 - (bool)shouldShowGoIncognito;
778 @end 781 @end
779 782
780 @implementation ProfileChooserController 783 @implementation ProfileChooserController
781 - (profiles::BubbleViewMode) viewMode { 784 - (profiles::BubbleViewMode) viewMode {
782 return viewMode_; 785 return viewMode_;
783 } 786 }
784 787
785 - (IBAction)switchToProfile:(id)sender { 788 - (IBAction)switchToProfile:(id)sender {
786 // Check the event flags to see if a new window should be created. 789 // Check the event flags to see if a new window should be created.
787 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( 790 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent(
788 [NSApp currentEvent]) == NEW_WINDOW; 791 [NSApp currentEvent]) == NEW_WINDOW;
789 avatarMenu_->SwitchToProfile([sender tag], alwaysCreate, 792 avatarMenu_->SwitchToProfile([sender tag], alwaysCreate,
790 ProfileMetrics::SWITCH_PROFILE_ICON); 793 ProfileMetrics::SWITCH_PROFILE_ICON);
791 } 794 }
792 795
793 - (IBAction)showUserManager:(id)sender { 796 - (IBAction)showUserManager:(id)sender {
794 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); 797 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
795 } 798 }
796 799
797 - (IBAction)exitGuest:(id)sender { 800 - (IBAction)exitGuest:(id)sender {
798 DCHECK(browser_->profile()->IsGuestSession()); 801 DCHECK(browser_->profile()->IsGuestSession());
799 [self showUserManager:sender]; 802 [self showUserManager:sender];
800 profiles::CloseGuestProfileWindows(); 803 profiles::CloseGuestProfileWindows();
801 } 804 }
802 805
803 - (IBAction)goIncognito:(id)sender { 806 - (IBAction)goIncognito:(id)sender {
804 DCHECK(!browser_->profile()->IsGuestSession()); 807 DCHECK([self shouldShowGoIncognito]);
805 chrome::NewIncognitoWindow(browser_); 808 chrome::NewIncognitoWindow(browser_);
806 } 809 }
807 810
808 - (IBAction)showAccountManagement:(id)sender { 811 - (IBAction)showAccountManagement:(id)sender {
809 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 812 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
810 } 813 }
811 814
812 - (IBAction)hideAccountManagement:(id)sender { 815 - (IBAction)hideAccountManagement:(id)sender {
813 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; 816 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
814 } 817 }
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 imageResourceId:IDR_ICON_PROFILES_MENU_LOCK 1517 imageResourceId:IDR_ICON_PROFILES_MENU_LOCK
1515 action:@selector(lockProfile:)]; 1518 action:@selector(lockProfile:)];
1516 [container addSubview:lockButton]; 1519 [container addSubview:lockButton];
1517 viewRect.origin.y = NSMaxY([lockButton frame]); 1520 viewRect.origin.y = NSMaxY([lockButton frame]);
1518 1521
1519 NSBox* separator = [self horizontalSeparatorWithFrame:viewRect]; 1522 NSBox* separator = [self horizontalSeparatorWithFrame:viewRect];
1520 [container addSubview:separator]; 1523 [container addSubview:separator];
1521 viewRect.origin.y = NSMaxY([separator frame]); 1524 viewRect.origin.y = NSMaxY([separator frame]);
1522 } 1525 }
1523 1526
1524 if (!isGuestSession_) { 1527 if ([self shouldShowGoIncognito]) {
1525 // TODO(noms): Use the correct incognito icon when it's available. 1528 // TODO(noms): Use the correct incognito icon when it's available.
1526 NSButton* goIncognitoButton = 1529 NSButton* goIncognitoButton =
1527 [self hoverButtonWithRect:viewRect 1530 [self hoverButtonWithRect:viewRect
1528 text:l10n_util::GetNSString( 1531 text:l10n_util::GetNSString(
1529 IDS_PROFILES_GO_INCOGNITO_BUTTON) 1532 IDS_PROFILES_GO_INCOGNITO_BUTTON)
1530 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR 1533 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR
1531 action:@selector(goIncognito:)]; 1534 action:@selector(goIncognito:)];
1532 viewRect.origin.y = NSMaxY([goIncognitoButton frame]); 1535 viewRect.origin.y = NSMaxY([goIncognitoButton frame]);
1533 [container addSubview:goIncognitoButton]; 1536 [container addSubview:goIncognitoButton];
1534 1537
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 } 1934 }
1932 1935
1933 return button.autorelease(); 1936 return button.autorelease();
1934 } 1937 }
1935 1938
1936 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { 1939 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action {
1937 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); 1940 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_);
1938 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; 1941 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE;
1939 } 1942 }
1940 1943
1944 - (bool)shouldShowGoIncognito {
1945 bool incognitoAvailable =
1946 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1947 IncognitoModePrefs::DISABLED;
1948 return incognitoAvailable && !browser_->profile()->IsGuestSession();
1949 }
1950
1941 @end 1951 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/profiles/profile_chooser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698