1c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 2a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// found in the LICENSE file. 4a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 5c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#ifndef CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_ 6c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#define CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_ 7a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#import <Cocoa/Cocoa.h> 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include <map> 10c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#include <string> 11a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 12a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 1346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "chrome/browser/profiles/profile_metrics.h" 1446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "chrome/browser/signin/signin_header_helper.h" 15cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "chrome/browser/ui/profile_chooser_constants.h" 16a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#import "chrome/browser/ui/cocoa/base_bubble_controller.h" 17a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 18a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class AvatarMenu; 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ActiveProfileObserverBridge; 20a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class Browser; 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ProfileOAuth2TokenService; 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace content { 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class WebContents; 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 27a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// This window controller manages the bubble that displays a "menu" of profiles. 28a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// It is brought open by clicking on the avatar icon in the window frame. 29c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch@interface ProfileChooserController : BaseBubbleController<NSTextViewDelegate> { 30effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch @private 31a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // The menu that contains the data from the backend. 32a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) scoped_ptr<AvatarMenu> avatarMenu_; 33a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // An observer to be notified when the OAuth2 tokens change or the avatar 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // menu model updates for the active profile. 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<ActiveProfileObserverBridge> observer_; 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // The browser that launched the bubble. Not owned. 39a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) Browser* browser_; 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 41c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // The id for the account that the user has requested to remove from the 42c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // current profile. It is set in |showAccountRemovalView| and used in 43010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // |removeAccount|. 44c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch std::string accountIdToRemove_; 45c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Active view mode. 47cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) profiles::BubbleViewMode viewMode_; 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 49010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) // The current tutorial mode. 50cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) profiles::TutorialMode tutorialMode_; 5123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // List of the full, un-elided accounts for the active profile. The keys are 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // generated used to tag the UI buttons, and the values are the original 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // emails displayed by the buttons. 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) std::map<int, std::string> currentProfileAccounts_; 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Web contents used by the inline signin view. 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<content::WebContents> webContents_; 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Whether the bubble is displayed for an active guest profile. 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) BOOL isGuestSession_; 6246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 6346d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // The GAIA service type that caused this menu to open. 6446d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) signin::GAIAServiceType serviceType_; 65a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 66a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 67effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch- (id)initWithBrowser:(Browser*)browser 68effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch anchoredAt:(NSPoint)point 696e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) viewMode:(profiles::BubbleViewMode)viewMode 706e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) tutorialMode:(profiles::TutorialMode)tutorialMode 716e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) serviceType:(signin::GAIAServiceType)GAIAServiceType; 72a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Creates all the subviews of the avatar bubble for |viewToDisplay|. 74cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)- (void)initMenuContentsWithView:(profiles::BubbleViewMode)viewToDisplay; 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Returns the view currently displayed by the bubble. 77cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)- (profiles::BubbleViewMode)viewMode; 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 795f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Sets the tutorial mode of the bubble. 805f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)- (void)setTutorialMode:(profiles::TutorialMode)tutorialMode; 815f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 82a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Switches to a given profile. |sender| is an ProfileChooserItemController. 83a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (IBAction)switchToProfile:(id)sender; 84a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 85a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Shows the User Manager. 86a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (IBAction)showUserManager:(id)sender; 87a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 885c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// Closes all guest browsers and shows the User Manager. 895c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu- (IBAction)exitGuest:(id)sender; 905c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 91a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Shows the account management view. 92a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (IBAction)showAccountManagement:(id)sender; 93a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 940529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// Hides the account management view and shows the default view. 950529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch- (IBAction)hideAccountManagement:(id)sender; 960529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 97a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Locks the active profile. 98a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)- (IBAction)lockProfile:(id)sender; 99a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 1000529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// Shows the inline signin page. 1010529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch- (IBAction)showInlineSigninPage:(id)sender; 1020529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch 1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Adds an account to the active profile. 1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)- (IBAction)addAccount:(id)sender; 1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 106c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// Shows the account removal view to confirm removing the currently selected 107c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// account from the active profile if possible. 108c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch- (IBAction)showAccountRemovalView:(id)sender; 109c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 110f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Shows the account reauthentication view to re-sign in the currently selected 111f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// account from the active profile if possible. 112f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)- (IBAction)showAccountReauthenticationView:(id)sender; 113f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles) 114010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)// Removes the current account |accountIdToRemove_|. 115010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)- (IBAction)removeAccount:(id)sender; 1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Reset the WebContents used by the Gaia embedded view. 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)- (void)cleanUpEmbeddedViewContents; 11946d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 12046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)// Clean-up done after an action was performed in the ProfileChooser. 12146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)- (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action; 122a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)@end 123a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 124a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Testing API ///////////////////////////////////////////////////////////////// 125a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 126a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)@interface ProfileChooserController (ExposedForTesting) 127effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch- (id)initWithBrowser:(Browser*)browser 128effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch anchoredAt:(NSPoint)point 1296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) viewMode:(profiles::BubbleViewMode)viewMode 1306e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) tutorialMode:(profiles::TutorialMode)tutorialMode 1316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) serviceType:(signin::GAIAServiceType)GAIAServiceType; 132a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)@end 133a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 134c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#endif // CHROME_BROWSER_UI_COCOA_PROFILES_PROFILE_CHOOSER_CONTROLLER_H_ 135