summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 01:12:29 +0000
committeratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 01:12:29 +0000
commit3ef741021d8713318906d33b5920d59ad13727db (patch)
tree0de5b6e0e6cf4763d7643a7fd37501ba41c2896a
parente9c4caea5b4e27268d893d1cb629bc966ca83631 (diff)
downloadchromium_src-3ef741021d8713318906d33b5920d59ad13727db.zip
chromium_src-3ef741021d8713318906d33b5920d59ad13727db.tar.gz
chromium_src-3ef741021d8713318906d33b5920d59ad13727db.tar.bz2
Revert SigninManager changes to see if they were the cause of the perf regression.
Revert "Moved SigninManager out of browser/sync, and start changing the code so signin" This reverts commit 897f42f222022acb470de4e8cd369862139583f2. Revert "Make SigninManager a ProfileKeyedService." This reverts commit b29413fd67465671335091b2b7e3bb7ed2f62e0f. BUG=108017 TEST=watch perf bots, see if perf regression disappears TBR=jamesr@chromium.org Review URL: https://chromiumcodereview.appspot.com/9251031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118202 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/gdata/gdata.cc2
-rw-r--r--chrome/browser/chromeos/login/login_performer.cc2
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc55
-rw-r--r--chrome/browser/chromeos/login/login_utils.h2
-rw-r--r--chrome/browser/chromeos/login/mock_authenticator.h2
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc4
-rw-r--r--chrome/browser/extensions/app_notify_channel_setup.cc4
-rw-r--r--chrome/browser/extensions/app_notify_channel_setup_unittest.cc6
-rw-r--r--chrome/browser/extensions/extension_webstore_private_api.cc4
-rw-r--r--chrome/browser/net/gaia/token_service.cc (renamed from chrome/browser/signin/token_service.cc)4
-rw-r--r--chrome/browser/net/gaia/token_service.h (renamed from chrome/browser/signin/token_service.h)8
-rw-r--r--chrome/browser/net/gaia/token_service_unittest.cc (renamed from chrome/browser/signin/token_service_unittest.cc)4
-rw-r--r--chrome/browser/net/gaia/token_service_unittest.h (renamed from chrome/browser/signin/token_service_unittest.h)10
-rw-r--r--chrome/browser/policy/browser_policy_connector.cc3
-rw-r--r--chrome/browser/prefs/browser_prefs.cc4
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.cc2
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.h2
-rw-r--r--chrome/browser/profiles/profile.h2
-rw-r--r--chrome/browser/profiles/profile_dependency_manager.cc9
-rw-r--r--chrome/browser/profiles/profile_downloader.cc4
-rw-r--r--chrome/browser/profiles/profile_impl.cc2
-rw-r--r--chrome/browser/profiles/profile_keyed_service_factory.cc26
-rw-r--r--chrome/browser/profiles/profile_keyed_service_factory.h7
-rw-r--r--chrome/browser/signin/OWNERS2
-rw-r--r--chrome/browser/signin/signin_manager_factory.cc49
-rw-r--r--chrome/browser/signin/signin_manager_factory.h41
-rw-r--r--chrome/browser/sync/abstract_profile_sync_service_test.h4
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc4
-rw-r--r--chrome/browser/sync/profile_sync_components_factory_impl.cc11
-rw-r--r--chrome/browser/sync/profile_sync_service.cc93
-rw-r--r--chrome/browser/sync/profile_sync_service.h34
-rw-r--r--chrome/browser/sync/profile_sync_service_autofill_unittest.cc5
-rw-r--r--chrome/browser/sync/profile_sync_service_harness.cc4
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.cc9
-rw-r--r--chrome/browser/sync/profile_sync_service_mock.h3
-rw-r--r--chrome/browser/sync/profile_sync_service_password_unittest.cc7
-rw-r--r--chrome/browser/sync/profile_sync_service_preference_unittest.cc8
-rw-r--r--chrome/browser/sync/profile_sync_service_session_unittest.cc7
-rw-r--r--chrome/browser/sync/profile_sync_service_startup_unittest.cc21
-rw-r--r--chrome/browser/sync/profile_sync_service_typed_url_unittest.cc7
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc20
-rw-r--r--chrome/browser/sync/signin_manager.cc (renamed from chrome/browser/signin/signin_manager.cc)42
-rw-r--r--chrome/browser/sync/signin_manager.h (renamed from chrome/browser/signin/signin_manager.h)26
-rw-r--r--chrome/browser/sync/signin_manager_fake.cc (renamed from chrome/browser/signin/signin_manager_fake.cc)13
-rw-r--r--chrome/browser/sync/signin_manager_fake.h (renamed from chrome/browser/signin/signin_manager_fake.h)17
-rw-r--r--chrome/browser/sync/signin_manager_unittest.cc (renamed from chrome/browser/signin/signin_manager_unittest.cc)8
-rw-r--r--chrome/browser/sync/sync_global_error_unittest.cc4
-rw-r--r--chrome/browser/sync/sync_setup_flow.cc102
-rw-r--r--chrome/browser/sync/sync_setup_flow.h17
-rw-r--r--chrome/browser/sync/sync_setup_wizard_unittest.cc122
-rw-r--r--chrome/browser/sync/test_profile_sync_service.cc7
-rw-r--r--chrome/browser/ui/auto_login_info_bar_delegate.cc2
-rw-r--r--chrome/browser/ui/auto_login_prompter.cc4
-rw-r--r--chrome/browser/ui/browser.cc4
-rw-r--r--chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc4
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.cc9
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler2.cc9
-rw-r--r--chrome/chrome_browser.gypi10
-rw-r--r--chrome/chrome_tests.gypi10
-rw-r--r--chrome/test/base/testing_profile.cc3
-rw-r--r--chrome/test/base/testing_profile.h4
-rw-r--r--tools/valgrind/memcheck/suppressions.txt36
62 files changed, 431 insertions, 519 deletions
diff --git a/chrome/browser/chromeos/gdata/gdata.cc b/chrome/browser/chromeos/gdata/gdata.cc
index 85e7881..7fc6795 100644
--- a/chrome/browser/chromeos/gdata/gdata.cc
+++ b/chrome/browser/chromeos/gdata/gdata.cc
@@ -18,9 +18,9 @@
#include "base/stringprintf.h"
#include "chrome/browser/chromeos/gdata/gdata_parser.h"
#include "chrome/browser/net/browser_url_util.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_downloader_delegate.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/net/gaia/gaia_urls.h"
diff --git a/chrome/browser/chromeos/login/login_performer.cc b/chrome/browser/chromeos/login/login_performer.cc
index a85bdbb..d4b3049 100644
--- a/chrome/browser/chromeos/login/login_performer.cc
+++ b/chrome/browser/chromeos/login/login_performer.cc
@@ -176,7 +176,7 @@ void LoginPerformer::OnProfileCreated(
if (using_oauth_)
LoginUtils::Get()->StartTokenServices(profile);
- LoginUtils::Get()->StartSignedInServices(profile, credentials_);
+ LoginUtils::Get()->StartSync(profile, credentials_);
credentials_ = GaiaAuthConsumer::ClientLoginResult();
// Don't unlock screen if it was locked while we're waiting
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index 67b3a5e..481cd75 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -45,14 +45,12 @@
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
#include "chrome/browser/net/gaia/gaia_oauth_fetcher.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/net/preconnect.h"
#include "chrome/browser/policy/browser_policy_connector.h"
#include "chrome/browser/prefs/pref_member.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/ui/browser_init.h"
#include "chrome/common/chrome_paths.h"
@@ -560,7 +558,7 @@ class LoginUtilsImpl : public LoginUtils,
virtual void PrewarmAuthentication() OVERRIDE;
virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE;
virtual void StartTokenServices(Profile* user_profile) OVERRIDE;
- virtual void StartSignedInServices(
+ virtual void StartSync(
Profile* profile,
const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE;
virtual void TransferDefaultCookies(Profile* default_profile,
@@ -771,20 +769,11 @@ void LoginUtilsImpl::OnProfileCreated(
switch (status) {
case Profile::CREATE_STATUS_INITIALIZED:
break;
- case Profile::CREATE_STATUS_CREATED: {
+ case Profile::CREATE_STATUS_CREATED:
if (UserManager::Get()->current_user_is_new())
SetFirstLoginPrefs(user_profile->GetPrefs());
- // Make sure that the google service username is properly set (we do this
- // on every sign in, not just the first login, to deal with existing
- // profiles that might not have it set yet).
- StringPrefMember google_services_username;
- google_services_username.Init(prefs::kGoogleServicesUsername,
- user_profile->GetPrefs(), NULL);
- google_services_username.SetValue(
- UserManager::Get()->logged_in_user().display_email());
RespectLocalePreference(user_profile);
return;
- }
case Profile::CREATE_STATUS_FAIL:
default:
NOTREACHED();
@@ -888,30 +877,30 @@ void LoginUtilsImpl::StartTokenServices(Profile* user_profile) {
oauth1_secret);
}
-void LoginUtilsImpl::StartSignedInServices(
+void LoginUtilsImpl::StartSync(
Profile* user_profile,
const GaiaAuthConsumer::ClientLoginResult& credentials) {
- // Fetch/Create the SigninManager - this will cause the TokenService to load
- // tokens for the currently signed-in user if the SigninManager hasn't already
- // been initialized.
- SigninManager* signin = SigninManagerFactory::GetForProfile(user_profile);
- DCHECK(signin);
- // Make sure SigninManager is connected to our current user (this should
- // happen automatically because we set kGoogleServicesUsername in
- // OnProfileCreated()).
- DCHECK_EQ(UserManager::Get()->logged_in_user().display_email(),
- signin->GetAuthenticatedUsername());
+ TokenService* token_service = user_profile->GetTokenService();
static bool initialized = false;
if (!initialized) {
initialized = true;
- // Pass the updated passphrase to the sync service for use in decrypting
- // data encrypted with the user's GAIA password.
- ProfileSyncService* sync_service = user_profile->GetProfileSyncService();
- if (sync_service)
- sync_service->SetPassphrase(password_, false);
+
+ std::string email = UserManager::Get()->logged_in_user().display_email();
+ user_profile->GetPrefs()->SetString(prefs::kGoogleServicesUsername, email);
+
+ ProfileSyncService* service = user_profile->GetProfileSyncService();
+ if (service) {
+ service->SetPassphrase(password_, false);
+ } else {
+ DCHECK(!token_service->Initialized());
+ // TODO(cros): This TokenService init if sync is not enabled (someone
+ // passed the --disable-sync flag) should likely be handled at a higher
+ // level.
+ token_service->Initialize(GaiaConstants::kChromeOSSource, user_profile);
+ token_service->LoadTokensFromDB();
+ }
+ password_ = "";
}
- password_.clear();
- TokenService* token_service = user_profile->GetTokenService();
token_service->UpdateCredentials(credentials);
if (token_service->AreCredentialsValid())
token_service->StartFetchingTokens();
@@ -1295,7 +1284,7 @@ void LoginUtilsImpl::OnOAuthVerificationSucceeded(
// Kick off sync engine.
GaiaAuthConsumer::ClientLoginResult credentials(sid, lsid, auth,
std::string());
- StartSignedInServices(ProfileManager::GetDefaultProfile(), credentials);
+ StartSync(ProfileManager::GetDefaultProfile(), credentials);
}
diff --git a/chrome/browser/chromeos/login/login_utils.h b/chrome/browser/chromeos/login/login_utils.h
index ae6dc60..2c156d1 100644
--- a/chrome/browser/chromeos/login/login_utils.h
+++ b/chrome/browser/chromeos/login/login_utils.h
@@ -103,7 +103,7 @@ class LoginUtils {
virtual void StartTokenServices(Profile* user_profile) = 0;
// Supply credentials for sync and others to use.
- virtual void StartSignedInServices(
+ virtual void StartSync(
Profile* profile,
const GaiaAuthConsumer::ClientLoginResult& credentials) = 0;
diff --git a/chrome/browser/chromeos/login/mock_authenticator.h b/chrome/browser/chromeos/login/mock_authenticator.h
index 3c0fad3..25ac2f9 100644
--- a/chrome/browser/chromeos/login/mock_authenticator.h
+++ b/chrome/browser/chromeos/login/mock_authenticator.h
@@ -103,7 +103,7 @@ class MockLoginUtils : public LoginUtils {
virtual void StartTokenServices(Profile* profile) OVERRIDE {}
- virtual void StartSignedInServices(
+ virtual void StartSync(
Profile* profile,
const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE {}
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index 4334e2f..810ba81 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,8 +31,8 @@
#include "chrome/browser/chromeos/status/status_area_view_chromeos.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
diff --git a/chrome/browser/extensions/app_notify_channel_setup.cc b/chrome/browser/extensions/app_notify_channel_setup.cc
index 8268345..82c2e68 100644
--- a/chrome/browser/extensions/app_notify_channel_setup.cc
+++ b/chrome/browser/extensions/app_notify_channel_setup.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,9 +13,9 @@
#include "base/json/json_reader.h"
#include "base/metrics/histogram.h"
#include "base/stringprintf.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/net/gaia/gaia_urls.h"
diff --git a/chrome/browser/extensions/app_notify_channel_setup_unittest.cc b/chrome/browser/extensions/app_notify_channel_setup_unittest.cc
index 543d243..063da55 100644
--- a/chrome/browser/extensions/app_notify_channel_setup_unittest.cc
+++ b/chrome/browser/extensions/app_notify_channel_setup_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,8 +9,8 @@
#include "base/message_loop.h"
#include "chrome/browser/extensions/app_notify_channel_setup.h"
#include "chrome/browser/extensions/app_notify_channel_ui.h"
-#include "chrome/browser/signin/token_service.h"
-#include "chrome/browser/signin/token_service_unittest.h"
+#include "chrome/browser/net/gaia/token_service.h"
+#include "chrome/browser/net/gaia/token_service_unittest.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/net/gaia/gaia_urls.h"
#include "chrome/common/pref_names.h"
diff --git a/chrome/browser/extensions/extension_webstore_private_api.cc b/chrome/browser/extensions/extension_webstore_private_api.cc
index 61ef38f..07d0e4c 100644
--- a/chrome/browser/extensions/extension_webstore_private_api.cc
+++ b/chrome/browser/extensions/extension_webstore_private_api.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -16,8 +16,8 @@
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/webstore_installer.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
diff --git a/chrome/browser/signin/token_service.cc b/chrome/browser/net/gaia/token_service.cc
index f6c17c5..031719e 100644
--- a/chrome/browser/signin/token_service.cc
+++ b/chrome/browser/net/gaia/token_service.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/signin/token_service.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "base/command_line.h"
#include "base/string_util.h"
diff --git a/chrome/browser/signin/token_service.h b/chrome/browser/net/gaia/token_service.h
index 6b33c8c..99c31d1 100644
--- a/chrome/browser/signin/token_service.h
+++ b/chrome/browser/net/gaia/token_service.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -32,8 +32,8 @@
// }
// }
-#ifndef CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_
-#define CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_
+#ifndef CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_
+#define CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_
#pragma once
#include <map>
@@ -278,4 +278,4 @@ class TokenService : public GaiaAuthConsumer,
DISALLOW_COPY_AND_ASSIGN(TokenService);
};
-#endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_
+#endif // CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_
diff --git a/chrome/browser/signin/token_service_unittest.cc b/chrome/browser/net/gaia/token_service_unittest.cc
index 2c8b264..c43cd5c 100644
--- a/chrome/browser/signin/token_service_unittest.cc
+++ b/chrome/browser/net/gaia/token_service_unittest.cc
@@ -1,10 +1,10 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file defines a unit test for the profile's token service.
-#include "chrome/browser/signin/token_service_unittest.h"
+#include "chrome/browser/net/gaia/token_service_unittest.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
diff --git a/chrome/browser/signin/token_service_unittest.h b/chrome/browser/net/gaia/token_service_unittest.h
index 5de3f248..5f14feb 100644
--- a/chrome/browser/signin/token_service_unittest.h
+++ b/chrome/browser/net/gaia/token_service_unittest.h
@@ -1,17 +1,17 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file defines a unit test harness for the profile's token service.
-#ifndef CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_UNITTEST_H_
-#define CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_UNITTEST_H_
+#ifndef CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_UNITTEST_H_
+#define CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_UNITTEST_H_
#pragma once
#include "base/message_loop.h"
#include "base/synchronization/waitable_event.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/common/net/gaia/gaia_auth_consumer.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/notification_details.h"
@@ -81,4 +81,4 @@ class TokenServiceTestHarness : public testing::Test {
scoped_ptr<TestingProfile> profile_;
};
-#endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_UNITTEST_H_
+#endif // CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_UNITTEST_H_
diff --git a/chrome/browser/policy/browser_policy_connector.cc b/chrome/browser/policy/browser_policy_connector.cc
index 33bcada..8e2c3ce9 100644
--- a/chrome/browser/policy/browser_policy_connector.cc
+++ b/chrome/browser/policy/browser_policy_connector.cc
@@ -9,6 +9,8 @@
#include "base/file_path.h"
#include "base/path_service.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/net/gaia/token_service.h"
+#include "chrome/browser/policy/cloud_policy_data_store.h"
#include "chrome/browser/policy/cloud_policy_provider.h"
#include "chrome/browser/policy/cloud_policy_provider_impl.h"
#include "chrome/browser/policy/cloud_policy_subsystem.h"
@@ -16,7 +18,6 @@
#include "chrome/browser/policy/network_configuration_updater.h"
#include "chrome/browser/policy/user_policy_cache.h"
#include "chrome/browser/policy/user_policy_token_cache.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index f2271358..1abb295 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -47,6 +47,7 @@
#include "chrome/browser/renderer_host/web_cache_manager.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/tabs/pinned_tab_codec.h"
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/browser/translate/translate_prefs.h"
@@ -188,6 +189,7 @@ void RegisterUserPrefs(PrefService* user_prefs) {
chromeos::Preferences::RegisterUserPrefs(user_prefs);
chromeos::ProxyConfigServiceImpl::RegisterPrefs(user_prefs);
#endif
+ SigninManager::RegisterUserPrefs(user_prefs);
InstantController::RegisterUserPrefs(user_prefs);
NetPrefObserver::RegisterPrefs(user_prefs);
ProtocolHandlerRegistry::RegisterPrefs(user_prefs);
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index 97809b0..ff56176 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h
index a647e96..4976d1d 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.h
+++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index 3954e5a..10de7ad 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/profile_dependency_manager.cc
index 5045ddf..f3c13c2 100644
--- a/chrome/browser/profiles/profile_dependency_manager.cc
+++ b/chrome/browser/profiles/profile_dependency_manager.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -21,7 +21,6 @@
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/speech/speech_input_extension_manager.h"
class Profile;
@@ -49,7 +48,6 @@ void AssertFactoriesBuilt() {
PluginPrefsFactory::GetInstance();
prerender::PrerenderManagerFactory::GetInstance();
SessionServiceFactory::GetInstance();
- SigninManagerFactory::GetInstance();
SpeechInputExtensionManager::InitializeFactory();
TabRestoreServiceFactory::GetInstance();
TemplateURLServiceFactory::GetInstance();
@@ -110,9 +108,10 @@ void ProfileDependencyManager::CreateProfileServices(Profile* profile,
for (std::vector<ProfileKeyedServiceFactory*>::reverse_iterator rit =
destruction_order_.rbegin(); rit != destruction_order_.rend();
++rit) {
- if (!profile->IsOffTheRecord()) {
+ if (!profile->IsOffTheRecord() && !profile->AsTestingProfile()) {
// We only register preferences on normal profiles because the incognito
- // profile shares the pref service with the normal one.
+ // profile shares the pref service with the normal one and the testing
+ // profile will often just insert its own PrefService.
(*rit)->RegisterUserPrefsOnProfile(profile);
}
diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc
index 8c92f8c..57ff7f9 100644
--- a/chrome/browser/profiles/profile_downloader.cc
+++ b/chrome/browser/profiles/profile_downloader.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,9 +13,9 @@
#include "base/string_split.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_downloader_delegate.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/net/gaia/gaia_urls.h"
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index c73aea2..323afcd 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -51,6 +51,7 @@
#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/net/chrome_url_request_context.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/net/net_pref_observer.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/net/proxy_service_factory.h"
@@ -70,7 +71,6 @@
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/sessions/session_service_factory.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/speech/chrome_speech_input_manager.h"
#include "chrome/browser/speech/chrome_speech_input_preferences.h"
#include "chrome/browser/spellchecker/spellcheck_profile.h"
diff --git a/chrome/browser/profiles/profile_keyed_service_factory.cc b/chrome/browser/profiles/profile_keyed_service_factory.cc
index 886308d..e755ae3 100644
--- a/chrome/browser/profiles/profile_keyed_service_factory.cc
+++ b/chrome/browser/profiles/profile_keyed_service_factory.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -50,18 +50,20 @@ void ProfileKeyedServiceFactory::RegisterUserPrefsOnProfile(Profile* profile) {
// profiles, we just never register since incognito profiles share the same
// pref services with their parent profiles.
//
- // TestingProfiles throw a wrench into the mix, in that some tests will
- // swap out the PrefService after we've registered user prefs on the original
- // PrefService. Test code that does this is responsible for either manually
- // invoking RegisterUserPrefs() on the appropriate ProfileKeyedServiceFactory
- // associated with the prefs they need, or they can use SetTestingFactory()
- // and create a service (since service creation with a factory method causes
- // registration to happen at service creation time).
+ // Testing profiles throw two wrenches into the mix. One: PrefService isn't
+ // created at profile creation time so we have to move pref registration to
+ // service creation time when using a testing factory. We can't change
+ // PrefService because Two: some tests switch out the PrefService after the
+ // TestingProfile has been created but before it's ever used. So we key our
+ // check on Profile since there's already error checking code to prevent
+ // a secondary PrefService from existing.
//
- // Now that services are responsible for declaring their preferences, we have
- // to enforce a uniquenes check here because some tests create one profile and
- // multiple services of the same type attached to that profile (serially, not
- // parallel) and we don't want to register multiple times on the same profile.
+ // Even worse is Three: Now that services are responsible for declaring their
+ // preferences, we have to enforce a uniquenes check here because some tests
+ // create one profile and multiple services of the same type attached to that
+ // profile (serially, not parallel). This wasn't a problem when it was the
+ // Profile that was responsible for registering the preferences, but now is
+ // because of the timing issues introduced by One.
DCHECK(!profile->IsOffTheRecord());
std::set<Profile*>::iterator it = registered_preferences_.find(profile);
diff --git a/chrome/browser/profiles/profile_keyed_service_factory.h b/chrome/browser/profiles/profile_keyed_service_factory.h
index ab5eceb..3cac950 100644
--- a/chrome/browser/profiles/profile_keyed_service_factory.h
+++ b/chrome/browser/profiles/profile_keyed_service_factory.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -60,9 +60,8 @@ class ProfileKeyedServiceFactory {
// Common implementation that maps |profile| to some service object. Deals
// with incognito profiles per subclass instructions with
- // ServiceRedirectedInIncognito() and ServiceHasOwnInstanceInIncognito().
- // If |create| is true, the service will be created using
- // BuildServiceInstanceFor() if it doesn't already exist.
+ // ServiceActiveInIncognito(). If |create| is true, the service will be
+ // created using BuildServiceInstanceFor() if it doesn't already exist.
ProfileKeyedService* GetServiceForProfile(Profile* profile, bool create);
// The main public interface for declaring dependencies between services
diff --git a/chrome/browser/signin/OWNERS b/chrome/browser/signin/OWNERS
deleted file mode 100644
index e94f3aa..0000000
--- a/chrome/browser/signin/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-tim@chromium.org
-atwilson@chromium.org \ No newline at end of file
diff --git a/chrome/browser/signin/signin_manager_factory.cc b/chrome/browser/signin/signin_manager_factory.cc
deleted file mode 100644
index c844da0..0000000
--- a/chrome/browser/signin/signin_manager_factory.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/signin/signin_manager_factory.h"
-
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile_dependency_manager.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/common/pref_names.h"
-
-SigninManagerFactory::SigninManagerFactory()
- : ProfileKeyedServiceFactory(ProfileDependencyManager::GetInstance()) {
- // TODO(atwilson): SigninManager depends on TokenService - when this is
- // converted to the ProfileKeyedService framework, uncomment this dependency.
- // DependsOn(TokenServiceFactory::GetInstance());
-}
-
-SigninManagerFactory::~SigninManagerFactory() {}
-
-// static
-SigninManager* SigninManagerFactory::GetForProfile(Profile* profile) {
- return static_cast<SigninManager*>(
- GetInstance()->GetServiceForProfile(profile, true));
-}
-
-// static
-SigninManagerFactory* SigninManagerFactory::GetInstance() {
- return Singleton<SigninManagerFactory>::get();
-}
-
-void SigninManagerFactory::RegisterUserPrefs(PrefService* user_prefs) {
- user_prefs->RegisterBooleanPref(prefs::kSyncUsingOAuth, "",
- PrefService::UNSYNCABLE_PREF);
- user_prefs->RegisterStringPref(prefs::kGoogleServicesUsername, "",
- PrefService::UNSYNCABLE_PREF);
- user_prefs->RegisterBooleanPref(prefs::kAutologinEnabled, true,
- PrefService::UNSYNCABLE_PREF);
- user_prefs->RegisterBooleanPref(prefs::kReverseAutologinEnabled, true,
- PrefService::UNSYNCABLE_PREF);
-}
-
-ProfileKeyedService* SigninManagerFactory::BuildServiceInstanceFor(
- Profile* profile) const {
- SigninManager* service = new SigninManager();
- service->Initialize(profile);
- return service;
-}
-
diff --git a/chrome/browser/signin/signin_manager_factory.h b/chrome/browser/signin/signin_manager_factory.h
deleted file mode 100644
index f281447..0000000
--- a/chrome/browser/signin/signin_manager_factory.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_
-#define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_
-#pragma once
-
-#include "base/memory/singleton.h"
-#include "chrome/browser/profiles/profile_keyed_service_factory.h"
-
-class SigninManager;
-class Profile;
-
-// Singleton that owns all SigninManagers and associates them with
-// Profiles. Listens for the Profile's destruction notification and cleans up
-// the associated SigninManager.
-class SigninManagerFactory : public ProfileKeyedServiceFactory {
- public:
- // Returns the instance of SigninManager associated with this profile
- // (creating one if none exists). Returns NULL if this profile cannot have a
- // SigninManager (for example, if |profile| is incognito).
- static SigninManager* GetForProfile(Profile* profile);
-
- // Returns an instance of the SigninManagerFactory singleton.
- static SigninManagerFactory* GetInstance();
-
- // Implementation of ProfileKeyedServiceFactory (public so tests can call it).
- virtual void RegisterUserPrefs(PrefService* user_prefs) OVERRIDE;
- private:
- friend struct DefaultSingletonTraits<SigninManagerFactory>;
-
- SigninManagerFactory();
- virtual ~SigninManagerFactory();
-
- // ProfileKeyedServiceFactory:
- virtual ProfileKeyedService* BuildServiceInstanceFor(
- Profile* profile) const OVERRIDE;
-};
-
-#endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FACTORY_H_
diff --git a/chrome/browser/sync/abstract_profile_sync_service_test.h b/chrome/browser/sync/abstract_profile_sync_service_test.h
index 2d0da0b9..fc62d49 100644
--- a/chrome/browser/sync/abstract_profile_sync_service_test.h
+++ b/chrome/browser/sync/abstract_profile_sync_service_test.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,7 +12,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
-#include "chrome/browser/signin/token_service.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/sync/internal_api/change_record.h"
#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
#include "chrome/browser/sync/syncable/model_type.h"
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index 9ee5d70..ccc4b4c 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,8 +18,8 @@
#include "base/threading/thread_restrictions.h"
#include "base/timer.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/sync/glue/change_processor.h"
#include "chrome/browser/sync/glue/http_bridge.h"
#include "chrome/browser/sync/glue/sync_backend_registrar.h"
diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc
index 736338f..6628d7c 100644
--- a/chrome/browser/sync/profile_sync_components_factory_impl.cc
+++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,8 +11,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/api/syncable_service.h"
#include "chrome/browser/sync/glue/app_data_type_controller.h"
#include "chrome/browser/sync/glue/app_notification_data_type_controller.h"
@@ -44,6 +42,7 @@
#include "chrome/browser/sync/glue/typed_url_model_associator.h"
#include "chrome/browser/sync/profile_sync_components_factory_impl.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/webdata/autocomplete_syncable_service.h"
#include "chrome/browser/webdata/autofill_profile_syncable_service.h"
#include "chrome/browser/webdata/web_data_service.h"
@@ -95,7 +94,11 @@ ProfileSyncService*
ProfileSyncService::StartBehavior behavior =
browser_defaults::kSyncAutoStarts ? ProfileSyncService::AUTO_START
: ProfileSyncService::MANUAL_START;
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
+
+ PrefService* prefs = profile_->GetPrefs();
+ SigninManager* signin = new SigninManager();
+ signin->SetAuthenticatedUsername(prefs->GetString(
+ prefs::kGoogleServicesUsername));
// TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync
// is set up and *not* a browser restart for a manual-start platform (where
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 1a09529..cdfad50 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -24,10 +24,8 @@
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/chrome_cookie_notification_details.h"
-
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/sync/api/sync_error.h"
#include "chrome/browser/sync/backend_migrator.h"
#include "chrome/browser/sync/glue/change_processor.h"
@@ -41,6 +39,7 @@
#include "chrome/browser/sync/js/js_arg_list.h"
#include "chrome/browser/sync/js/js_event_details.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/sync_global_error.h"
#include "chrome/browser/sync/util/cryptographer.h"
#include "chrome/browser/sync/util/oauth.h"
@@ -193,6 +192,8 @@ void ProfileSyncService::Initialize() {
if (!HasSyncSetupCompleted())
DisableForUser(); // Clean up in case of previous crash / setup abort.
+ signin_->Initialize(profile_);
+
TryStart();
}
@@ -223,9 +224,6 @@ void ProfileSyncService::RegisterAuthNotifications() {
registrar_.Add(this,
chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED,
content::Source<Profile>(profile_));
- registrar_.Add(this,
- chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
- content::Source<Profile>(profile_));
}
void ProfileSyncService::RegisterDataTypeController(
@@ -436,6 +434,7 @@ void ProfileSyncService::Shutdown(bool sync_disabled) {
encrypt_everything_ = false;
encrypted_types_ = browser_sync::Cryptographer::SensitiveTypes();
passphrase_required_reason_ = sync_api::REASON_PASSPHRASE_NOT_REQUIRED;
+ last_attempted_user_email_.clear();
last_auth_error_ = GoogleServiceAuthError::None();
if (sync_global_error_.get()) {
@@ -464,11 +463,7 @@ void ProfileSyncService::DisableForUser() {
ClearUnrecoverableError();
Shutdown(true);
- // TODO(atwilson): Don't call SignOut() on *any* platform - move this into
- // the UI layer if needed (sync activity should never result in the user
- // being logged out of all chrome services).
- if (!auto_start_enabled_)
- signin_->SignOut();
+ signin_->SignOut();
NotifyObservers();
}
@@ -713,6 +708,7 @@ void ProfileSyncService::UpdateAuthErrorState(
auth_start_time_ = base::TimeTicks();
}
+ is_auth_in_progress_ = false;
// Fan the notification out to interested UI-thread components.
NotifyObservers();
}
@@ -1040,17 +1036,6 @@ bool ProfileSyncService::UIShouldDepictAuthInProgress() const {
return is_auth_in_progress_;
}
-void ProfileSyncService::SetUIShouldDepictAuthInProgress(
- bool auth_in_progress) {
- is_auth_in_progress_ = auth_in_progress;
- // TODO(atwilson): Figure out if we still need to track this or if we should
- // move this up to the UI (or break it out into two stats that track GAIA
- // auth and sync auth separately).
- if (is_auth_in_progress_)
- auth_start_time_ = base::TimeTicks::Now();
- NotifyObservers();
-}
-
bool ProfileSyncService::IsPassphraseRequired() const {
return passphrase_required_reason_ !=
sync_api::REASON_PASSPHRASE_NOT_REQUIRED;
@@ -1077,6 +1062,41 @@ string16 ProfileSyncService::GetLastSyncedTimeString() const {
return TimeFormat::TimeElapsed(last_synced);
}
+void ProfileSyncService::OnUserSubmittedAuth(
+ const std::string& username, const std::string& password,
+ const std::string& captcha, const std::string& access_code) {
+ last_attempted_user_email_ = username;
+ is_auth_in_progress_ = true;
+ NotifyObservers();
+
+ auth_start_time_ = base::TimeTicks::Now();
+
+ if (!access_code.empty()) {
+ signin_->ProvideSecondFactorAccessCode(access_code);
+ return;
+ }
+
+ // The user has submitted credentials, which indicates they don't
+ // want to suppress start up anymore.
+ sync_prefs_.SetStartSuppressed(false);
+
+ signin_->StartSignIn(username,
+ password,
+ last_auth_error_.captcha().token,
+ captcha);
+}
+
+void ProfileSyncService::OnUserSubmittedOAuth(
+ const std::string& oauth1_request_token) {
+ is_auth_in_progress_ = true;
+
+ // The user has submitted credentials, which indicates they don't
+ // want to suppress start up anymore.
+ sync_prefs_.SetStartSuppressed(false);
+
+ signin_->StartOAuthSignIn(oauth1_request_token);
+}
+
void ProfileSyncService::OnUserChoseDatatypes(bool sync_everything,
syncable::ModelTypeSet chosen_types) {
if (!backend_.get() &&
@@ -1104,6 +1124,16 @@ void ProfileSyncService::OnUserCancelledDialog() {
// allow them to cancel out.
encryption_pending_ = false;
+ // Though an auth could still be in progress, once the dialog is closed we
+ // don't want the UI to stay stuck in the "waiting for authentication" state
+ // as that could take forever. We set this to false so the buttons to re-
+ // login will appear until either a) the original request finishes and
+ // succeeds, calling OnAuthError(NONE), or b) the user clicks the button,
+ // and tries to re-authenticate. (b) is a little awkward as this second
+ // request will get queued behind the first and could wind up "undoing" the
+ // good if invalid creds were provided, but it's an edge case and the user
+ // can of course get themselves out of it.
+ is_auth_in_progress_ = false;
NotifyObservers();
}
@@ -1387,23 +1417,6 @@ void ProfileSyncService::Observe(int type,
UpdateAuthErrorState(error);
break;
}
- case chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL: {
- const GoogleServiceSigninSuccessDetails* successful =
- content::Details<const GoogleServiceSigninSuccessDetails>(
- details).ptr();
- // The user has submitted credentials, which indicates they don't
- // want to suppress start up anymore.
- sync_prefs_.SetStartSuppressed(false);
-
- // We pass 'false' to SetPassphrase to denote that this is an implicit
- // request and shouldn't override an explicit one. Thus, we either
- // update the implicit passphrase (idempotent if the passphrase didn't
- // actually change), or the user has an explicit passphrase set so this
- // becomes a no-op.
- if (!successful->password.empty())
- SetPassphrase(successful->password, false);
- break;
- }
case chrome::NOTIFICATION_TOKEN_REQUEST_FAILED: {
const TokenService::TokenRequestFailedDetails& token_details =
*(content::Details<const TokenService::TokenRequestFailedDetails>(
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 77d4d08b..b483ef9 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -159,7 +159,7 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
ProfileSyncService(ProfileSyncComponentsFactory* factory,
Profile* profile,
- SigninManager* signin,
+ SigninManager* signin, // Service takes ownership.
StartBehavior start_behavior);
virtual ~ProfileSyncService();
@@ -234,6 +234,15 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
void OnClearServerDataTimeout();
+ // Called when a user enters credentials through UI.
+ virtual void OnUserSubmittedAuth(const std::string& username,
+ const std::string& password,
+ const std::string& captcha,
+ const std::string& access_code);
+
+ // Called when a user enters credentials through UI.
+ virtual void OnUserSubmittedOAuth(const std::string& oauth1_request_token);
+
// Update the last auth error and notify observers of error state.
void UpdateAuthErrorState(const GoogleServiceAuthError& error);
@@ -304,14 +313,7 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
return unrecoverable_error_location_;
}
- // Tracks whether the user is currently authenticating or not. This is used
- // by the sync_ui_util helper routines to allow the UI to properly display
- // an "authenticating..." status message instead of an auth error when we are
- // in the process of trying to update credentials.
- // TODO(atwilson): This state should reside up in the UI or in a profile-
- // specific SyncUIUtil object rather than in ProfileSyncService.
virtual bool UIShouldDepictAuthInProgress() const;
- virtual void SetUIShouldDepictAuthInProgress(bool auth_in_progress);
// Returns true if OnPassphraseRequired has been called for any reason.
virtual bool IsPassphraseRequired() const;
@@ -327,6 +329,10 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// Returns a user-friendly string form of last synced time (in minutes).
virtual string16 GetLastSyncedTimeString() const;
+ const std::string& last_attempted_user_email() const {
+ return last_attempted_user_email_;
+ }
+
// The profile we are syncing for.
Profile* profile() const { return profile_; }
@@ -471,7 +477,7 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
const GURL& sync_service_url() const { return sync_service_url_; }
bool auto_start_enabled() const { return auto_start_enabled_; }
- SigninManager* signin() const { return signin_; }
+ SigninManager* signin() const { return signin_.get(); }
// Stops the sync backend and sets the flag for suppressing sync startup.
void StopAndSuppress();
@@ -526,6 +532,9 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
// other threads.
scoped_ptr<browser_sync::SyncBackendHost> backend_;
+ // Cache of the last name the client attempted to authenticate.
+ std::string last_attempted_user_email_;
+
// Was the last SYNC_PASSPHRASE_REQUIRED notification sent because it
// was required for encryption, decryption with a cached passphrase, or
// because a new passphrase is required?
@@ -622,9 +631,8 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
SyncSetupWizard wizard_;
- // Encapsulates user signin - used to set/get the user's authenticated
- // email address.
- SigninManager* signin_;
+ // Encapsulates user signin with TokenService.
+ scoped_ptr<SigninManager> signin_;
// True if an unrecoverable error (e.g. violation of an assumed invariant)
// occurred during syncer operation. This value should be checked before
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
index b99c7d1..c92a915 100644
--- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
@@ -23,8 +23,6 @@
#include "chrome/browser/autofill/autofill_common_test.h"
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/autofill/personal_data_manager_factory.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/engine/model_changing_syncer_command.h"
#include "chrome/browser/sync/glue/autofill_data_type_controller.h"
@@ -41,6 +39,7 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/syncable/syncable.h"
@@ -400,7 +399,7 @@ class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest {
bool will_fail_association,
syncable::ModelType type) {
AbstractAutofillFactory* factory = GetFactory(type);
- SigninManager* signin = SigninManagerFactory::GetForProfile(&profile_);
+ SigninManager* signin = new SigninManager();
signin->SetAuthenticatedUsername("test_user");
service_.reset(
new TestProfileSyncService(&factory_,
diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc
index d403396..e675efb 100644
--- a/chrome/browser/sync/profile_sync_service_harness.cc
+++ b/chrome/browser/sync/profile_sync_service_harness.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -20,9 +20,9 @@
#include "base/memory/ref_counted.h"
#include "base/message_loop.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
#include "chrome/browser/sync/sessions/session_state.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/sync_ui_util.h"
using browser_sync::sessions::SyncSessionSnapshot;
diff --git a/chrome/browser/sync/profile_sync_service_mock.cc b/chrome/browser/sync/profile_sync_service_mock.cc
index b5755bb..2682fd3 100644
--- a/chrome/browser/sync/profile_sync_service_mock.cc
+++ b/chrome/browser/sync/profile_sync_service_mock.cc
@@ -1,12 +1,11 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/prefs/pref_service_mock_builder.h"
#include "chrome/browser/prefs/testing_pref_store.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -27,7 +26,6 @@ ProfileSyncServiceMock::ProfileSyncServiceMock(
}
ProfileSyncServiceMock::~ProfileSyncServiceMock() {
- delete signin();
}
// static
@@ -38,8 +36,7 @@ Profile* ProfileSyncServiceMock::MakeSignedInTestingProfile() {
.WithUserPrefs(user_prefs)
.Create();
profile->SetPrefService(prefs);
- // We just blew away our prefs, so reregister them.
- SigninManagerFactory::GetInstance()->RegisterUserPrefs(prefs);
+ SigninManager::RegisterUserPrefs(prefs);
user_prefs->SetString(prefs::kGoogleServicesUsername, "foo");
return profile;
}
diff --git a/chrome/browser/sync/profile_sync_service_mock.h b/chrome/browser/sync/profile_sync_service_mock.h
index 5987540..7c1d6c1 100644
--- a/chrome/browser/sync/profile_sync_service_mock.h
+++ b/chrome/browser/sync/profile_sync_service_mock.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -20,7 +20,6 @@
class ProfileSyncServiceMock : public ProfileSyncService {
public:
- // no-arg constructor provided so TestingProfile can use NiceMock.
ProfileSyncServiceMock();
explicit ProfileSyncServiceMock(Profile* profile);
virtual ~ProfileSyncServiceMock();
diff --git a/chrome/browser/sync/profile_sync_service_password_unittest.cc b/chrome/browser/sync/profile_sync_service_password_unittest.cc
index 3670b32..d78a177 100644
--- a/chrome/browser/sync/profile_sync_service_password_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_password_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -14,8 +14,6 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/password_manager/password_store.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/glue/password_change_processor.h"
#include "chrome/browser/sync/glue/password_data_type_controller.h"
@@ -29,6 +27,7 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/browser/sync/protocol/password_specifics.pb.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/test/engine/test_id_factory.h"
@@ -216,7 +215,7 @@ class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest {
void StartSyncService(const base::Closure& root_callback,
const base::Closure& node_callback) {
if (!service_.get()) {
- SigninManager* signin = SigninManagerFactory::GetForProfile(&profile_);
+ SigninManager* signin = new SigninManager();
signin->SetAuthenticatedUsername("test_user");
service_.reset(new PasswordTestProfileSyncService(
&factory_, &profile_, signin, false,
diff --git a/chrome/browser/sync/profile_sync_service_preference_unittest.cc b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
index 72e542c..26dc5e3 100644
--- a/chrome/browser/sync/profile_sync_service_preference_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_preference_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,9 +15,6 @@
#include "base/string_piece.h"
#include "chrome/browser/prefs/pref_model_associator.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/api/sync_data.h"
#include "chrome/browser/sync/glue/generic_change_processor.h"
@@ -31,6 +28,7 @@
#include "chrome/browser/sync/internal_api/write_transaction.h"
#include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/browser/sync/protocol/preference_specifics.pb.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/test_profile_sync_service.h"
#include "chrome/common/net/gaia/gaia_constants.h"
@@ -121,7 +119,7 @@ class ProfileSyncServicePreferenceTest
if (service_.get())
return false;
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile_.get());
+ SigninManager* signin = new SigninManager();
signin->SetAuthenticatedUsername("test");
service_.reset(new TestProfileSyncService(
&factory_,
diff --git a/chrome/browser/sync/profile_sync_service_session_unittest.cc b/chrome/browser/sync/profile_sync_service_session_unittest.cc
index 7c01375..d858448 100644
--- a/chrome/browser/sync/profile_sync_service_session_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_session_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,8 +15,6 @@
#include "base/scoped_temp_dir.h"
#include "base/stl_util.h"
#include "base/time.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/glue/session_change_processor.h"
#include "chrome/browser/sync/glue/session_data_type_controller.h"
@@ -30,6 +28,7 @@
#include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/browser/sync/protocol/session_specifics.pb.h"
#include "chrome/browser/sync/protocol/sync.pb.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/syncable/syncable.h"
@@ -209,7 +208,7 @@ class ProfileSyncServiceSessionTest
bool will_fail_association) {
if (sync_service_.get())
return false;
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile());
+ SigninManager* signin = new SigninManager();
signin->SetAuthenticatedUsername("test_user");
sync_service_.reset(new TestProfileSyncService(
&factory_,
diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
index b211602..118527d 100644
--- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,15 +6,13 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/signin/signin_manager_fake.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/sync/glue/data_type_manager.h"
#include "chrome/browser/sync/glue/data_type_manager_mock.h"
#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
#include "chrome/browser/sync/profile_sync_test_util.h"
+#include "chrome/browser/sync/signin_manager_fake.h"
#include "chrome/browser/sync/test_profile_sync_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/net/gaia/gaia_auth_consumer.h"
@@ -71,13 +69,9 @@ class ProfileSyncServiceStartupTest : public testing::Test {
protected:
// Overridden below by ProfileSyncServiceStartupCrosTest.
virtual void CreateSyncService() {
- SigninManager* signin = static_cast<SigninManager*>(
- SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_.get(), FakeSigninManager::Build));
- signin->SetAuthenticatedUsername("test_user");
service_.reset(new TestProfileSyncService(&factory_,
profile_.get(),
- signin,
+ new FakeSigninManager(),
ProfileSyncService::MANUAL_START,
true,
base::Closure()));
@@ -103,7 +97,7 @@ class ProfileSyncServiceStartupTest : public testing::Test {
class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest {
protected:
virtual void CreateSyncService() {
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile_.get());
+ SigninManager* signin = new SigninManager();
signin->SetAuthenticatedUsername("test_user");
service_.reset(new TestProfileSyncService(&factory_,
profile_.get(),
@@ -120,9 +114,6 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
// We've never completed startup.
profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted);
- // Make sure SigninManager doesn't think we're signed in (undoes the call to
- // SetAuthenticatedUsername() in CreateSyncService()).
- SigninManagerFactory::GetForProfile(profile_.get())->SignOut();
// Should not actually start, rather just clean things up and wait
// to be enabled.
@@ -144,7 +135,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
// Create some tokens in the token service; the service will startup when
// it is notified that tokens are available.
- service_->signin()->StartSignIn("test_user", "", "", "");
+ service_->OnUserSubmittedAuth("test_user", "", "", "");
profile_->GetTokenService()->IssueAuthTokenForTest(
GaiaConstants::kSyncService, "sync_token");
profile_->GetTokenService()->IssueAuthTokenForTest(
diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
index 12f7d2e..4b2b915 100644
--- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,8 +18,6 @@
#include "chrome/browser/history/history_backend.h"
#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/history/history_types.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/glue/sync_backend_host.h"
#include "chrome/browser/sync/glue/sync_backend_host_mock.h"
@@ -35,6 +33,7 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_test_util.h"
#include "chrome/browser/sync/protocol/typed_url_specifics.pb.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/test_profile_sync_service.h"
#include "chrome/browser/sync/test/engine/test_id_factory.h"
@@ -181,7 +180,7 @@ class ProfileSyncServiceTypedUrlTest : public AbstractProfileSyncServiceTest {
void StartSyncService(const base::Closure& callback) {
if (!service_.get()) {
- SigninManager* signin = SigninManagerFactory::GetForProfile(&profile_);
+ SigninManager* signin = new SigninManager();
signin->SetAuthenticatedUsername("test");
service_.reset(
new TestProfileSyncService(&factory_,
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index 10cb293..5a43002 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,14 +6,13 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/values.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/signin_manager_factory.h"
-#include "chrome/browser/signin/token_service.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
#include "chrome/browser/sync/js/js_arg_list.h"
#include "chrome/browser/sync/js/js_event_details.h"
#include "chrome/browser/sync/js/js_test_util.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
#include "chrome/browser/sync/test_profile_sync_service.h"
#include "chrome/common/chrome_version_info.h"
@@ -92,8 +91,7 @@ class ProfileSyncServiceTest : public testing::Test {
bool sync_setup_completed,
bool expect_create_dtm) {
if (!service_.get()) {
- SigninManager* signin =
- SigninManagerFactory::GetForProfile(profile_.get());
+ SigninManager* signin = new SigninManager();
signin->SetAuthenticatedUsername("test");
service_.reset(new TestProfileSyncService(&factory_,
profile_.get(),
@@ -144,10 +142,9 @@ class ProfileSyncServiceTest : public testing::Test {
};
TEST_F(ProfileSyncServiceTest, InitialState) {
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile_.get());
service_.reset(new TestProfileSyncService(&factory_,
profile_.get(),
- signin,
+ new SigninManager(),
ProfileSyncService::MANUAL_START,
true,
base::Closure()));
@@ -162,10 +159,9 @@ TEST_F(ProfileSyncServiceTest, DisabledByPolicy) {
profile_->GetTestingPrefService()->SetManagedPref(
prefs::kSyncManaged,
Value::CreateBooleanValue(true));
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile_.get());
service_.reset(new TestProfileSyncService(&factory_,
profile_.get(),
- signin,
+ new SigninManager(),
ProfileSyncService::MANUAL_START,
true,
base::Closure()));
@@ -174,7 +170,7 @@ TEST_F(ProfileSyncServiceTest, DisabledByPolicy) {
}
TEST_F(ProfileSyncServiceTest, AbortedByShutdown) {
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile_.get());
+ SigninManager* signin = new SigninManager();
signin->SetAuthenticatedUsername("test");
service_.reset(new TestProfileSyncService(&factory_,
profile_.get(),
@@ -194,7 +190,7 @@ TEST_F(ProfileSyncServiceTest, AbortedByShutdown) {
}
TEST_F(ProfileSyncServiceTest, DisableAndEnableSyncTemporarily) {
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile_.get());
+ SigninManager* signin = new SigninManager();
signin->SetAuthenticatedUsername("test");
service_.reset(new TestProfileSyncService(&factory_,
profile_.get(),
diff --git a/chrome/browser/signin/signin_manager.cc b/chrome/browser/sync/signin_manager.cc
index 75a4abb..bdb10a0 100644
--- a/chrome/browser/signin/signin_manager.cc
+++ b/chrome/browser/sync/signin_manager.cc
@@ -1,14 +1,14 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "base/command_line.h"
#include "base/string_util.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/util/oauth.h"
#include "chrome/common/chrome_notification_types.h"
@@ -20,13 +20,22 @@
const char kGetInfoEmailKey[] = "email";
SigninManager::SigninManager()
- : profile_(NULL),
- had_two_factor_error_(false),
- last_login_auth_error_(GoogleServiceAuthError::None()) {
-}
+ : profile_(NULL), had_two_factor_error_(false) {}
SigninManager::~SigninManager() {}
+// static
+void SigninManager::RegisterUserPrefs(PrefService* user_prefs) {
+ user_prefs->RegisterBooleanPref(prefs::kSyncUsingOAuth, "",
+ PrefService::UNSYNCABLE_PREF);
+ user_prefs->RegisterStringPref(prefs::kGoogleServicesUsername, "",
+ PrefService::UNSYNCABLE_PREF);
+ user_prefs->RegisterBooleanPref(prefs::kAutologinEnabled, true,
+ PrefService::UNSYNCABLE_PREF);
+ user_prefs->RegisterBooleanPref(prefs::kReverseAutologinEnabled, true,
+ PrefService::UNSYNCABLE_PREF);
+}
+
void SigninManager::Initialize(Profile* profile) {
profile_ = profile;
@@ -34,13 +43,10 @@ void SigninManager::Initialize(Profile* profile) {
prefs::kGoogleServicesUsername);
if (!user.empty())
SetAuthenticatedUsername(user);
- // TokenService can be null for unit tests.
- TokenService* token_service = profile_->GetTokenService();
- if (token_service) {
- token_service->Initialize(GaiaConstants::kChromeSource, profile_);
- if (!authenticated_username_.empty()) {
- token_service->LoadTokensFromDB();
- }
+ profile_->GetTokenService()->Initialize(
+ GaiaConstants::kChromeSource, profile_);
+ if (!authenticated_username_.empty()) {
+ profile_->GetTokenService()->LoadTokensFromDB();
}
}
@@ -182,10 +188,6 @@ void SigninManager::SignOut() {
profile_->GetTokenService()->EraseTokensFromDB();
}
-const GoogleServiceAuthError& SigninManager::GetLoginAuthError() const {
- return last_login_auth_error_;
-}
-
void SigninManager::OnClientLoginSuccess(const ClientLoginResult& result) {
DCHECK(!browser_sync::IsUsingOAuth());
last_result_ = result;
@@ -200,7 +202,6 @@ void SigninManager::OnGetUserInfoSuccess(const std::string& key,
DCHECK(key == kGetInfoEmailKey);
DCHECK(authenticated_username_.empty() || authenticated_username_ == value);
- last_login_auth_error_ = GoogleServiceAuthError::None();
authenticated_username_ = value;
possibly_invalid_username_.clear();
profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
@@ -246,7 +247,6 @@ void SigninManager::OnTokenAuthFailure(const GoogleServiceAuthError& error) {
void SigninManager::OnClientLoginFailure(const GoogleServiceAuthError& error) {
DCHECK(!browser_sync::IsUsingOAuth());
- last_login_auth_error_ = error;
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_GOOGLE_SIGNIN_FAILED,
content::Source<Profile>(profile_),
@@ -306,8 +306,6 @@ void SigninManager::OnUserInfoSuccess(const std::string& email) {
return;
DVLOG(1) << "Sync signin for " << email << " is complete.";
- last_login_auth_error_ = GoogleServiceAuthError::None();
-
authenticated_username_ = email;
profile_->GetPrefs()->SetString(
prefs::kGoogleServicesUsername, authenticated_username_);
diff --git a/chrome/browser/signin/signin_manager.h b/chrome/browser/sync/signin_manager.h
index 8f55010..ff05bdc 100644
--- a/chrome/browser/signin/signin_manager.h
+++ b/chrome/browser/sync/signin_manager.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -14,8 +14,8 @@
// restarts). Until that happens, the signin manager can still be used to
// refresh credentials, but changing the username is not permitted.
-#ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_
-#define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_
+#ifndef CHROME_BROWSER_SYNC_SIGNIN_MANAGER_H_
+#define CHROME_BROWSER_SYNC_SIGNIN_MANAGER_H_
#pragma once
#include <string>
@@ -24,7 +24,6 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/net/gaia/gaia_oauth_fetcher.h"
-#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/common/net/gaia/gaia_auth_consumer.h"
#include "chrome/common/net/gaia/google_service_auth_error.h"
#include "content/public/browser/notification_observer.h"
@@ -48,12 +47,14 @@ struct GoogleServiceSigninSuccessDetails {
class SigninManager : public GaiaAuthConsumer,
public GaiaOAuthConsumer,
- public content::NotificationObserver,
- public ProfileKeyedService {
+ public content::NotificationObserver {
public:
SigninManager();
virtual ~SigninManager();
+ // Call to register our prefs.
+ static void RegisterUserPrefs(PrefService* user_prefs);
+
// If user was signed in, load tokens from DB if available.
void Initialize(Profile* profile);
bool IsInitialized() const;
@@ -90,11 +91,7 @@ class SigninManager : public GaiaAuthConsumer,
// Sign a user out, removing the preference, erasing all keys
// associated with the user, and canceling all auth in progress.
- virtual void SignOut();
-
- // Returns the auth error associated with the last login attempt, or None if
- // there have been no login failures.
- virtual const GoogleServiceAuthError& GetLoginAuthError() const;
+ void SignOut();
// GaiaAuthConsumer
virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE;
@@ -127,7 +124,6 @@ class SigninManager : public GaiaAuthConsumer,
const content::NotificationDetails& details) OVERRIDE;
private:
- friend class FakeSigninManager;
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ClearTransientSigninData);
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorSuccess);
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorFailure);
@@ -164,13 +160,9 @@ class SigninManager : public GaiaAuthConsumer,
// Register for notifications from the TokenService.
content::NotificationRegistrar registrar_;
- // The last error we received when logging in (used to retrieve details like
- // captchas, etc).
- GoogleServiceAuthError last_login_auth_error_;
-
std::string authenticated_username_;
DISALLOW_COPY_AND_ASSIGN(SigninManager);
};
-#endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_
+#endif // CHROME_BROWSER_SYNC_SIGNIN_MANAGER_H_
diff --git a/chrome/browser/signin/signin_manager_fake.cc b/chrome/browser/sync/signin_manager_fake.cc
index 0eae17d..da486f9 100644
--- a/chrome/browser/signin/signin_manager_fake.cc
+++ b/chrome/browser/sync/signin_manager_fake.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/signin/signin_manager_fake.h"
+#include "chrome/browser/sync/signin_manager_fake.h"
FakeSigninManager::FakeSigninManager() {}
@@ -14,12 +14,3 @@ void FakeSigninManager::StartSignIn(const std::string& username,
const std::string& login_captcha) {
SetAuthenticatedUsername(username);
}
-
-void FakeSigninManager::SignOut() {
- authenticated_username_.clear();
-}
-
-// static
-ProfileKeyedService* FakeSigninManager::Build(Profile* profile) {
- return new FakeSigninManager();
-}
diff --git a/chrome/browser/signin/signin_manager_fake.h b/chrome/browser/sync/signin_manager_fake.h
index a1e1c42..563bc02 100644
--- a/chrome/browser/signin/signin_manager_fake.h
+++ b/chrome/browser/sync/signin_manager_fake.h
@@ -1,18 +1,15 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FAKE_H_
-#define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FAKE_H_
+#ifndef CHROME_BROWSER_SYNC_SIGNIN_MANAGER_FAKE_H_
+#define CHROME_BROWSER_SYNC_SIGNIN_MANAGER_FAKE_H_
#pragma once
#include <string>
#include "base/compiler_specific.h"
-#include "chrome/browser/signin/signin_manager.h"
-
-class Profile;
-class ProfileKeyedService;
+#include "chrome/browser/sync/signin_manager.h"
// A signin manager that bypasses actual authentication routines with servers
// and accepts the credentials provided to StartSignIn.
@@ -25,10 +22,6 @@ class FakeSigninManager : public SigninManager {
const std::string& password,
const std::string& login_token,
const std::string& login_captcha) OVERRIDE;
- virtual void SignOut() OVERRIDE;
-
- // Helper function to be used with ProfileKeyedService::SetTestingFactory().
- static ProfileKeyedService* Build(Profile* profile);
};
-#endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_FAKE_H_
+#endif // CHROME_BROWSER_SYNC_SIGNIN_MANAGER_FAKE_H_
diff --git a/chrome/browser/signin/signin_manager_unittest.cc b/chrome/browser/sync/signin_manager_unittest.cc
index 410b632..a26be73 100644
--- a/chrome/browser/signin/signin_manager_unittest.cc
+++ b/chrome/browser/sync/signin_manager_unittest.cc
@@ -1,16 +1,16 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
+#include "chrome/browser/net/gaia/token_service.h"
+#include "chrome/browser/net/gaia/token_service_unittest.h"
#include "chrome/browser/password_manager/encryptor.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/signin/token_service.h"
-#include "chrome/browser/signin/token_service_unittest.h"
#include "chrome/browser/sync/util/oauth.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/chrome_notification_types.h"
diff --git a/chrome/browser/sync/sync_global_error_unittest.cc b/chrome/browser/sync/sync_global_error_unittest.cc
index e795dc5..d7eab6e 100644
--- a/chrome/browser/sync/sync_global_error_unittest.cc
+++ b/chrome/browser/sync/sync_global_error_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,8 +6,8 @@
#include "base/basictypes.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/test/base/testing_profile.h"
#include "content/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock-actions.h"
diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc
index 9806c76..b9d1090 100644
--- a/chrome/browser/sync/sync_setup_flow.cc
+++ b/chrome/browser/sync/sync_setup_flow.cc
@@ -14,7 +14,6 @@
#include "base/values.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/sync_setup_flow_handler.h"
#include "chrome/browser/sync/syncable/model_type.h"
@@ -239,15 +238,17 @@ SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service,
return new SyncSetupFlow(start, end, container, service);
}
-void SyncSetupFlow::GetArgsForGaiaLogin(DictionaryValue* args) {
- const GoogleServiceAuthError& error = service_->GetAuthError();
- if (!last_attempted_user_email_.empty()) {
- args->SetString("user", last_attempted_user_email_);
+// static
+void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service,
+ DictionaryValue* args) {
+ const GoogleServiceAuthError& error = service->GetAuthError();
+ if (!service->last_attempted_user_email().empty()) {
+ args->SetString("user", service->last_attempted_user_email());
args->SetInteger("error", error.state());
args->SetBoolean("editable_user", true);
} else {
string16 user;
- user = UTF8ToUTF16(service_->profile()->GetPrefs()->GetString(
+ user = UTF8ToUTF16(service->profile()->GetPrefs()->GetString(
prefs::kGoogleServicesUsername));
args->SetString("user", user);
args->SetInteger("error", 0);
@@ -257,20 +258,21 @@ void SyncSetupFlow::GetArgsForGaiaLogin(DictionaryValue* args) {
args->SetString("captchaUrl", error.captcha().image_url.spec());
}
-void SyncSetupFlow::GetArgsForConfigure(DictionaryValue* args) {
+void SyncSetupFlow::GetArgsForConfigure(ProfileSyncService* service,
+ DictionaryValue* args) {
// The SYNC_EVERYTHING case will set this to true.
args->SetBoolean("showSyncEverythingPage", false);
args->SetBoolean("syncAllDataTypes",
- service_->profile()->GetPrefs()->GetBoolean(
+ service->profile()->GetPrefs()->GetBoolean(
prefs::kSyncKeepEverythingSynced));
// Bookmarks, Preferences, and Themes are launched for good, there's no
// going back now. Check if the other data types are registered though.
const syncable::ModelTypeSet registered_types =
- service_->GetRegisteredDataTypes();
+ service->GetRegisteredDataTypes();
const syncable::ModelTypeSet preferred_types =
- service_->GetPreferredDataTypes();
+ service->GetPreferredDataTypes();
args->SetBoolean("passwordsRegistered",
registered_types.Has(syncable::PASSWORDS));
args->SetBoolean("autofillRegistered",
@@ -306,21 +308,23 @@ void SyncSetupFlow::GetArgsForConfigure(DictionaryValue* args) {
!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableSyncEncryption));
- bool encrypt_all = service_->EncryptEverythingEnabled();
- if (service_->encryption_pending())
+ bool encrypt_all = service->EncryptEverythingEnabled();
+ if (service->encryption_pending())
encrypt_all = true;
args->SetBoolean("encryptAllData", encrypt_all);
// Load the parameters for the encryption tab.
- args->SetBoolean("usePassphrase", service_->IsUsingSecondaryPassphrase());
+ args->SetBoolean("usePassphrase", service->IsUsingSecondaryPassphrase());
// Determine if we need a passphrase or not, and if so, prompt the user.
- if (service_->IsPassphraseRequiredForDecryption()) {
- // We need a passphrase, so we have to prompt the user.
+ if (service->IsPassphraseRequiredForDecryption() &&
+ (service->IsUsingSecondaryPassphrase() || cached_passphrase_.empty())) {
+ // We need a passphrase, and either it's an explicit passphrase, or we
+ // don't have a cached gaia passphrase, so we have to prompt the user.
args->SetBoolean("show_passphrase", true);
// Tell the UI layer what kind of passphrase we need.
args->SetBoolean("need_google_passphrase",
- !service_->IsUsingSecondaryPassphrase());
+ !service->IsUsingSecondaryPassphrase());
args->SetBoolean("passphrase_creation_rejected",
user_tried_creating_explicit_passphrase_);
args->SetBoolean("passphrase_setting_rejected",
@@ -399,7 +403,6 @@ void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) {
break;
}
- service_->SetUIShouldDepictAuthInProgress(false);
service_->OnUserCancelledDialog();
delete this;
}
@@ -408,27 +411,16 @@ void SyncSetupFlow::OnUserSubmittedAuth(const std::string& username,
const std::string& password,
const std::string& captcha,
const std::string& access_code) {
- last_attempted_user_email_ = username;
- service_->SetUIShouldDepictAuthInProgress(true);
-
- // If we're just being called to provide an ASP, then pass it to the
- // SigninManager and wait for the next step.
- if (!access_code.empty()) {
- service_->signin()->ProvideSecondFactorAccessCode(access_code);
- return;
- }
-
- // Kick off a sign-in through the signin manager.
- SigninManager* signin = service_->signin();
- signin->StartSignIn(username,
- password,
- signin->GetLoginAuthError().captcha().token,
- captcha);
+ // It's possible to receive an empty password (e.g. for ASP's), in which case
+ // we don't want to overwrite any previously cached password.
+ if (!password.empty())
+ cached_passphrase_ = password;
+ service_->OnUserSubmittedAuth(username, password, captcha, access_code);
}
void SyncSetupFlow::OnUserSubmittedOAuth(
const std::string& oauth1_request_token) {
- service_->signin()->StartOAuthSignIn(oauth1_request_token);
+ service_->OnUserSubmittedOAuth(oauth1_request_token);
}
void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) {
@@ -453,6 +445,22 @@ void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) {
// report an error if the passphrase setting failed.
user_tried_setting_passphrase_ = true;
set_new_decryption_passphrase = true;
+ } else if (!service_->IsUsingSecondaryPassphrase() &&
+ !cached_passphrase_.empty()) {
+ // Service needs a GAIA passphrase and we have one cached, so try it.
+ service_->SetPassphrase(cached_passphrase_, false);
+ cached_passphrase_.clear();
+ set_new_decryption_passphrase = true;
+ } else {
+ // We can get here if the user changes their GAIA passphrase but still has
+ // data encrypted with the old passphrase. The UI prompts the user for their
+ // passphrase, but they might just leave it blank/disable the encrypted
+ // types.
+ // No gaia passphrase cached or set, so make sure the ProfileSyncService
+ // wasn't expecting one.
+ DLOG_IF(WARNING, !service_->IsUsingSecondaryPassphrase() &&
+ service_->IsPassphraseRequiredForDecryption()) <<
+ "Google passphrase required but not provided by UI";
}
// Set the secondary passphrase, either as a decryption passphrase, or
@@ -575,14 +583,23 @@ void SyncSetupFlow::ActivateState(SyncSetupWizard::State state) {
}
case SyncSetupWizard::GAIA_LOGIN: {
DictionaryValue args;
- GetArgsForGaiaLogin(&args);
+ SyncSetupFlow::GetArgsForGaiaLogin(service_, &args);
flow_handler_->ShowGaiaLogin(args);
break;
}
case SyncSetupWizard::GAIA_SUCCESS:
- // Authentication is complete now.
- service_->SetUIShouldDepictAuthInProgress(false);
if (end_state_ == SyncSetupWizard::GAIA_SUCCESS) {
+ // The user has just re-authed - set the passphrase so we can re-encrypt
+ // if necessary. If we are currently encrypting with an explicit
+ // passphrase, this does nothing.
+ // TODO(atwilson): Move all the code dealing with the implicit GAIA
+ // passphrase back into ProfileSyncService in a
+ // NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL listener once we get rid of
+ // SyncSetupFlow.
+ if (!cached_passphrase_.empty()) {
+ service_->SetPassphrase(cached_passphrase_, false);
+ cached_passphrase_.clear();
+ }
flow_handler_->ShowGaiaSuccessAndClose();
break;
}
@@ -590,20 +607,21 @@ void SyncSetupFlow::ActivateState(SyncSetupWizard::State state) {
break;
case SyncSetupWizard::SYNC_EVERYTHING: {
DictionaryValue args;
- GetArgsForConfigure(&args);
+ SyncSetupFlow::GetArgsForConfigure(service_, &args);
args.SetBoolean("showSyncEverythingPage", true);
flow_handler_->ShowConfigure(args);
break;
}
case SyncSetupWizard::CONFIGURE: {
DictionaryValue args;
- GetArgsForConfigure(&args);
+ SyncSetupFlow::GetArgsForConfigure(service_, &args);
flow_handler_->ShowConfigure(args);
break;
}
case SyncSetupWizard::ENTER_PASSPHRASE: {
DictionaryValue args;
- GetArgsForConfigure(&args);
+ SyncSetupFlow::GetArgsForConfigure(service_, &args);
+ GetArgsForConfigure(service_, &args);
// TODO(atwilson): Remove ShowPassphraseEntry in favor of using
// ShowConfigure() - http://crbug.com/90786.
flow_handler_->ShowPassphraseEntry(args);
@@ -614,7 +632,7 @@ void SyncSetupFlow::ActivateState(SyncSetupWizard::State state) {
// SyncSetupFlowHandler (crbug.com/92722) but for now just transition
// to the login state with a special error code.
DictionaryValue args;
- GetArgsForGaiaLogin(&args);
+ SyncSetupFlow::GetArgsForGaiaLogin(service_, &args);
args.SetInteger("error", GoogleServiceAuthError::SERVICE_UNAVAILABLE);
current_state_ = SyncSetupWizard::GAIA_LOGIN;
flow_handler_->ShowGaiaLogin(args);
@@ -629,7 +647,7 @@ void SyncSetupFlow::ActivateState(SyncSetupWizard::State state) {
// TODO(sync): Update this error handling to allow different platforms to
// display the error appropriately (http://crbug.com/92722).
DictionaryValue args;
- GetArgsForGaiaLogin(&args);
+ SyncSetupFlow::GetArgsForGaiaLogin(service_, &args);
args.SetBoolean("fatalError", true);
current_state_ = SyncSetupWizard::GAIA_LOGIN;
flow_handler_->ShowGaiaLogin(args);
diff --git a/chrome/browser/sync/sync_setup_flow.h b/chrome/browser/sync/sync_setup_flow.h
index 2338d6f..7939f0f 100644
--- a/chrome/browser/sync/sync_setup_flow.h
+++ b/chrome/browser/sync/sync_setup_flow.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -62,11 +62,13 @@ class SyncSetupFlow {
SyncSetupWizard::State start,
SyncSetupWizard::State end);
- // Fills |args| with "user" and "error" arguments per our current state.
- void GetArgsForGaiaLogin(DictionaryValue* args);
+ // Fills |args| with "user" and "error" arguments by querying |service|.
+ static void GetArgsForGaiaLogin(
+ const ProfileSyncService* service,
+ DictionaryValue* args);
// Fills |args| for the configure screen (Choose Data Types/Encryption)
- void GetArgsForConfigure(DictionaryValue* args);
+ void GetArgsForConfigure(ProfileSyncService* service, DictionaryValue* args);
// Attaches the |handler| to this flow. Returns true if successful and false
// if a handler has already been attached.
@@ -101,7 +103,6 @@ class SyncSetupFlow {
void OnDialogClosed(const std::string& json_retval);
private:
- friend class ProfileSyncServiceForWizardTest;
FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, InitialStepLogin);
FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, ChooseDataTypesSetsPrefs);
FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DialogCancelled);
@@ -154,9 +155,9 @@ class SyncSetupFlow {
// reflect this in the UI.
bool user_tried_setting_passphrase_;
- // Cache of the last name the client attempted to authenticate.
- // TODO(atwilson): Move this out of here entirely and up into the UI layer.
- std::string last_attempted_user_email_;
+ // We track the passphrase the user entered so we can set it when configuring
+ // the ProfileSyncService.
+ std::string cached_passphrase_;
DISALLOW_COPY_AND_ASSIGN(SyncSetupFlow);
};
diff --git a/chrome/browser/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc
index 90ccf02..bff5d38 100644
--- a/chrome/browser/sync/sync_setup_wizard_unittest.cc
+++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -11,9 +11,9 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/pref_service_mock_builder.h"
#include "chrome/browser/prefs/testing_pref_store.h"
-#include "chrome/browser/signin/signin_manager_fake.h"
#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/sync_setup_flow.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
@@ -57,75 +57,61 @@ class MockSyncSetupHandler : public OptionsSyncSetupHandler {
DISALLOW_COPY_AND_ASSIGN(MockSyncSetupHandler);
};
-class SigninManagerMock : public FakeSigninManager {
- public:
- SigninManagerMock() : auth_error_(AuthError::None()) {}
-
- virtual void StartSignIn(const std::string& username,
- const std::string& password,
- const std::string& token,
- const std::string& captcha) OVERRIDE {
- FakeSigninManager::StartSignIn(username, password, token, captcha);
- username_ = username;
- password_ = password;
- captcha_ = captcha;
- }
-
- virtual const AuthError& GetLoginAuthError() const OVERRIDE {
- return auth_error_;
- }
-
- void ResetTestStats() {
- username_.clear();
- password_.clear();
- captcha_.clear();
- }
-
- AuthError auth_error_;
- std::string username_;
- std::string password_;
- std::string captcha_;
-};
-
// A PSS subtype to inject.
class ProfileSyncServiceForWizardTest : public ProfileSyncService {
public:
ProfileSyncServiceForWizardTest(ProfileSyncComponentsFactory* factory,
Profile* profile,
ProfileSyncService::StartBehavior behavior)
- : ProfileSyncService(factory, profile, NULL, behavior),
+ : ProfileSyncService(factory, profile, new SigninManager(), behavior),
user_cancelled_dialog_(false),
is_using_secondary_passphrase_(false),
encrypt_everything_(false) {
- signin_ = &mock_signin_;
ResetTestStats();
}
virtual ~ProfileSyncServiceForWizardTest() {}
- virtual void OnUserChoseDatatypes(
- bool sync_everything, syncable::ModelTypeSet chosen_types) OVERRIDE {
+ virtual void OnUserSubmittedAuth(const std::string& username,
+ const std::string& password,
+ const std::string& captcha,
+ const std::string& access_code) {
+ username_ = username;
+ password_ = password;
+ captcha_ = captcha;
+ }
+
+ virtual void OnUserChoseDatatypes(bool sync_everything,
+ syncable::ModelTypeSet chosen_types) {
user_chose_data_types_ = true;
chosen_data_types_ = chosen_types;
}
- virtual void OnUserCancelledDialog() OVERRIDE {
+ virtual void OnUserCancelledDialog() {
user_cancelled_dialog_ = true;
}
virtual void SetPassphrase(const std::string& passphrase,
- bool is_explicit) OVERRIDE {
+ bool is_explicit) {
passphrase_ = passphrase;
}
- virtual bool IsUsingSecondaryPassphrase() const OVERRIDE {
+ virtual string16 GetAuthenticatedUsername() const {
+ return UTF8ToUTF16(username_);
+ }
+
+ virtual bool IsUsingSecondaryPassphrase() const {
return is_using_secondary_passphrase_;
}
+ void set_auth_state(const std::string& last_email,
+ const AuthError& error) {
+ last_attempted_user_email_ = last_email;
+ last_auth_error_ = error;
+ }
+
void set_last_auth_error(const AuthError& error) {
- // Set the cached auth error in the SigninManager and ProfileSyncService.
last_auth_error_ = error;
- mock_signin_.auth_error_ = error;
}
void set_is_using_secondary_passphrase(bool secondary) {
@@ -137,11 +123,11 @@ class ProfileSyncServiceForWizardTest : public ProfileSyncService {
passphrase_required_reason_ = reason;
}
- virtual bool sync_initialized() const OVERRIDE {
+ virtual bool sync_initialized() const {
return true;
}
- virtual bool EncryptEverythingEnabled() const OVERRIDE {
+ virtual bool EncryptEverythingEnabled() const {
return encrypt_everything_;
}
@@ -150,14 +136,16 @@ class ProfileSyncServiceForWizardTest : public ProfileSyncService {
}
void ResetTestStats() {
- mock_signin_.ResetTestStats();
+ username_.clear();
+ password_.clear();
+ captcha_.clear();
user_cancelled_dialog_ = false;
user_chose_data_types_ = false;
keep_everything_synced_ = false;
chosen_data_types_.Clear();
}
- virtual void ShowSyncSetup(const std::string& sub_page) OVERRIDE {
+ virtual void ShowSyncSetup(const std::string& sub_page) {
// Do Nothing.
}
@@ -169,7 +157,9 @@ class ProfileSyncServiceForWizardTest : public ProfileSyncService {
return &wizard_;
}
- SigninManagerMock mock_signin_;
+ std::string username_;
+ std::string password_;
+ std::string captcha_;
bool user_cancelled_dialog_;
bool user_chose_data_types_;
bool keep_everything_synced_;
@@ -281,21 +271,20 @@ TEST_F(SyncSetupWizardTest, InitialStepLogin) {
handler_.HandleSubmitAuth(&credentials);
EXPECT_TRUE(wizard_->IsVisible());
EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
- EXPECT_EQ(kTestUser, service_->mock_signin_.username_);
- EXPECT_EQ(kTestPassword, service_->mock_signin_.password_);
- EXPECT_EQ(kTestCaptcha, service_->mock_signin_.captcha_);
+ EXPECT_EQ(kTestUser, service_->username_);
+ EXPECT_EQ(kTestPassword, service_->password_);
+ EXPECT_EQ(kTestCaptcha, service_->captcha_);
EXPECT_FALSE(service_->user_cancelled_dialog_);
service_->ResetTestStats();
// Simulate failed credentials.
AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS);
- flow_->last_attempted_user_email_ = kTestUser;
- service_->set_last_auth_error(invalid_gaia);
+ service_->set_auth_state(kTestUser, invalid_gaia);
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
EXPECT_TRUE(wizard_->IsVisible());
EXPECT_EQ(SyncSetupWizard::GAIA_LOGIN, flow_->current_state_);
DictionaryValue dialog_args;
- flow_->GetArgsForGaiaLogin(&dialog_args);
+ SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
EXPECT_EQ(4U, dialog_args.size());
std::string actual_user;
dialog_args.GetString("user", &actual_user);
@@ -303,16 +292,14 @@ TEST_F(SyncSetupWizardTest, InitialStepLogin) {
int error = -1;
dialog_args.GetInteger("error", &error);
EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error);
- flow_->last_attempted_user_email_ = kTestUser;
- service_->set_last_auth_error(AuthError::None());
+ service_->set_auth_state(kTestUser, AuthError::None());
// Simulate captcha.
AuthError captcha_error(AuthError::FromCaptchaChallenge(
std::string(), GURL(kTestCaptchaUrl), GURL()));
- flow_->last_attempted_user_email_ = kTestUser;
- service_->set_last_auth_error(captcha_error);
+ service_->set_auth_state(kTestUser, captcha_error);
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
- flow_->GetArgsForGaiaLogin(&dialog_args);
+ SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
EXPECT_EQ(4U, dialog_args.size());
std::string captcha_url;
dialog_args.GetString("captchaUrl", &captcha_url);
@@ -320,8 +307,7 @@ TEST_F(SyncSetupWizardTest, InitialStepLogin) {
error = -1;
dialog_args.GetInteger("error", &error);
EXPECT_EQ(static_cast<int>(AuthError::CAPTCHA_REQUIRED), error);
- flow_->last_attempted_user_email_ = kTestUser;
- service_->set_last_auth_error(AuthError::None());
+ service_->set_auth_state(kTestUser, AuthError::None());
// Simulate success.
wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
@@ -433,8 +419,8 @@ TEST_F(SyncSetupWizardTest, DialogCancelled) {
CloseSetupUI();
EXPECT_FALSE(wizard_->IsVisible());
EXPECT_TRUE(service_->user_cancelled_dialog_);
- EXPECT_EQ(std::string(), service_->mock_signin_.username_);
- EXPECT_EQ(std::string(), service_->mock_signin_.password_);
+ EXPECT_EQ(std::string(), service_->username_);
+ EXPECT_EQ(std::string(), service_->password_);
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
AttachSyncSetupHandler();
@@ -444,8 +430,8 @@ TEST_F(SyncSetupWizardTest, DialogCancelled) {
CloseSetupUI();
EXPECT_FALSE(wizard_->IsVisible());
EXPECT_TRUE(service_->user_cancelled_dialog_);
- EXPECT_EQ(std::string(), service_->mock_signin_.username_);
- EXPECT_EQ(std::string(), service_->mock_signin_.password_);
+ EXPECT_EQ(std::string(), service_->username_);
+ EXPECT_EQ(std::string(), service_->password_);
}
TEST_F(SyncSetupWizardTest, InvalidTransitions) {
@@ -526,13 +512,12 @@ TEST_F(SyncSetupWizardTest, DiscreteRunGaiaLogin) {
EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, flow_->end_state_);
AuthError invalid_gaia(AuthError::INVALID_GAIA_CREDENTIALS);
- flow_->last_attempted_user_email_ = kTestUser;
- service_->set_last_auth_error(invalid_gaia);
+ service_->set_auth_state(kTestUser, invalid_gaia);
wizard_->Step(SyncSetupWizard::GAIA_LOGIN);
EXPECT_TRUE(wizard_->IsVisible());
DictionaryValue dialog_args;
- flow_->GetArgsForGaiaLogin(&dialog_args);
+ SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
EXPECT_EQ(4U, dialog_args.size());
std::string actual_user;
dialog_args.GetString("user", &actual_user);
@@ -540,8 +525,7 @@ TEST_F(SyncSetupWizardTest, DiscreteRunGaiaLogin) {
int error = -1;
dialog_args.GetInteger("error", &error);
EXPECT_EQ(static_cast<int>(AuthError::INVALID_GAIA_CREDENTIALS), error);
- flow_->last_attempted_user_email_ = kTestUser;
- service_->set_last_auth_error(AuthError::None());
+ service_->set_auth_state(kTestUser, AuthError::None());
wizard_->Step(SyncSetupWizard::GAIA_SUCCESS);
}
@@ -632,7 +616,7 @@ TEST_F(SyncSetupWizardCrosTest, CrosAuthSetup) {
EXPECT_EQ(SyncSetupWizard::GAIA_SUCCESS, flow_->end_state_);
DictionaryValue dialog_args;
- flow_->GetArgsForGaiaLogin(&dialog_args);
+ SyncSetupFlow::GetArgsForGaiaLogin(service_, &dialog_args);
EXPECT_EQ(4U, dialog_args.size());
std::string actual_user;
dialog_args.GetString("user", &actual_user);
diff --git a/chrome/browser/sync/test_profile_sync_service.cc b/chrome/browser/sync/test_profile_sync_service.cc
index 90c71d4..f6802d4 100644
--- a/chrome/browser/sync/test_profile_sync_service.cc
+++ b/chrome/browser/sync/test_profile_sync_service.cc
@@ -1,10 +1,9 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/sync/test_profile_sync_service.h"
-#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/abstract_profile_sync_service_test.h"
#include "chrome/browser/sync/glue/data_type_controller.h"
#include "chrome/browser/sync/glue/sync_backend_host.h"
@@ -13,6 +12,7 @@
#include "chrome/browser/sync/profile_sync_components_factory.h"
#include "chrome/browser/sync/protocol/encryption.pb.h"
#include "chrome/browser/sync/sessions/session_state.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/test/test_http_bridge_factory.h"
@@ -142,8 +142,7 @@ TestProfileSyncService::TestProfileSyncService(
SetSyncSetupCompleted();
}
-TestProfileSyncService::~TestProfileSyncService() {
-}
+TestProfileSyncService::~TestProfileSyncService() {}
void TestProfileSyncService::SetInitialSyncEndedForAllTypes() {
UserShare* user_share = GetUserShare();
diff --git a/chrome/browser/ui/auto_login_info_bar_delegate.cc b/chrome/browser/ui/auto_login_info_bar_delegate.cc
index 53c8241..af5df0c 100644
--- a/chrome/browser/ui/auto_login_info_bar_delegate.cc
+++ b/chrome/browser/ui/auto_login_info_bar_delegate.cc
@@ -8,8 +8,8 @@
#include "base/string_split.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
#include "chrome/common/chrome_notification_types.h"
diff --git a/chrome/browser/ui/auto_login_prompter.cc b/chrome/browser/ui/auto_login_prompter.cc
index 79a0a5d..fef06bd 100644
--- a/chrome/browser/ui/auto_login_prompter.cc
+++ b/chrome/browser/ui/auto_login_prompter.cc
@@ -9,11 +9,11 @@
#include "base/logging.h"
#include "base/string_split.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/signin_manager.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/ui/auto_login_info_bar_delegate.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index fa779f9..ac18f52 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -4354,9 +4354,7 @@ void Browser::Observe(int type,
void Browser::OnStateChanged() {
DCHECK(profile_->GetProfileSyncService());
- // For unit tests, we don't have a window.
- if (!window_)
- return;
+
const bool show_main_ui = IsShowingMainUI(window_->IsFullscreen());
command_updater_.UpdateCommandEnabled(IDC_SYNC_BOOKMARKS,
show_main_ui && profile_->GetOriginalProfile()->IsSyncAccessible());
diff --git a/chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc b/chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc
index 0d5f261..1c42227 100644
--- a/chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc
+++ b/chrome/browser/ui/webui/ntp/new_tab_ui_uitest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,7 +7,7 @@
#include "base/test/test_timeouts.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/prefs/pref_value_store.h"
-#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/json_pref_store.h"
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index a37b578..9837b94 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,9 +15,9 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
-#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/protocol/service_constants.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/sync_setup_flow.h"
#include "chrome/browser/sync/util/oauth.h"
#include "chrome/browser/ui/browser_list.h"
@@ -662,9 +662,10 @@ bool SyncSetupHandler::IsLoginAuthDataValid(const std::string& username,
}
void SyncSetupHandler::ShowLoginErrorMessage(const string16& error_message) {
- DCHECK(flow_);
DictionaryValue args;
- flow_->GetArgsForGaiaLogin(&args);
+ Profile* profile = Profile::FromWebUI(web_ui());
+ ProfileSyncService* service = profile->GetProfileSyncService();
+ SyncSetupFlow::GetArgsForGaiaLogin(service, &args);
args.SetString("error_message", error_message);
ShowGaiaLogin(args);
}
diff --git a/chrome/browser/ui/webui/sync_setup_handler2.cc b/chrome/browser/ui/webui/sync_setup_handler2.cc
index 0008770..b82e702 100644
--- a/chrome/browser/ui/webui/sync_setup_handler2.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler2.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,9 +15,9 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
-#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/protocol/service_constants.h"
+#include "chrome/browser/sync/signin_manager.h"
#include "chrome/browser/sync/sync_setup_flow.h"
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/sync/util/oauth.h"
@@ -659,9 +659,10 @@ bool SyncSetupHandler2::IsLoginAuthDataValid(const std::string& username,
}
void SyncSetupHandler2::ShowLoginErrorMessage(const string16& error_message) {
- DCHECK(flow_);
DictionaryValue args;
- flow_->GetArgsForGaiaLogin(&args);
+ Profile* profile = Profile::FromWebUI(web_ui());
+ ProfileSyncService* service = profile->GetProfileSyncService();
+ SyncSetupFlow::GetArgsForGaiaLogin(service, &args);
args.SetString("error_message", error_message);
ShowGaiaLogin(args);
}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index c5abb17..dbd5e99 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1633,6 +1633,8 @@
'browser/net/gaia/gaia_oauth_consumer.h',
'browser/net/gaia/gaia_oauth_fetcher.cc',
'browser/net/gaia/gaia_oauth_fetcher.h',
+ 'browser/net/gaia/token_service.cc',
+ 'browser/net/gaia/token_service.h',
'browser/net/load_timing_observer.cc',
'browser/net/load_timing_observer.h',
'browser/net/net_log_logger.cc',
@@ -2180,12 +2182,6 @@
'browser/shell_integration_linux.cc',
'browser/shell_integration_mac.mm',
'browser/shell_integration_win.cc',
- 'browser/signin/signin_manager.cc',
- 'browser/signin/signin_manager.h',
- 'browser/signin/signin_manager_factory.cc',
- 'browser/signin/signin_manager_factory.h',
- 'browser/signin/token_service.cc',
- 'browser/signin/token_service.h',
'browser/simple_message_box.h',
'browser/speech/chrome_speech_input_manager.cc',
'browser/speech/chrome_speech_input_manager.h',
@@ -2338,6 +2334,8 @@
'browser/sync/profile_sync_service_observer.h',
'browser/sync/retry_verifier.cc',
'browser/sync/retry_verifier.h',
+ 'browser/sync/signin_manager.cc',
+ 'browser/sync/signin_manager.h',
'browser/sync/sync_global_error.cc',
'browser/sync/sync_global_error.h',
'browser/sync/sync_prefs.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index b015823..8446758 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1536,6 +1536,8 @@
'browser/net/chrome_net_log_unittest.cc',
'browser/net/connection_tester_unittest.cc',
'browser/net/gaia/gaia_oauth_fetcher_unittest.cc',
+ 'browser/net/gaia/token_service_unittest.cc',
+ 'browser/net/gaia/token_service_unittest.h',
'browser/net/http_server_properties_manager_unittest.cc',
'browser/net/load_timing_observer_unittest.cc',
'browser/net/network_stats_unittest.cc',
@@ -1683,11 +1685,6 @@
'browser/sessions/session_backend_unittest.cc',
'browser/sessions/session_service_unittest.cc',
'browser/shell_integration_unittest.cc',
- 'browser/signin/signin_manager_unittest.cc',
- 'browser/signin/signin_manager_fake.cc',
- 'browser/signin/signin_manager_fake.h',
- 'browser/signin/token_service_unittest.cc',
- 'browser/signin/token_service_unittest.h',
'browser/speech/speech_input_bubble_controller_unittest.cc',
'browser/spellchecker/spellcheck_platform_mac_unittest.cc',
'browser/spellchecker/spellcheck_profile_unittest.cc',
@@ -1749,6 +1746,9 @@
'browser/sync/profile_sync_service_unittest.cc',
'browser/sync/profile_sync_test_util.cc',
'browser/sync/profile_sync_test_util.h',
+ 'browser/sync/signin_manager_fake.cc',
+ 'browser/sync/signin_manager_fake.h',
+ 'browser/sync/signin_manager_unittest.cc',
'browser/sync/sync_global_error_unittest.cc',
'browser/sync/sync_prefs_unittest.cc',
'browser/sync/sync_setup_wizard_unittest.cc',
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index e3d2ebe..17ae2c7 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/history_backend.h"
#include "chrome/browser/history/top_sites.h"
+#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/net/proxy_service_factory.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
@@ -35,7 +36,6 @@
#include "chrome/browser/search_engines/template_url_fetcher.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
-#include "chrome/browser/signin/token_service.h"
#include "chrome/browser/speech/chrome_speech_input_preferences.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/browser/ui/find_bar/find_bar_state.h"
@@ -576,6 +576,7 @@ PasswordStore* TestingProfile::GetPasswordStore(ServiceAccessType access) {
}
void TestingProfile::SetPrefService(PrefService* prefs) {
+ DCHECK(!prefs_.get());
prefs_.reset(prefs);
}
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index 203923f..e1909e5 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -281,8 +281,8 @@ class TestingProfile : public Profile {
// history service processes all pending requests.
void BlockUntilHistoryProcessesPendingRequests();
- virtual TokenService* GetTokenService() OVERRIDE;
// Creates and initializes a profile sync service if the tests require one.
+ virtual TokenService* GetTokenService() OVERRIDE;
virtual ProfileSyncService* GetProfileSyncService() OVERRIDE;
virtual ChromeBlobStorageContext* GetBlobStorageContext() OVERRIDE;
virtual ExtensionInfoMap* GetExtensionInfoMap() OVERRIDE;
diff --git a/tools/valgrind/memcheck/suppressions.txt b/tools/valgrind/memcheck/suppressions.txt
index 49e23f0..3f8ee30 100644
--- a/tools/valgrind/memcheck/suppressions.txt
+++ b/tools/valgrind/memcheck/suppressions.txt
@@ -2272,6 +2272,42 @@
fun:_Znw*
fun:_ZN11ProfileImpl20CreateWebDataServiceEv
fun:_ZN11ProfileImpl17GetWebDataServiceEN7Profile17ServiceAccessTypeE
+ fun:_ZN12TokenService10InitializeEPKcP7Profile
+ fun:_ZN13SigninManager10InitializeEP7Profile
+ fun:_ZN11ProfileImpl*
+}
+{
+ bug_56090b
+ Memcheck:Leak
+ fun:_Znw*
+ fun:_ZN11ProfileImpl20CreateWebDataServiceEv
+ fun:_ZN11ProfileImpl17GetWebDataServiceEN7Profile17ServiceAccessTypeE
+ fun:_ZN19PersonalDataManager12LoadProfilesEv
+ fun:_ZN19PersonalDataManager4InitEP7Profile
+ fun:_ZN11ProfileImpl22GetPersonalDataManagerEv
+ fun:_ZN15AutofillManagerC1EP11TabContents
+ ...
+ fun:_ZN11TabContentsC1EP7ProfileP12SiteInstanceiPKS_P23SessionStorageNamespace
+ fun:_ZN7Browser18TabContentsFactoryEP7ProfileP12SiteInstanceiPK11TabContentsP23SessionStorageNamespace
+ fun:_ZN7browser8NavigateEPNS_14NavigateParamsE
+ fun:_ZN11BrowserInit17LaunchWithProfile17OpenTabsInBrowserEP7BrowserbRKSt6vectorINS0_3TabESaIS4_EE
+ fun:_ZN11BrowserInit17LaunchWithProfile17OpenURLsInBrowserEP7BrowserbRKSt6vectorI4GURLSaIS4_EE
+ fun:_ZN11BrowserInit17LaunchWithProfile17ProcessLaunchURLsEbRKSt6vectorI4GURLSaIS2_EE
+ fun:_ZN11BrowserInit17LaunchWithProfile6LaunchEP7Profile*
+ fun:_ZN11BrowserInit13LaunchBrowserERK11CommandLineP7ProfileRK8FilePathbPi
+ fun:_ZN11BrowserInit18ProcessCmdLineImplERK11CommandLineRK8FilePathbP7ProfilePiPS_
+ fun:_ZN11BrowserInit5StartERK11CommandLineRK8FilePathP7ProfilePi
+}
+{
+ bug_56090c
+ Memcheck:Leak
+ fun:_Znw*
+ fun:_ZN11ProfileImpl20CreateWebDataServiceEv
+ fun:_ZN11ProfileImpl17GetWebDataServiceEN7Profile17ServiceAccessTypeE
+ fun:_ZN26AutocompleteHistoryManagerC1EP11TabContents
+ fun:_ZN18TabContentsWrapperC1EP11TabContents
+ fun:_ZN7Browser18TabContentsFactoryEP7ProfileP12SiteInstanceiPK11TabContentsP23SessionStorageNamespace
+ fun:_ZN7browser8NavigateEPNS_14NavigateParamsE
}
{
bug_56676