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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/observer_list.h" | |
10 #include "chrome/browser/profiles/profile_keyed_service.h" | 11 #include "chrome/browser/profiles/profile_keyed_service.h" |
11 | 12 |
12 class Browser; | 13 class Browser; |
13 | 14 |
14 // The LoginUIService helps track per-profile information for the login UI - | 15 // The LoginUIService helps track per-profile information for the login UI - |
15 // for example, whether there is login UI currently on-screen. | 16 // for example, whether there is login UI currently on-screen. |
16 class LoginUIService : public ProfileKeyedService { | 17 class LoginUIService : public ProfileKeyedService { |
17 public: | 18 public: |
18 // Various UI components implement this API to allow LoginUIService to | 19 // Various UI components implement this API to allow LoginUIService to |
19 // manipulate their associated login UI. | 20 // manipulate their associated login UI. |
20 class LoginUI { | 21 class LoginUI { |
21 public: | 22 public: |
22 // Invoked when the login UI should be brought to the foreground. | 23 // Invoked when the login UI should be brought to the foreground. |
23 virtual void FocusUI() = 0; | 24 virtual void FocusUI() = 0; |
24 | 25 |
25 // Invoked when the login UI should be closed. This can be invoked if the | 26 // Invoked when the login UI should be closed. This can be invoked if the |
26 // user takes an action that should display new login UI. | 27 // user takes an action that should display new login UI. |
27 virtual void CloseUI() = 0; | 28 virtual void CloseUI() = 0; |
28 protected: | 29 protected: |
29 virtual ~LoginUI() {} | 30 virtual ~LoginUI() {} |
30 }; | 31 }; |
31 | 32 |
33 class Observer { | |
James Hawkins
2012/07/10 19:25:22
nit: Document class.
Munjal (Google)
2012/07/10 20:36:24
Done.
| |
34 public: | |
35 virtual ~Observer() { } | |
James Hawkins
2012/07/10 19:25:22
This is an interface, right? The destructor shoul
James Hawkins
2012/07/10 19:25:22
s/{ }/{}/
Munjal (Google)
2012/07/10 20:36:24
Done.
Munjal (Google)
2012/07/10 20:36:24
Done.
| |
36 // Called when a new login UI is shown. | |
37 virtual void OnLoginUIShown(LoginUI* ui) = 0; | |
James Hawkins
2012/07/10 19:25:22
Optional nit: I'd add a newline between methods fo
Munjal (Google)
2012/07/10 20:36:24
Done.
| |
38 // Called when a login UI is closed. | |
39 virtual void OnLoginUIClosed(LoginUI* ui) = 0; | |
40 }; | |
41 | |
32 LoginUIService(); | 42 LoginUIService(); |
33 virtual ~LoginUIService(); | 43 virtual ~LoginUIService(); |
34 | 44 |
35 // Gets the currently active login UI, or null if no login UI is active. | 45 // Gets the currently active login UI, or null if no login UI is active. |
36 LoginUI* current_login_ui() const { | 46 LoginUI* current_login_ui() const { |
37 return ui_; | 47 return ui_; |
38 } | 48 } |
39 | 49 |
50 void AddObserver(Observer* observer); | |
James Hawkins
2012/07/10 19:25:22
nit: Document |observer|.
Munjal (Google)
2012/07/10 20:36:24
Done.
| |
51 void RemoveObserver(Observer* observer); | |
52 | |
40 // Sets the currently active login UI. It is illegal to call this if there is | 53 // Sets the currently active login UI. It is illegal to call this if there is |
41 // already login UI visible. | 54 // already login UI visible. |
42 void SetLoginUI(LoginUI* ui); | 55 void SetLoginUI(LoginUI* ui); |
43 | 56 |
44 // Called when login UI is closed. If the passed UI is the current login UI, | 57 // Called when login UI is closed. If the passed UI is the current login UI, |
45 // sets current_login_ui() to null. | 58 // sets current_login_ui() to null. |
46 void LoginUIClosed(LoginUI* ui); | 59 void LoginUIClosed(LoginUI* ui); |
47 | 60 |
48 // Brings the login UI to the foreground, or if there is no login UI, | 61 // Brings the login UI to the foreground, or if there is no login UI, |
49 // navigates to the login UI page in the given browser. | 62 // navigates to the login UI page in the given browser. |
50 // Virtual for mocking purposes. | 63 // Virtual for mocking purposes. |
51 virtual void ShowLoginUI(Browser* browser); | 64 virtual void ShowLoginUI(Browser* browser); |
52 | 65 |
53 private: | 66 private: |
54 // Weak pointer to the currently active login UI, or null if none. | 67 // Weak pointer to the currently active login UI, or null if none. |
55 LoginUI* ui_; | 68 LoginUI* ui_; |
56 | 69 |
70 ObserverList<Observer> observer_list_; | |
James Hawkins
2012/07/10 19:25:22
nit: Document member variable.
Munjal (Google)
2012/07/10 20:36:24
Done.
| |
71 | |
57 DISALLOW_COPY_AND_ASSIGN(LoginUIService); | 72 DISALLOW_COPY_AND_ASSIGN(LoginUIService); |
58 }; | 73 }; |
59 | 74 |
60 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_SERVICE_H_ | 75 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_LOGIN_UI_SERVICE_H_ |
OLD | NEW |