Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / profiles / profile_chooser_controller.h
blob4df0939edeea648b4abe4f33602fc609e6f2afd4
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
9 #include <map>
10 #include <string>
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/profiles/profile_metrics.h"
14 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
15 #include "chrome/browser/ui/profile_chooser_constants.h"
16 #include "components/signin/core/browser/signin_header_helper.h"
18 class AvatarMenu;
19 class ActiveProfileObserverBridge;
20 class Browser;
21 class ProfileOAuth2TokenService;
23 namespace content {
24 class WebContents;
26 class GaiaWebContentsDelegate;
28 // This window controller manages the bubble that displays a "menu" of profiles.
29 // It is brought open by clicking on the avatar icon in the window frame.
30 @interface ProfileChooserController : BaseBubbleController<NSTextViewDelegate> {
31 @private
32 // The menu that contains the data from the backend.
33 scoped_ptr<AvatarMenu> avatarMenu_;
35 // An observer to be notified when the OAuth2 tokens change or the avatar
36 // menu model updates for the active profile.
37 scoped_ptr<ActiveProfileObserverBridge> observer_;
39 // The browser that launched the bubble. Not owned.
40 Browser* browser_;
42 // The id for the account that the user has requested to remove from the
43 // current profile. It is set in |showAccountRemovalView| and used in
44 // |removeAccount|.
45 std::string accountIdToRemove_;
47 // Active view mode.
48 profiles::BubbleViewMode viewMode_;
50 // The current tutorial mode.
51 profiles::TutorialMode tutorialMode_;
53 // List of the full, un-elided accounts for the active profile. The keys are
54 // generated used to tag the UI buttons, and the values are the original
55 // emails displayed by the buttons.
56 std::map<int, std::string> currentProfileAccounts_;
58 // Web contents used by the inline signin view.
59 scoped_ptr<content::WebContents> webContents_;
60 scoped_ptr<GaiaWebContentsDelegate> webContentsDelegate_;
62 // Whether the bubble is displayed for an active guest profile.
63 BOOL isGuestSession_;
65 // The GAIA service type that caused this menu to open.
66 signin::GAIAServiceType serviceType_;
69 - (id)initWithBrowser:(Browser*)browser
70 anchoredAt:(NSPoint)point
71 viewMode:(profiles::BubbleViewMode)viewMode
72 tutorialMode:(profiles::TutorialMode)tutorialMode
73 serviceType:(signin::GAIAServiceType)GAIAServiceType;
75 // Creates all the subviews of the avatar bubble for |viewToDisplay|.
76 - (void)initMenuContentsWithView:(profiles::BubbleViewMode)viewToDisplay;
78 // Returns the view currently displayed by the bubble.
79 - (profiles::BubbleViewMode)viewMode;
81 // Sets the tutorial mode of the bubble.
82 - (void)setTutorialMode:(profiles::TutorialMode)tutorialMode;
84 // Switches to a given profile. |sender| is an ProfileChooserItemController.
85 - (IBAction)switchToProfile:(id)sender;
87 // Shows the User Manager.
88 - (IBAction)showUserManager:(id)sender;
90 // Closes all guest browsers and shows the User Manager.
91 - (IBAction)exitGuest:(id)sender;
93 // Shows the account management view.
94 - (IBAction)showAccountManagement:(id)sender;
96 // Hides the account management view and shows the default view.
97 - (IBAction)hideAccountManagement:(id)sender;
99 // Locks the active profile.
100 - (IBAction)lockProfile:(id)sender;
102 // Shows the inline signin page.
103 - (IBAction)showInlineSigninPage:(id)sender;
105 // Adds an account to the active profile.
106 - (IBAction)addAccount:(id)sender;
108 // Shows the account removal view to confirm removing the currently selected
109 // account from the active profile if possible.
110 - (IBAction)showAccountRemovalView:(id)sender;
112 // Shows the account reauthentication view to re-sign in the currently selected
113 // account from the active profile if possible.
114 - (IBAction)showAccountReauthenticationView:(id)sender;
116 // Removes the current account |accountIdToRemove_|.
117 - (IBAction)removeAccount:(id)sender;
119 // Reset the WebContents used by the Gaia embedded view.
120 - (void)cleanUpEmbeddedViewContents;
122 // Clean-up done after an action was performed in the ProfileChooser.
123 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action;
124 @end
126 // Testing API /////////////////////////////////////////////////////////////////
128 @interface ProfileChooserController (ExposedForTesting)
129 - (id)initWithBrowser:(Browser*)browser
130 anchoredAt:(NSPoint)point
131 viewMode:(profiles::BubbleViewMode)viewMode
132 tutorialMode:(profiles::TutorialMode)tutorialMode
133 serviceType:(signin::GAIAServiceType)GAIAServiceType;
134 - (IBAction)dismissTutorial:(id)sender;
135 @end
137 #endif // CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_