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