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 11 matching lines...) Expand all Loading... |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
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 #if !defined(OS_ANDROID) |
32 bool FetchUsernameThroughSigninManager(Profile* profile, std::string* output) { | 33 bool FetchUsernameThroughSigninManager(Profile* profile, std::string* output) { |
33 // In an incognito window these services are not available. | 34 // In an incognito window these services are not available. |
34 SigninManagerBase* signin_manager = | 35 SigninManagerBase* signin_manager = |
35 SigninManagerFactory::GetInstance()->GetForProfile(profile); | 36 SigninManagerFactory::GetInstance()->GetForProfile(profile); |
36 if (!signin_manager) | 37 if (!signin_manager) |
37 return false; | 38 return false; |
38 | 39 |
39 ProfileOAuth2TokenService* token_service = | 40 ProfileOAuth2TokenService* token_service = |
40 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 41 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
41 if (!token_service || !token_service->RefreshTokenIsAvailable( | 42 if (!token_service || !token_service->RefreshTokenIsAvailable( |
42 token_service->GetPrimaryAccountId())) { | 43 token_service->GetPrimaryAccountId())) { |
43 return false; | 44 return false; |
44 } | 45 } |
45 | 46 |
46 *output = signin_manager->GetAuthenticatedUsername(); | 47 *output = signin_manager->GetAuthenticatedUsername(); |
47 return true; | 48 return true; |
48 } | 49 } |
| 50 #endif // !defined(OS_ANDROID) |
49 | 51 |
50 } // namespace | 52 } // namespace |
51 | 53 |
52 AutoLoginPrompter::AutoLoginPrompter(WebContents* web_contents, | 54 AutoLoginPrompter::AutoLoginPrompter(WebContents* web_contents, |
53 const Params& params, | 55 const Params& params, |
54 const GURL& url) | 56 const GURL& url) |
55 : WebContentsObserver(web_contents), | 57 : WebContentsObserver(web_contents), |
56 params_(params), | 58 params_(params), |
57 url_(url), | 59 url_(url), |
58 infobar_shown_(false) { | 60 infobar_shown_(false) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return; | 142 return; |
141 | 143 |
142 InfoBarService* infobar_service = | 144 InfoBarService* infobar_service = |
143 InfoBarService::FromWebContents(web_contents()); | 145 InfoBarService::FromWebContents(web_contents()); |
144 // |infobar_service| is NULL for WebContents hosted in WebDialog. | 146 // |infobar_service| is NULL for WebContents hosted in WebDialog. |
145 if (infobar_service) { | 147 if (infobar_service) { |
146 AutoLoginInfoBarDelegate::Create(infobar_service, params_); | 148 AutoLoginInfoBarDelegate::Create(infobar_service, params_); |
147 infobar_shown_ = true; | 149 infobar_shown_ = true; |
148 } | 150 } |
149 } | 151 } |
OLD | NEW |