OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_SIGNIN_CHROME_SIGNIN_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_ |
6 #define CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_ | 6 #define CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
11 #include "components/signin/core/browser/signin_client.h" | 11 #include "components/signin/core/browser/signin_client.h" |
| 12 #include "content/public/browser/render_process_host_observer.h" |
12 | 13 |
13 class CookieSettings; | 14 class CookieSettings; |
14 class Profile; | 15 class Profile; |
15 | 16 |
16 class ChromeSigninClient : public SigninClient, public KeyedService { | 17 class ChromeSigninClient : public SigninClient, |
| 18 public KeyedService, |
| 19 public content::RenderProcessHostObserver { |
17 public: | 20 public: |
18 explicit ChromeSigninClient(Profile* profile); | 21 explicit ChromeSigninClient(Profile* profile); |
19 virtual ~ChromeSigninClient(); | 22 virtual ~ChromeSigninClient(); |
20 | 23 |
21 // Utility methods. | 24 // Utility methods. |
22 static bool ProfileAllowsSigninCookies(Profile* profile); | 25 static bool ProfileAllowsSigninCookies(Profile* profile); |
23 static bool SettingsAllowSigninCookies(CookieSettings* cookie_settings); | 26 static bool SettingsAllowSigninCookies(CookieSettings* cookie_settings); |
24 | 27 |
| 28 // Tracks the privileged signin process identified by |host_id| so that we |
| 29 // can later ask (via IsSigninProcess) if it is safe to sign the user in from |
| 30 // the current context (see OneClickSigninHelper). All of this tracking |
| 31 // state is reset once the renderer process terminates. |
| 32 // |
| 33 // N.B. This is the id returned by RenderProcessHost::GetID(). |
| 34 // TODO(guohui): Eliminate these APIs once the web-based signin flow is |
| 35 // replaced by a native flow. crbug.com/347247 |
| 36 void SetSigninProcess(int host_id); |
| 37 void ClearSigninProcess(); |
| 38 bool IsSigninProcess(int host_id) const; |
| 39 bool HasSigninProcess() const; |
| 40 |
| 41 // content::RenderProcessHostObserver implementation. |
| 42 virtual void RenderProcessHostDestroyed(content::RenderProcessHost* host) |
| 43 OVERRIDE; |
| 44 |
25 // SigninClient implementation. | 45 // SigninClient implementation. |
26 virtual PrefService* GetPrefs() OVERRIDE; | 46 virtual PrefService* GetPrefs() OVERRIDE; |
27 virtual scoped_refptr<TokenWebData> GetDatabase() OVERRIDE; | 47 virtual scoped_refptr<TokenWebData> GetDatabase() OVERRIDE; |
28 virtual bool CanRevokeCredentials() OVERRIDE; | 48 virtual bool CanRevokeCredentials() OVERRIDE; |
29 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; | 49 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; |
30 virtual void GoogleSigninSucceeded(const std::string& username, | 50 virtual void GoogleSigninSucceeded(const std::string& username, |
31 const std::string& password) OVERRIDE; | 51 const std::string& password) OVERRIDE; |
32 | 52 |
33 private: | 53 private: |
34 Profile* profile_; | 54 Profile* profile_; |
35 | 55 |
| 56 // See SetSigninProcess. Tracks the currently active signin process |
| 57 // by ID, if there is one. |
| 58 int signin_host_id_; |
| 59 |
| 60 // The RenderProcessHosts being observed. |
| 61 std::set<content::RenderProcessHost*> signin_hosts_observed_; |
| 62 |
36 DISALLOW_COPY_AND_ASSIGN(ChromeSigninClient); | 63 DISALLOW_COPY_AND_ASSIGN(ChromeSigninClient); |
37 }; | 64 }; |
38 | 65 |
39 #endif // CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_ | 66 #endif // CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_ |
OLD | NEW |