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 #include "chrome/browser/ui/auto_login_prompter.h" | 5 #include "chrome/browser/ui/auto_login_prompter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
26 | 26 |
27 using content::BrowserThread; | 27 using content::BrowserThread; |
28 using content::WebContents; | 28 using content::WebContents; |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 bool FetchUsernameThroughSigninManager(Profile* profile, std::string* output) { | 32 bool FetchUsernameThroughSigninManager(Profile* profile, std::string* output) { |
33 // In an incognito window these services are not available. | 33 // In an incognito window these services are not available. |
34 ProfileOAuth2TokenService* token_service = | |
35 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | |
36 if (!token_service || !token_service->RefreshTokenIsAvailable()) | |
37 return false; | |
38 | |
39 SigninManagerBase* signin_manager = | 34 SigninManagerBase* signin_manager = |
40 SigninManagerFactory::GetInstance()->GetForProfile(profile); | 35 SigninManagerFactory::GetInstance()->GetForProfile(profile); |
41 if (!signin_manager) | 36 if (!signin_manager) |
42 return false; | 37 return false; |
43 | 38 |
| 39 ProfileOAuth2TokenService* token_service = |
| 40 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 41 if (!token_service || !token_service->RefreshTokenIsAvailable( |
| 42 token_service->GetPrimaryAccountId())) { |
| 43 return false; |
| 44 } |
| 45 |
44 *output = signin_manager->GetAuthenticatedUsername(); | 46 *output = signin_manager->GetAuthenticatedUsername(); |
45 return true; | 47 return true; |
46 } | 48 } |
47 | 49 |
48 } // namespace | 50 } // namespace |
49 | 51 |
50 AutoLoginPrompter::AutoLoginPrompter(WebContents* web_contents, | 52 AutoLoginPrompter::AutoLoginPrompter(WebContents* web_contents, |
51 const Params& params, | 53 const Params& params, |
52 const GURL& url) | 54 const GURL& url) |
53 : WebContentsObserver(web_contents), | 55 : WebContentsObserver(web_contents), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 return; | 140 return; |
139 | 141 |
140 InfoBarService* infobar_service = | 142 InfoBarService* infobar_service = |
141 InfoBarService::FromWebContents(web_contents()); | 143 InfoBarService::FromWebContents(web_contents()); |
142 // |infobar_service| is NULL for WebContents hosted in WebDialog. | 144 // |infobar_service| is NULL for WebContents hosted in WebDialog. |
143 if (infobar_service) { | 145 if (infobar_service) { |
144 AutoLoginInfoBarDelegate::Create(infobar_service, params_); | 146 AutoLoginInfoBarDelegate::Create(infobar_service, params_); |
145 infobar_shown_ = true; | 147 infobar_shown_ = true; |
146 } | 148 } |
147 } | 149 } |
OLD | NEW |