3fab01cd52a51f14cb4d97561ad841c4cb426aa7
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / browser / profile_chooser_controller.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_PROFILE_CHOOSER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_PROFILE_CHOOSER_CONTROLLER_H_
7
8 #import <Cocoa/Cocoa.h>
9 #include <map>
10
11 #include "base/memory/scoped_ptr.h"
12 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
13
14 class AvatarMenu;
15 class ActiveProfileObserverBridge;
16 class Browser;
17 class ProfileOAuth2TokenService;
18
19 namespace content {
20 class WebContents;
21 }
22
23 // This window controller manages the bubble that displays a "menu" of profiles.
24 // It is brought open by clicking on the avatar icon in the window frame.
25 @interface ProfileChooserController : BaseBubbleController {
26  @private
27   // Different views that can be displayed in the bubble.
28   enum BubbleViewMode {
29     PROFILE_CHOOSER_VIEW,     // Shows a "fast profile switcher" view.
30     ACCOUNT_MANAGEMENT_VIEW,  // Shows a list of accounts for the active user.
31     GAIA_SIGNIN_VIEW,         // Shows a web view for primary sign in.
32     GAIA_ADD_ACCOUNT_VIEW     // Shows a web view for adding secondary accounts.
33   };
34
35   // The menu that contains the data from the backend.
36   scoped_ptr<AvatarMenu> avatarMenu_;
37
38   // An observer to be notified when the OAuth2 tokens change or the avatar
39   // menu model updates for the active profile.
40   scoped_ptr<ActiveProfileObserverBridge> observer_;
41
42   // The browser that launched the bubble. Not owned.
43   Browser* browser_;
44
45   // Active view mode.
46   BubbleViewMode viewMode_;
47
48   // List of the full, un-elided accounts for the active profile. The keys are
49   // generated used to tag the UI buttons, and the values are the original
50   // emails displayed by the buttons.
51   std::map<int, std::string> currentProfileAccounts_;
52
53   // Web contents used by the inline signin view.
54   scoped_ptr<content::WebContents> webContents_;
55
56   // Whether the bubble is displayed for an active guest profile.
57   BOOL isGuestSession_;
58 }
59
60 - (id)initWithBrowser:(Browser*)browser anchoredAt:(NSPoint)point;
61
62 // Creates all the subviews of the avatar bubble for |viewToDisplay|.
63 - (void)initMenuContentsWithView:(BubbleViewMode)viewToDisplay;
64
65 // Returns the view currently displayed by the bubble.
66 - (BubbleViewMode)viewMode;
67
68 // Creates a new profile.
69 - (IBAction)addNewProfile:(id)sender;
70
71 // Switches to a given profile. |sender| is an ProfileChooserItemController.
72 - (IBAction)switchToProfile:(id)sender;
73
74 // Shows the User Manager.
75 - (IBAction)showUserManager:(id)sender;
76
77 // Starts a guest browser window.
78 - (IBAction)switchToGuestProfile:(id)sender;
79
80 // Closes all guest browser windows.
81 - (IBAction)exitGuestProfile:(id)sender;
82
83 // Shows the account management view.
84 - (IBAction)showAccountManagement:(id)sender;
85
86 // Locks the active profile.
87 - (IBAction)lockProfile:(id)sender;
88
89 // Shows the signin page.
90 - (IBAction)showSigninPage:(id)sender;
91
92 // Adds an account to the active profile.
93 - (IBAction)addAccount:(id)sender;
94
95 // Deletes an account from the active profile.
96 - (IBAction)removeAccount:(id)sender;
97
98 // Reset the WebContents used by the Gaia embedded view.
99 - (void)cleanUpEmbeddedViewContents;
100 @end
101
102 // Testing API /////////////////////////////////////////////////////////////////
103
104 @interface ProfileChooserController (ExposedForTesting)
105 - (id)initWithBrowser:(Browser*)browser anchoredAt:(NSPoint)point;
106 @end
107
108 #endif  // CHROME_BROWSER_UI_COCOA_BROWSER_PROFILE_CHOOSER_CONTROLLER_H_