Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / profiles / profile_chooser_controller.h
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.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_
7
8 #import <Cocoa/Cocoa.h>
9 #include <map>
10 #include <string>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/profiles/profile_metrics.h"
14 #include "chrome/browser/signin/signin_header_helper.h"
15 #include "chrome/browser/ui/profile_chooser_constants.h"
16 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
17
18 class AvatarMenu;
19 class ActiveProfileObserverBridge;
20 class Browser;
21 class ProfileOAuth2TokenService;
22
23 namespace content {
24 class WebContents;
25 }
26 class GaiaWebContentsDelegate;
27
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_;
34
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_;
38
39   // The browser that launched the bubble. Not owned.
40   Browser* browser_;
41
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_;
46
47   // Active view mode.
48   profiles::BubbleViewMode viewMode_;
49
50   // The current tutorial mode.
51   profiles::TutorialMode tutorialMode_;
52
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_;
57
58   // Web contents used by the inline signin view.
59   scoped_ptr<content::WebContents> webContents_;
60   scoped_ptr<GaiaWebContentsDelegate> webContentsDelegate_;
61
62   // Whether the bubble is displayed for an active guest profile.
63   BOOL isGuestSession_;
64
65   // The GAIA service type that caused this menu to open.
66   signin::GAIAServiceType serviceType_;
67 }
68
69 - (id)initWithBrowser:(Browser*)browser
70            anchoredAt:(NSPoint)point
71              viewMode:(profiles::BubbleViewMode)viewMode
72          tutorialMode:(profiles::TutorialMode)tutorialMode
73           serviceType:(signin::GAIAServiceType)GAIAServiceType;
74
75 // Creates all the subviews of the avatar bubble for |viewToDisplay|.
76 - (void)initMenuContentsWithView:(profiles::BubbleViewMode)viewToDisplay;
77
78 // Returns the view currently displayed by the bubble.
79 - (profiles::BubbleViewMode)viewMode;
80
81 // Sets the tutorial mode of the bubble.
82 - (void)setTutorialMode:(profiles::TutorialMode)tutorialMode;
83
84 // Switches to a given profile. |sender| is an ProfileChooserItemController.
85 - (IBAction)switchToProfile:(id)sender;
86
87 // Shows the User Manager.
88 - (IBAction)showUserManager:(id)sender;
89
90 // Closes all guest browsers and shows the User Manager.
91 - (IBAction)exitGuest:(id)sender;
92
93 // Shows the account management view.
94 - (IBAction)showAccountManagement:(id)sender;
95
96 // Hides the account management view and shows the default view.
97 - (IBAction)hideAccountManagement:(id)sender;
98
99 // Locks the active profile.
100 - (IBAction)lockProfile:(id)sender;
101
102 // Shows the inline signin page.
103 - (IBAction)showInlineSigninPage:(id)sender;
104
105 // Adds an account to the active profile.
106 - (IBAction)addAccount:(id)sender;
107
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;
111
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;
115
116 // Removes the current account |accountIdToRemove_|.
117 - (IBAction)removeAccount:(id)sender;
118
119 // Reset the WebContents used by the Gaia embedded view.
120 - (void)cleanUpEmbeddedViewContents;
121
122 // Clean-up done after an action was performed in the ProfileChooser.
123 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action;
124 @end
125
126 // Testing API /////////////////////////////////////////////////////////////////
127
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 @end
135
136 #endif  // CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_