| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef ASH_SESSION_STATE_DELEGATE_H_ | 5 #ifndef ASH_SESSION_STATE_DELEGATE_H_ |
| 6 #define ASH_SESSION_STATE_DELEGATE_H_ | 6 #define ASH_SESSION_STATE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 | 13 |
| 14 namespace aura { | 14 namespace aura { |
| 15 class Window; | 15 class Window; |
| 16 } // namespace aura | 16 } // namespace aura |
| 17 | 17 |
| 18 namespace content { |
| 19 class BrowserContext; |
| 20 } |
| 21 |
| 18 namespace gfx { | 22 namespace gfx { |
| 19 class ImageSkia; | 23 class ImageSkia; |
| 20 } // namespace gfx | 24 } // namespace gfx |
| 21 | 25 |
| 22 namespace ash { | 26 namespace ash { |
| 23 | 27 |
| 24 class SessionStateObserver; | 28 class SessionStateObserver; |
| 25 | 29 |
| 26 // The index for the multi-profile item to use. The list is always LRU sorted | 30 // The index for the multi-profile item to use. The list is always LRU sorted |
| 27 // So that the index #0 is the currently active user. | 31 // So that the index #0 is the currently active user. |
| 28 typedef int MultiProfileIndex; | 32 typedef int MultiProfileIndex; |
| 29 | 33 |
| 30 // A list of user_id. | 34 // A list of user_id. |
| 31 typedef std::vector<std::string> UserIdList; | 35 typedef std::vector<std::string> UserIdList; |
| 32 | 36 |
| 33 // Delegate for checking and modifying the session state. | 37 // Delegate for checking and modifying the session state. |
| 38 // TODO(oshima): Replace MultiProfileIndex with BrowsreContext, bacause |
| 39 // GetUserXXX are useful for non multi profile scenario in ash_shell. |
| 34 class ASH_EXPORT SessionStateDelegate { | 40 class ASH_EXPORT SessionStateDelegate { |
| 35 public: | 41 public: |
| 36 // Defines the cycle direction for |CycleActiveUser|. | 42 // Defines the cycle direction for |CycleActiveUser|. |
| 37 enum CycleUser { | 43 enum CycleUser { |
| 38 CYCLE_TO_NEXT_USER = 0, // Cycle to the next user. | 44 CYCLE_TO_NEXT_USER = 0, // Cycle to the next user. |
| 39 CYCLE_TO_PREVIOUS_USER, // Cycle to the previous user. | 45 CYCLE_TO_PREVIOUS_USER, // Cycle to the previous user. |
| 40 }; | 46 }; |
| 41 | 47 |
| 42 virtual ~SessionStateDelegate() {}; | 48 virtual ~SessionStateDelegate() {}; |
| 43 | 49 |
| 50 // Returns the browser context for the user given by |index|. |
| 51 virtual content::BrowserContext* GetBrowserContextByIndex( |
| 52 MultiProfileIndex index) = 0; |
| 53 |
| 44 // Returns the maximum possible number of logged in users. | 54 // Returns the maximum possible number of logged in users. |
| 45 virtual int GetMaximumNumberOfLoggedInUsers() const = 0; | 55 virtual int GetMaximumNumberOfLoggedInUsers() const = 0; |
| 46 | 56 |
| 47 // Returns the number of signed in users. If 0 is returned, there is either | 57 // Returns the number of signed in users. If 0 is returned, there is either |
| 48 // no session in progress or no active user. | 58 // no session in progress or no active user. |
| 49 virtual int NumberOfLoggedInUsers() const = 0; | 59 virtual int NumberOfLoggedInUsers() const = 0; |
| 50 | 60 |
| 51 // Returns |true| if the session has been fully started for the active user. | 61 // Returns |true| if the session has been fully started for the active user. |
| 52 // When a user becomes active, the profile and browser UI are not immediately | 62 // When a user becomes active, the profile and browser UI are not immediately |
| 53 // available. Only once this method starts returning |true| is the browser | 63 // available. Only once this method starts returning |true| is the browser |
| (...skipping 30 matching lines...) Expand all Loading... |
| 84 // The display email address might contains some periods in the email name | 94 // The display email address might contains some periods in the email name |
| 85 // as well as capitalized letters. For example: "Foo.Bar@mock.com". | 95 // as well as capitalized letters. For example: "Foo.Bar@mock.com". |
| 86 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. | 96 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. |
| 87 virtual const std::string GetUserEmail(MultiProfileIndex index) const = 0; | 97 virtual const std::string GetUserEmail(MultiProfileIndex index) const = 0; |
| 88 | 98 |
| 89 // Gets the user id (sanitized email address) for the user with the given | 99 // Gets the user id (sanitized email address) for the user with the given |
| 90 // |index|. The function would return something like "foobar@mock.com". | 100 // |index|. The function would return something like "foobar@mock.com". |
| 91 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. | 101 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. |
| 92 virtual const std::string GetUserID(MultiProfileIndex index) const = 0; | 102 virtual const std::string GetUserID(MultiProfileIndex index) const = 0; |
| 93 | 103 |
| 94 // Gets the avatar image for the user with the given |index|. | 104 // Gets the avatar image for the user associated with the |context|. |
| 95 // Note that |index| can at maximum be |NumberOfLoggedInUsers() - 1|. | 105 virtual const gfx::ImageSkia& GetUserImage( |
| 96 virtual const gfx::ImageSkia& GetUserImage(MultiProfileIndex index) const = 0; | 106 content::BrowserContext* context) const = 0; |
| 97 | 107 |
| 98 // Returns a list of all logged in users. | 108 // Whether or not the window's title should show the avatar. |
| 99 virtual void GetLoggedInUsers(UserIdList* users) = 0; | 109 virtual bool ShouldShowAvatar(aura::Window* window) = 0; |
| 100 | 110 |
| 101 // Switches to another active user with |user_id| | 111 // Switches to another active user with |user_id| |
| 102 // (if that user has already signed in). | 112 // (if that user has already signed in). |
| 103 virtual void SwitchActiveUser(const std::string& user_id) = 0; | 113 virtual void SwitchActiveUser(const std::string& user_id) = 0; |
| 104 | 114 |
| 105 // Switches the active user to the next or previous user, with the same | 115 // Switches the active user to the next or previous user, with the same |
| 106 // ordering as GetLoggedInUsers. | 116 // ordering as GetLoggedInUsers. |
| 107 virtual void CycleActiveUser(CycleUser cycle_user) = 0; | 117 virtual void CycleActiveUser(CycleUser cycle_user) = 0; |
| 108 | 118 |
| 109 // Adds or removes sessions state observer. | 119 // Adds or removes sessions state observer. |
| 110 virtual void AddSessionStateObserver(SessionStateObserver* observer) = 0; | 120 virtual void AddSessionStateObserver(SessionStateObserver* observer) = 0; |
| 111 virtual void RemoveSessionStateObserver(SessionStateObserver* observer) = 0; | 121 virtual void RemoveSessionStateObserver(SessionStateObserver* observer) = 0; |
| 112 }; | 122 }; |
| 113 | 123 |
| 114 } // namespace ash | 124 } // namespace ash |
| 115 | 125 |
| 116 #endif // ASH_SESSION_STATE_DELEGATE_H_ | 126 #endif // ASH_SESSION_STATE_DELEGATE_H_ |
| OLD | NEW |