OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "chrome/browser/signin/mutable_profile_oauth2_token_service.h" | 6 #include "chrome/browser/signin/mutable_profile_oauth2_token_service.h" |
7 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 7 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
9 #include "chrome/browser/signin/signin_account_id_helper.h" | 9 #include "chrome/browser/signin/signin_account_id_helper.h" |
10 #include "chrome/browser/signin/signin_manager.h" | 10 #include "chrome/browser/signin/signin_manager.h" |
11 #include "chrome/browser/signin/signin_manager_factory.h" | 11 #include "chrome/browser/signin/signin_manager_factory.h" |
12 #include "chrome/browser/webdata/token_web_data.h" | 12 #include "chrome/browser/webdata/web_data_service_factory.h" |
13 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "components/signin/core/webdata/token_web_data.h" |
14 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
15 #include "google_apis/gaia/gaia_constants.h" | 16 #include "google_apis/gaia/gaia_constants.h" |
16 #include "google_apis/gaia/gaia_urls.h" | 17 #include "google_apis/gaia/gaia_urls.h" |
17 #include "google_apis/gaia/oauth2_token_service_test_util.h" | 18 #include "google_apis/gaia/oauth2_token_service_test_util.h" |
18 #include "net/http/http_status_code.h" | 19 #include "net/http/http_status_code.h" |
19 #include "net/url_request/test_url_fetcher_factory.h" | 20 #include "net/url_request/test_url_fetcher_factory.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 #if defined(OS_MACOSX) | 23 #if defined(OS_MACOSX) |
23 #include "components/webdata/encryptor/encryptor.h" | 24 #include "components/webdata/encryptor/encryptor.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 TestingProfile* profile() { return profile_.get(); } | 70 TestingProfile* profile() { return profile_.get(); } |
70 | 71 |
71 void SetupSigninManager(const std::string& username) { | 72 void SetupSigninManager(const std::string& username) { |
72 SigninManagerFactory::GetForProfile(profile())-> | 73 SigninManagerFactory::GetForProfile(profile())-> |
73 SetAuthenticatedUsername(username); | 74 SetAuthenticatedUsername(username); |
74 } | 75 } |
75 | 76 |
76 void AddAuthTokenManually(const std::string& service, | 77 void AddAuthTokenManually(const std::string& service, |
77 const std::string& value) { | 78 const std::string& value) { |
78 scoped_refptr<TokenWebData> token_web_data = | 79 scoped_refptr<TokenWebData> token_web_data = |
79 TokenWebData::FromBrowserContext(profile()); | 80 WebDataServiceFactory::GetTokenWebDataForProfile( |
| 81 profile(), Profile::EXPLICIT_ACCESS); |
80 if (token_web_data.get()) | 82 if (token_web_data.get()) |
81 token_web_data->SetTokenForService(service, value); | 83 token_web_data->SetTokenForService(service, value); |
82 } | 84 } |
83 | 85 |
84 // OAuth2TokenService::Observer implementation. | 86 // OAuth2TokenService::Observer implementation. |
85 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE { | 87 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE { |
86 ++token_available_count_; | 88 ++token_available_count_; |
87 } | 89 } |
88 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE { | 90 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE { |
89 ++token_revoked_count_; | 91 ++token_revoked_count_; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 "refreshToken"); | 354 "refreshToken"); |
353 ExpectOneTokenAvailableNotification(); | 355 ExpectOneTokenAvailableNotification(); |
354 | 356 |
355 scoped_ptr<OAuth2TokenService::Request> request(oauth2_service_->StartRequest( | 357 scoped_ptr<OAuth2TokenService::Request> request(oauth2_service_->StartRequest( |
356 oauth2_service_->GetPrimaryAccountId(), scope_list, &consumer_)); | 358 oauth2_service_->GetPrimaryAccountId(), scope_list, &consumer_)); |
357 base::RunLoop().RunUntilIdle(); | 359 base::RunLoop().RunUntilIdle(); |
358 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), | 360 EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(), |
359 oauth2_service_->signin_global_error()->GetLastAuthError()); | 361 oauth2_service_->signin_global_error()->GetLastAuthError()); |
360 } | 362 } |
361 | 363 |
OLD | NEW |