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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_
6 #define CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "components/keyed_service/core/keyed_service.h"
11 #include "components/signin/core/browser/signin_client.h"
12 #include "content/public/browser/render_process_host_observer.h"
17 class ChromeSigninClient : public SigninClient,
19 public content::RenderProcessHostObserver {
21 explicit ChromeSigninClient(Profile* profile);
22 virtual ~ChromeSigninClient();
25 static bool ProfileAllowsSigninCookies(Profile* profile);
26 static bool SettingsAllowSigninCookies(CookieSettings* cookie_settings);
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.
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;
41 // content::RenderProcessHostObserver implementation.
42 virtual void RenderProcessHostDestroyed(content::RenderProcessHost* host)
45 // SigninClient implementation.
46 virtual PrefService* GetPrefs() OVERRIDE;
47 virtual scoped_refptr<TokenWebData> GetDatabase() OVERRIDE;
48 virtual bool CanRevokeCredentials() OVERRIDE;
49 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE;
50 virtual void GoogleSigninSucceeded(const std::string& username,
51 const std::string& password) OVERRIDE;
56 // See SetSigninProcess. Tracks the currently active signin process
57 // by ID, if there is one.
60 // The RenderProcessHosts being observed.
61 std::set<content::RenderProcessHost*> signin_hosts_observed_;
63 DISALLOW_COPY_AND_ASSIGN(ChromeSigninClient);
66 #endif // CHROME_BROWSER_SIGNIN_CHROME_SIGNIN_CLIENT_H_