Chromium Code Reviews| 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; | |
|
Roger Tawa OOO till Jul 10th
2013/08/26 21:04:53
Need { and } since condition spans more than one l
fgorski
2013/08/26 23:30:54
Done.
| |
| 44 | |
| 44 *output = signin_manager->GetAuthenticatedUsername(); | 45 *output = signin_manager->GetAuthenticatedUsername(); |
| 45 return true; | 46 return true; |
| 46 } | 47 } |
| 47 | 48 |
| 48 } // namespace | 49 } // namespace |
| 49 | 50 |
| 50 AutoLoginPrompter::AutoLoginPrompter(WebContents* web_contents, | 51 AutoLoginPrompter::AutoLoginPrompter(WebContents* web_contents, |
| 51 const Params& params, | 52 const Params& params, |
| 52 const GURL& url) | 53 const GURL& url) |
| 53 : WebContentsObserver(web_contents), | 54 : WebContentsObserver(web_contents), |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 return; | 139 return; |
| 139 | 140 |
| 140 InfoBarService* infobar_service = | 141 InfoBarService* infobar_service = |
| 141 InfoBarService::FromWebContents(web_contents()); | 142 InfoBarService::FromWebContents(web_contents()); |
| 142 // |infobar_service| is NULL for WebContents hosted in WebDialog. | 143 // |infobar_service| is NULL for WebContents hosted in WebDialog. |
| 143 if (infobar_service) { | 144 if (infobar_service) { |
| 144 AutoLoginInfoBarDelegate::Create(infobar_service, params_); | 145 AutoLoginInfoBarDelegate::Create(infobar_service, params_); |
| 145 infobar_shown_ = true; | 146 infobar_shown_ = true; |
| 146 } | 147 } |
| 147 } | 148 } |
| OLD | NEW |