Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: chrome/browser/signin/signin_manager_unittest.cc

Issue 192313002: Make ChromeSigninClient a BrowserContextKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/signin/signin_manager_factory.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/signin/signin_manager.h" 5 #include "chrome/browser/signin/signin_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/prefs/testing_pref_service.h" 11 #include "base/prefs/testing_pref_service.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/prefs/browser_prefs.h" 16 #include "chrome/browser/prefs/browser_prefs.h"
17 #include "chrome/browser/signin/chrome_signin_client.h" 17 #include "chrome/browser/signin/chrome_signin_client_factory.h"
18 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" 18 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
19 #include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h" 19 #include "chrome/browser/signin/fake_profile_oauth2_token_service_wrapper.h"
20 #include "chrome/browser/signin/profile_oauth2_token_service.h" 20 #include "chrome/browser/signin/profile_oauth2_token_service.h"
21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 21 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
22 #include "chrome/browser/signin/signin_manager_factory.h" 22 #include "chrome/browser/signin/signin_manager_factory.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
25 #include "chrome/test/base/testing_browser_process.h" 25 #include "chrome/test/base/testing_browser_process.h"
26 #include "chrome/test/base/testing_profile.h" 26 #include "chrome/test/base/testing_profile.h"
27 #include "content/public/browser/child_process_security_policy.h" 27 #include "content/public/browser/child_process_security_policy.h"
(...skipping 20 matching lines...) Expand all
48 " \"token_type\": \"Bearer\"" 48 " \"token_type\": \"Bearer\""
49 "}"; 49 "}";
50 50
51 const char kUberAuthTokenURLFormat[] = "?source=%s&issueuberauth=1"; 51 const char kUberAuthTokenURLFormat[] = "?source=%s&issueuberauth=1";
52 52
53 BrowserContextKeyedService* SigninManagerBuild( 53 BrowserContextKeyedService* SigninManagerBuild(
54 content::BrowserContext* context) { 54 content::BrowserContext* context) {
55 SigninManager* service = NULL; 55 SigninManager* service = NULL;
56 Profile* profile = static_cast<Profile*>(context); 56 Profile* profile = static_cast<Profile*>(context);
57 service = new SigninManager( 57 service = new SigninManager(
58 scoped_ptr<SigninClient>(new ChromeSigninClient(profile))); 58 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile));
59 service->Initialize(profile, NULL); 59 service->Initialize(profile, NULL);
60 return service; 60 return service;
61 } 61 }
62 62
63 class TestSigninManagerObserver : public SigninManagerBase::Observer { 63 class TestSigninManagerObserver : public SigninManagerBase::Observer {
64 public: 64 public:
65 TestSigninManagerObserver() : num_failed_signins_(0), 65 TestSigninManagerObserver() : num_failed_signins_(0),
66 num_successful_signins_(0), 66 num_successful_signins_(0),
67 num_signouts_(0) { 67 num_signouts_(0) {
68 } 68 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 manager_ = static_cast<SigninManager*>( 139 manager_ = static_cast<SigninManager*>(
140 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( 140 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
141 profile(), SigninManagerBuild)); 141 profile(), SigninManagerBuild));
142 manager_->AddObserver(&test_observer_); 142 manager_->AddObserver(&test_observer_);
143 } 143 }
144 144
145 // Create a naked signin manager if integration with PKSs is not needed. 145 // Create a naked signin manager if integration with PKSs is not needed.
146 void CreateNakedSigninManager() { 146 void CreateNakedSigninManager() {
147 DCHECK(!manager_); 147 DCHECK(!manager_);
148 naked_manager_.reset(new SigninManager( 148 naked_manager_.reset(new SigninManager(
149 scoped_ptr<SigninClient>(new ChromeSigninClient(profile())))); 149 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile())));
150 150
151 manager_ = naked_manager_.get(); 151 manager_ = naked_manager_.get();
152 manager_->AddObserver(&test_observer_); 152 manager_->AddObserver(&test_observer_);
153 } 153 }
154 154
155 // Shuts down |manager_|. 155 // Shuts down |manager_|.
156 void ShutDownManager() { 156 void ShutDownManager() {
157 DCHECK(manager_); 157 DCHECK(manager_);
158 manager_->RemoveObserver(&test_observer_); 158 manager_->RemoveObserver(&test_observer_);
159 manager_->Shutdown(); 159 manager_->Shutdown();
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); 571 profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername));
572 EXPECT_EQ("external@example.com", manager_->GetAuthenticatedUsername()); 572 EXPECT_EQ("external@example.com", manager_->GetAuthenticatedUsername());
573 } 573 }
574 574
575 TEST_F(SigninManagerTest, SigninNotAllowed) { 575 TEST_F(SigninManagerTest, SigninNotAllowed) {
576 std::string user("user@google.com"); 576 std::string user("user@google.com");
577 profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user); 577 profile()->GetPrefs()->SetString(prefs::kGoogleServicesUsername, user);
578 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); 578 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
579 CreateSigninManagerAsService(); 579 CreateSigninManagerAsService();
580 } 580 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager_factory.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698