| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_SERVICE_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_SERVICE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Invoked when the login UI should be brought to the foreground. | 24 // Invoked when the login UI should be brought to the foreground. |
| 25 virtual void FocusUI() = 0; | 25 virtual void FocusUI() = 0; |
| 26 | 26 |
| 27 // Invoked when the login UI should be closed. This can be invoked if the | 27 // Invoked when the login UI should be closed. This can be invoked if the |
| 28 // user takes an action that should display new login UI. | 28 // user takes an action that should display new login UI. |
| 29 virtual void CloseUI() = 0; | 29 virtual void CloseUI() = 0; |
| 30 protected: | 30 protected: |
| 31 virtual ~LoginUI() {} | 31 virtual ~LoginUI() {} |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 // Used when the sync confirmation UI is closed to signify which option was |
| 35 // selected by the user. |
| 36 enum SyncConfirmationUIClosedResults { |
| 37 // Start sync immediately. |
| 38 SYNC_WITH_DEFAULT_SETTINGS, |
| 39 // Show the user the sync settings before starting sync. |
| 40 CONFIGURE_SYNC_FIRST, |
| 41 // The signing process was aborted, don't start sync or show settings. |
| 42 ABORT_SIGNIN, |
| 43 }; |
| 44 |
| 34 // Interface for obervers of LoginUIService. | 45 // Interface for obervers of LoginUIService. |
| 35 class Observer { | 46 class Observer { |
| 36 public: | 47 public: |
| 37 // Called when a new login UI is shown. | 48 // Called when a new login UI is shown. |
| 38 // |ui| The login UI that was just shown. Will never be null. | 49 // |ui| The login UI that was just shown. Will never be null. |
| 39 virtual void OnLoginUIShown(LoginUI* ui) {} | 50 virtual void OnLoginUIShown(LoginUI* ui) {} |
| 40 | 51 |
| 41 // Called when a login UI is closed. | 52 // Called when a login UI is closed. |
| 42 // |ui| The login UI that was just closed; will never be null. | 53 // |ui| The login UI that was just closed; will never be null. |
| 43 virtual void OnLoginUIClosed(LoginUI* ui) {} | 54 virtual void OnLoginUIClosed(LoginUI* ui) {} |
| 44 | 55 |
| 45 // Called when the sync confirmation UI is closed. |configure_sync_first| | 56 // Called when the sync confirmation UI is closed. |results| indicates the |
| 46 // is true if the user has requested to configure the sync settings before | 57 // option chosen by the user in the confirmation UI. |
| 47 // sync starts. | 58 virtual void OnSyncConfirmationUIClosed( |
| 48 virtual void OnSyncConfirmationUIClosed(bool configure_sync_first) {} | 59 SyncConfirmationUIClosedResults results) {} |
| 49 | 60 |
| 50 // Called when a confirmation UI for untrusted signin is shown. | 61 // Called when a confirmation UI for untrusted signin is shown. |
| 51 virtual void OnUntrustedLoginUIShown() {} | 62 virtual void OnUntrustedLoginUIShown() {} |
| 52 | 63 |
| 53 protected: | 64 protected: |
| 54 virtual ~Observer() {} | 65 virtual ~Observer() {} |
| 55 }; | 66 }; |
| 56 | 67 |
| 57 explicit LoginUIService(Profile* profile); | 68 explicit LoginUIService(Profile* profile); |
| 58 ~LoginUIService() override; | 69 ~LoginUIService() override; |
| 59 | 70 |
| 60 // Gets the currently active login UI, or null if no login UI is active. | 71 // Gets the currently active login UI, or null if no login UI is active. |
| 61 LoginUI* current_login_ui() const { | 72 LoginUI* current_login_ui() const { |
| 62 return ui_; | 73 return ui_; |
| 63 } | 74 } |
| 64 | 75 |
| 65 // |observer| The observer to add or remove; cannot be NULL. | 76 // |observer| The observer to add or remove; cannot be NULL. |
| 66 void AddObserver(Observer* observer); | 77 void AddObserver(Observer* observer); |
| 67 void RemoveObserver(Observer* observer); | 78 void RemoveObserver(Observer* observer); |
| 68 | 79 |
| 69 // Sets the currently active login UI. It is illegal to call this if there is | 80 // Sets the currently active login UI. It is illegal to call this if there is |
| 70 // already login UI visible. | 81 // already login UI visible. |
| 71 void SetLoginUI(LoginUI* ui); | 82 void SetLoginUI(LoginUI* ui); |
| 72 | 83 |
| 73 // Called when login UI is closed. If the passed UI is the current login UI, | 84 // Called when login UI is closed. If the passed UI is the current login UI, |
| 74 // sets current_login_ui() to null. | 85 // sets current_login_ui() to null. |
| 75 void LoginUIClosed(LoginUI* ui); | 86 void LoginUIClosed(LoginUI* ui); |
| 76 | 87 |
| 77 // Called when the sync settings confirmation UI is closed. | 88 // Called when the sync settings confirmation UI is closed. |
| 78 void SyncConfirmationUIClosed(bool configure_sync_first); | 89 void SyncConfirmationUIClosed(SyncConfirmationUIClosedResults results); |
| 79 | 90 |
| 80 // Called when a confirmation UI for untrusted signin is shown. | 91 // Called when a confirmation UI for untrusted signin is shown. |
| 81 void UntrustedLoginUIShown(); | 92 void UntrustedLoginUIShown(); |
| 82 | 93 |
| 83 // Delegate to an existing login dialog if one exists. | 94 // Delegate to an existing login dialog if one exists. |
| 84 // If not, we make a new popup dialog window, and set it to | 95 // If not, we make a new popup dialog window, and set it to |
| 85 // chrome://signin to ask the user to sign in to chrome. | 96 // chrome://signin to ask the user to sign in to chrome. |
| 86 void ShowLoginPopup(); | 97 void ShowLoginPopup(); |
| 87 | 98 |
| 88 // Displays login results. | 99 // Displays login results. |
| 89 void DisplayLoginResult(Browser* browser, const base::string16& message); | 100 void DisplayLoginResult(Browser* browser, const base::string16& message); |
| 90 | 101 |
| 91 // Gets the last login result set through |DisplayLoginResult|. | 102 // Gets the last login result set through |DisplayLoginResult|. |
| 92 const base::string16& GetLastLoginResult(); | 103 const base::string16& GetLastLoginResult(); |
| 93 | 104 |
| 94 private: | 105 private: |
| 95 // Weak pointer to the currently active login UI, or null if none. | 106 // Weak pointer to the currently active login UI, or null if none. |
| 96 LoginUI* ui_; | 107 LoginUI* ui_; |
| 97 Profile* profile_; | 108 Profile* profile_; |
| 98 | 109 |
| 99 // List of observers. | 110 // List of observers. |
| 100 base::ObserverList<Observer> observer_list_; | 111 base::ObserverList<Observer> observer_list_; |
| 101 | 112 |
| 102 base::string16 last_login_result_; | 113 base::string16 last_login_result_; |
| 103 | 114 |
| 104 DISALLOW_COPY_AND_ASSIGN(LoginUIService); | 115 DISALLOW_COPY_AND_ASSIGN(LoginUIService); |
| 105 }; | 116 }; |
| 106 | 117 |
| 107 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_SERVICE_H_ | 118 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_SERVICE_H_ |
| OLD | NEW |