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/signin/signin_manager.h" | 5 #include "chrome/browser/signin/signin_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 had_two_factor_error_(false) { | 49 had_two_factor_error_(false) { |
50 } | 50 } |
51 | 51 |
52 SigninManager::~SigninManager() {} | 52 SigninManager::~SigninManager() {} |
53 | 53 |
54 void SigninManager::Initialize(Profile* profile) { | 54 void SigninManager::Initialize(Profile* profile) { |
55 // Should never call Initialize() twice. | 55 // Should never call Initialize() twice. |
56 DCHECK(!IsInitialized()); | 56 DCHECK(!IsInitialized()); |
57 profile_ = profile; | 57 profile_ = profile; |
58 | 58 |
| 59 // If the user is clearing the token service from the command line, then |
| 60 // clear their login info also (not valid to be logged in without any |
| 61 // tokens). |
| 62 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 63 if (cmd_line->HasSwitch(switches::kClearTokenService)) |
| 64 profile->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); |
| 65 |
59 std::string user = profile_->GetPrefs()->GetString( | 66 std::string user = profile_->GetPrefs()->GetString( |
60 prefs::kGoogleServicesUsername); | 67 prefs::kGoogleServicesUsername); |
61 if (!user.empty()) | 68 if (!user.empty()) |
62 SetAuthenticatedUsername(user); | 69 SetAuthenticatedUsername(user); |
63 // TokenService can be null for unit tests. | 70 // TokenService can be null for unit tests. |
64 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); | 71 TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); |
65 if (token_service) { | 72 if (token_service) { |
66 token_service->Initialize(GaiaConstants::kChromeSource, profile_); | 73 token_service->Initialize(GaiaConstants::kChromeSource, profile_); |
67 if (!authenticated_username_.empty()) { | 74 if (!authenticated_username_.empty()) { |
68 token_service->LoadTokensFromDB(); | 75 token_service->LoadTokensFromDB(); |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 profile_->GetRequestContext())); | 405 profile_->GetRequestContext())); |
399 } | 406 } |
400 | 407 |
401 client_login_->StartMergeSession(tok_details->token()); | 408 client_login_->StartMergeSession(tok_details->token()); |
402 | 409 |
403 // We only want to do this once per sign-in. | 410 // We only want to do this once per sign-in. |
404 CleanupNotificationRegistration(); | 411 CleanupNotificationRegistration(); |
405 } | 412 } |
406 #endif | 413 #endif |
407 } | 414 } |
OLD | NEW |