| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/string_number_conversions.h" | 5 #include "base/string_number_conversions.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/browser_signin.h" | 8 #include "chrome/browser/browser_signin.h" |
| 9 #include "chrome/browser/extensions/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
| 10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 virtual void RequestSignin(TabContents* tab_contents, | 79 virtual void RequestSignin(TabContents* tab_contents, |
| 80 const string16& preferred_email, | 80 const string16& preferred_email, |
| 81 const string16& message, | 81 const string16& message, |
| 82 SigninDelegate* delegate) { | 82 SigninDelegate* delegate) { |
| 83 if (should_succeed_) { | 83 if (should_succeed_) { |
| 84 // Simulate valid login. | 84 // Simulate valid login. |
| 85 username_ = username_after_login_; | 85 username_ = username_after_login_; |
| 86 delegate->OnLoginSuccess(); | 86 delegate->OnLoginSuccess(); |
| 87 | 87 |
| 88 // Fake a token available notification. | 88 // Fake a token available notification. |
| 89 Profile* profile = tab_contents->profile(); | 89 Profile* profile = tab_contents->profile()->GetOriginalProfile(); |
| 90 if (profile->IsOffTheRecord()) { | |
| 91 profile = g_browser_process->profile_manager()->GetDefaultProfile(); | |
| 92 } | |
| 93 TokenService* token_service = profile->GetTokenService(); | 90 TokenService* token_service = profile->GetTokenService(); |
| 94 token_service->IssueAuthTokenForTest(GaiaConstants::kGaiaService, | 91 token_service->IssueAuthTokenForTest(GaiaConstants::kGaiaService, |
| 95 "new_token"); | 92 "new_token"); |
| 96 } else { | 93 } else { |
| 97 delegate->OnLoginFailure(GoogleServiceAuthError( | 94 delegate->OnLoginFailure(GoogleServiceAuthError( |
| 98 GoogleServiceAuthError::REQUEST_CANCELED)); | 95 GoogleServiceAuthError::REQUEST_CANCELED)); |
| 99 } | 96 } |
| 100 } | 97 } |
| 101 | 98 |
| 102 private: | 99 private: |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 RunLoginTest("browser_login/expect_nonempty.html", | 186 RunLoginTest("browser_login/expect_nonempty.html", |
| 190 "foo@bar.com", false, ""); | 187 "foo@bar.com", false, ""); |
| 191 | 188 |
| 192 RunLoginTest("browser_login/prompt_no_preferred.html", "", true, ""); | 189 RunLoginTest("browser_login/prompt_no_preferred.html", "", true, ""); |
| 193 | 190 |
| 194 RunLoginTest("browser_login/prompt_preferred.html", "", true, "foo@bar.com"); | 191 RunLoginTest("browser_login/prompt_preferred.html", "", true, "foo@bar.com"); |
| 195 | 192 |
| 196 RunLoginTest("browser_login/prompt_login_fails.html", | 193 RunLoginTest("browser_login/prompt_login_fails.html", |
| 197 "", false, "foo@bar.com"); | 194 "", false, "foo@bar.com"); |
| 198 } | 195 } |
| OLD | NEW |