| 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/signin/core/browser/signin_client.h" | 10 #include "components/signin/core/browser/signin_client.h" |
| 11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "content/public/browser/render_process_host_observer.h" | 13 #include "content/public/browser/render_process_host_observer.h" |
| 14 | 14 |
| 15 class CookieSettings; | 15 class CookieSettings; |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 class ChromeSigninClient : public SigninClient, | 18 class ChromeSigninClient : public SigninClient, |
| 19 public content::NotificationObserver, | 19 public content::NotificationObserver, |
| 20 public content::RenderProcessHostObserver { | 20 public content::RenderProcessHostObserver { |
| 21 public: | 21 public: |
| 22 explicit ChromeSigninClient(Profile* profile); | 22 explicit ChromeSigninClient(Profile* profile); |
| 23 virtual ~ChromeSigninClient(); | 23 ~ChromeSigninClient() override; |
| 24 | 24 |
| 25 // Utility methods. | 25 // Utility methods. |
| 26 static bool ProfileAllowsSigninCookies(Profile* profile); | 26 static bool ProfileAllowsSigninCookies(Profile* profile); |
| 27 static bool SettingsAllowSigninCookies(CookieSettings* cookie_settings); | 27 static bool SettingsAllowSigninCookies(CookieSettings* cookie_settings); |
| 28 | 28 |
| 29 // Tracks the privileged signin process identified by |host_id| so that we | 29 // Tracks the privileged signin process identified by |host_id| so that we |
| 30 // can later ask (via IsSigninProcess) if it is safe to sign the user in from | 30 // can later ask (via IsSigninProcess) if it is safe to sign the user in from |
| 31 // the current context (see OneClickSigninHelper). All of this tracking | 31 // the current context (see OneClickSigninHelper). All of this tracking |
| 32 // state is reset once the renderer process terminates. | 32 // state is reset once the renderer process terminates. |
| 33 // | 33 // |
| 34 // N.B. This is the id returned by RenderProcessHost::GetID(). | 34 // N.B. This is the id returned by RenderProcessHost::GetID(). |
| 35 // TODO(guohui): Eliminate these APIs once the web-based signin flow is | 35 // TODO(guohui): Eliminate these APIs once the web-based signin flow is |
| 36 // replaced by a native flow. crbug.com/347247 | 36 // replaced by a native flow. crbug.com/347247 |
| 37 virtual void SetSigninProcess(int host_id) override; | 37 void SetSigninProcess(int host_id) override; |
| 38 virtual void ClearSigninProcess() override; | 38 void ClearSigninProcess() override; |
| 39 virtual bool IsSigninProcess(int host_id) const override; | 39 bool IsSigninProcess(int host_id) const override; |
| 40 virtual bool HasSigninProcess() const override; | 40 bool HasSigninProcess() const override; |
| 41 | 41 |
| 42 // content::RenderProcessHostObserver implementation. | 42 // content::RenderProcessHostObserver implementation. |
| 43 virtual void RenderProcessHostDestroyed(content::RenderProcessHost* host) | 43 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; |
| 44 override; | |
| 45 | 44 |
| 46 // SigninClient implementation. | 45 // SigninClient implementation. |
| 47 virtual PrefService* GetPrefs() override; | 46 PrefService* GetPrefs() override; |
| 48 virtual scoped_refptr<TokenWebData> GetDatabase() override; | 47 scoped_refptr<TokenWebData> GetDatabase() override; |
| 49 virtual bool CanRevokeCredentials() override; | 48 bool CanRevokeCredentials() override; |
| 50 virtual std::string GetSigninScopedDeviceId() override; | 49 std::string GetSigninScopedDeviceId() override; |
| 51 virtual void OnSignedOut() override; | 50 void OnSignedOut() override; |
| 52 virtual net::URLRequestContextGetter* GetURLRequestContext() override; | 51 net::URLRequestContextGetter* GetURLRequestContext() override; |
| 53 virtual bool ShouldMergeSigninCredentialsIntoCookieJar() override; | 52 bool ShouldMergeSigninCredentialsIntoCookieJar() override; |
| 54 virtual bool IsFirstRun() const override; | 53 bool IsFirstRun() const override; |
| 55 virtual base::Time GetInstallDate() override; | 54 base::Time GetInstallDate() override; |
| 56 | 55 |
| 57 // Returns a string describing the chrome version environment. Version format: | 56 // Returns a string describing the chrome version environment. Version format: |
| 58 // <Build Info> <OS> <Version number> (<Last change>)<channel or "-devel"> | 57 // <Build Info> <OS> <Version number> (<Last change>)<channel or "-devel"> |
| 59 // If version information is unavailable, returns "invalid." | 58 // If version information is unavailable, returns "invalid." |
| 60 virtual std::string GetProductVersion() override; | 59 std::string GetProductVersion() override; |
| 61 virtual scoped_ptr<CookieChangedCallbackList::Subscription> | 60 scoped_ptr<CookieChangedCallbackList::Subscription> AddCookieChangedCallback( |
| 62 AddCookieChangedCallback(const CookieChangedCallback& callback) override; | 61 const CookieChangedCallback& callback) override; |
| 63 virtual void GoogleSigninSucceeded(const std::string& account_id, | 62 void GoogleSigninSucceeded(const std::string& account_id, |
| 64 const std::string& username, | 63 const std::string& username, |
| 65 const std::string& password) override; | 64 const std::string& password) override; |
| 66 | 65 |
| 67 // content::NotificationObserver implementation. | 66 // content::NotificationObserver implementation. |
| 68 virtual void Observe(int type, | 67 void Observe(int type, |
| 69 const content::NotificationSource& source, | 68 const content::NotificationSource& source, |
| 70 const content::NotificationDetails& details) override; | 69 const content::NotificationDetails& details) override; |
| 71 | 70 |
| 72 private: | 71 private: |
| 73 void RegisterForCookieChangedNotification(); | 72 void RegisterForCookieChangedNotification(); |
| 74 void UnregisterForCookieChangedNotification(); | 73 void UnregisterForCookieChangedNotification(); |
| 75 | 74 |
| 76 Profile* profile_; | 75 Profile* profile_; |
| 77 content::NotificationRegistrar registrar_; | 76 content::NotificationRegistrar registrar_; |
| 78 | 77 |
| 79 // The callbacks that will be called when notifications about cookie changes | 78 // The callbacks that will be called when notifications about cookie changes |
| 80 // are received. | 79 // are received. |
| 81 base::CallbackList<void(const net::CanonicalCookie* cookie)> callbacks_; | 80 base::CallbackList<void(const net::CanonicalCookie* cookie)> callbacks_; |
| 82 | 81 |
| 83 // See SetSigninProcess. Tracks the currently active signin process | 82 // See SetSigninProcess. Tracks the currently active signin process |
| 84 // by ID, if there is one. | 83 // by ID, if there is one. |
| 85 int signin_host_id_; | 84 int signin_host_id_; |
| 86 | 85 |
| 87 // The RenderProcessHosts being observed. | 86 // The RenderProcessHosts being observed. |
| 88 std::set<content::RenderProcessHost*> signin_hosts_observed_; | 87 std::set<content::RenderProcessHost*> signin_hosts_observed_; |
| 89 | 88 |
| 90 DISALLOW_COPY_AND_ASSIGN(ChromeSigninClient); | 89 DISALLOW_COPY_AND_ASSIGN(ChromeSigninClient); |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 #endif // CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_ | 92 #endif // CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_ |
| OLD | NEW |