summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r--chrome/browser/sync/engine/auth_watcher_unittest.cc2
-rw-r--r--chrome/browser/sync/engine/syncapi.cc7
-rw-r--r--chrome/browser/sync/engine/syncapi.h5
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.cc3
-rw-r--r--chrome/browser/sync/glue/sync_backend_host.h7
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator_impl.cc12
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator_impl.h5
-rw-r--r--chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service.cc7
9 files changed, 40 insertions, 10 deletions
diff --git a/chrome/browser/sync/engine/auth_watcher_unittest.cc b/chrome/browser/sync/engine/auth_watcher_unittest.cc
index f2adaa5..9d9f319 100644
--- a/chrome/browser/sync/engine/auth_watcher_unittest.cc
+++ b/chrome/browser/sync/engine/auth_watcher_unittest.cc
@@ -99,7 +99,7 @@ class AuthWatcherTest : public testing::Test {
user_settings_->Init(user_settings_path);
gaia_auth_ = new GaiaAuthMockForAuthWatcher();
talk_mediator_.reset(new TalkMediatorImpl(
- browser_sync::kDefaultNotificationMethod));
+ browser_sync::kDefaultNotificationMethod, false));
auth_watcher_ = new AuthWatcher(metadb_.manager(), connection_.get(),
allstatus_.get(), kTestUserAgent, kTestServiceId, kTestGaiaURL,
user_settings_.get(), gaia_auth_, talk_mediator_.get());
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index a7718d8..23243d5 100644
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -966,6 +966,7 @@ class SyncManager::SyncInternal {
ModelSafeWorkerRegistrar* model_safe_worker_registrar,
bool attempt_last_user_authentication,
bool invalidate_last_user_auth_token,
+ bool invalidate_xmpp_auth_token,
const char* user_agent,
const std::string& lsid,
browser_sync::NotificationMethod notification_method);
@@ -1218,6 +1219,7 @@ bool SyncManager::Init(const FilePath& database_location,
ModelSafeWorkerRegistrar* registrar,
bool attempt_last_user_authentication,
bool invalidate_last_user_auth_token,
+ bool invalidate_xmpp_auth_token,
const char* user_agent,
const char* lsid,
browser_sync::NotificationMethod notification_method) {
@@ -1235,6 +1237,7 @@ bool SyncManager::Init(const FilePath& database_location,
registrar,
attempt_last_user_authentication,
invalidate_last_user_auth_token,
+ invalidate_xmpp_auth_token,
user_agent,
lsid,
notification_method);
@@ -1262,6 +1265,7 @@ bool SyncManager::SyncInternal::Init(
ModelSafeWorkerRegistrar* model_safe_worker_registrar,
bool attempt_last_user_authentication,
bool invalidate_last_user_auth_token,
+ bool invalidate_xmpp_auth_token,
const char* user_agent,
const std::string& lsid,
browser_sync::NotificationMethod notification_method) {
@@ -1316,7 +1320,8 @@ bool SyncManager::SyncInternal::Init(
const char* service_id = gaia_service_id ?
gaia_service_id : SYNC_SERVICE_NAME;
- talk_mediator_.reset(new TalkMediatorImpl(notification_method));
+ talk_mediator_.reset(new TalkMediatorImpl(notification_method,
+ invalidate_xmpp_auth_token));
allstatus()->WatchTalkMediator(talk_mediator());
BridgedGaiaAuthenticator* gaia_auth = new BridgedGaiaAuthenticator(
diff --git a/chrome/browser/sync/engine/syncapi.h b/chrome/browser/sync/engine/syncapi.h
index 9fa0765..0b0572f 100644
--- a/chrome/browser/sync/engine/syncapi.h
+++ b/chrome/browser/sync/engine/syncapi.h
@@ -609,6 +609,10 @@ class SyncManager {
// |invalidate_last_user_auth_token| makes it so that any auth token
// read from user settings is invalidated. This is used for testing
// code paths related to authentication failures.
+ //
+ // |invalidate_xmpp_auth_token| makes it so that any auth token
+ // used to log into XMPP is invalidated. This is used for testing
+ // code paths related to authentication failures for XMPP only.
bool Init(const FilePath& database_location,
const char* sync_server_and_path,
int sync_server_port,
@@ -620,6 +624,7 @@ class SyncManager {
browser_sync::ModelSafeWorkerRegistrar* registrar,
bool attempt_last_user_authentication,
bool invalidate_last_user_auth_token,
+ bool invalidate_xmpp_auth_token,
const char* user_agent,
const char* lsid,
browser_sync::NotificationMethod notification_method);
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index e158cf53..1a16776 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -50,6 +50,7 @@ void SyncBackendHost::Initialize(
const std::string& lsid,
bool delete_sync_data_folder,
bool invalidate_sync_login,
+ bool invalidate_sync_xmpp_login,
NotificationMethod notification_method) {
if (!core_thread_.Start())
return;
@@ -82,6 +83,7 @@ void SyncBackendHost::Initialize(
lsid,
delete_sync_data_folder,
invalidate_sync_login,
+ invalidate_sync_xmpp_login,
notification_method)));
}
@@ -279,6 +281,7 @@ void SyncBackendHost::Core::DoInitialize(const DoInitializeOptions& options) {
host_, // ModelSafeWorkerRegistrar.
options.attempt_last_user_authentication,
options.invalidate_sync_login,
+ options.invalidate_sync_xmpp_login,
MakeUserAgentForSyncapi().c_str(),
options.lsid.c_str(),
options.notification_method);
diff --git a/chrome/browser/sync/glue/sync_backend_host.h b/chrome/browser/sync/glue/sync_backend_host.h
index 92baeca..fe425dc 100644
--- a/chrome/browser/sync/glue/sync_backend_host.h
+++ b/chrome/browser/sync/glue/sync_backend_host.h
@@ -87,6 +87,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
const std::string& lsid,
bool delete_sync_data_folder,
bool invalidate_sync_login,
+ bool invalidate_sync_xmpp_login,
NotificationMethod notification_method);
// Called on |frontend_loop_| to kick off asynchronous authentication.
@@ -186,6 +187,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
const std::string& lsid,
bool delete_sync_data_folder,
bool invalidate_sync_login,
+ bool invalidate_sync_xmpp_login,
NotificationMethod notification_method)
: service_url(service_url),
attempt_last_user_authentication(attempt_last_user_authentication),
@@ -194,6 +196,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
lsid(lsid),
delete_sync_data_folder(delete_sync_data_folder),
invalidate_sync_login(invalidate_sync_login),
+ invalidate_sync_xmpp_login(invalidate_sync_xmpp_login),
notification_method(notification_method) {}
GURL service_url;
@@ -203,6 +206,7 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
std::string lsid;
bool delete_sync_data_folder;
bool invalidate_sync_login;
+ bool invalidate_sync_xmpp_login;
NotificationMethod notification_method;
};
@@ -255,7 +259,8 @@ class SyncBackendHost : public browser_sync::ModelSafeWorkerRegistrar {
NotificationMethod notification_method) {
DoInitialize(
DoInitializeOptions(GURL(), false, factory, auth_factory,
- std::string(), delete_sync_data_folder, false,
+ std::string(), delete_sync_data_folder,
+ false, false,
notification_method));
syncapi_->SetupForTestMode(test_user);
}
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc b/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc
index f8506fe..c2aff57 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc
+++ b/chrome/browser/sync/notifier/listener/talk_mediator_impl.cc
@@ -41,8 +41,10 @@ class SslInitializationSingleton {
DISALLOW_COPY_AND_ASSIGN(SslInitializationSingleton);
};
-TalkMediatorImpl::TalkMediatorImpl(NotificationMethod notification_method)
- : mediator_thread_(new MediatorThreadImpl(notification_method)) {
+TalkMediatorImpl::TalkMediatorImpl(NotificationMethod notification_method,
+ bool invalidate_xmpp_auth_token)
+ : mediator_thread_(new MediatorThreadImpl(notification_method)),
+ invalidate_xmpp_auth_token_(invalidate_xmpp_auth_token) {
// Ensure the SSL library is initialized.
SslInitializationSingleton::GetInstance()->RegisterClient();
@@ -51,7 +53,8 @@ TalkMediatorImpl::TalkMediatorImpl(NotificationMethod notification_method)
}
TalkMediatorImpl::TalkMediatorImpl(MediatorThread *thread)
- : mediator_thread_(thread) {
+ : mediator_thread_(thread),
+ invalidate_xmpp_auth_token_(false) {
// When testing we do not initialize the SSL library.
TalkMediatorInitialization(true);
}
@@ -176,7 +179,8 @@ bool TalkMediatorImpl::SetAuthToken(const std::string& email,
xmpp_settings_.set_resource("chrome-sync");
xmpp_settings_.set_host(jid.domain());
xmpp_settings_.set_use_tls(true);
- xmpp_settings_.set_auth_cookie(token);
+ xmpp_settings_.set_auth_cookie(invalidate_xmpp_auth_token_ ?
+ token + "bogus" : token);
state_.initialized = 1;
return true;
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator_impl.h b/chrome/browser/sync/notifier/listener/talk_mediator_impl.h
index 98cc642..7de0885 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator_impl.h
+++ b/chrome/browser/sync/notifier/listener/talk_mediator_impl.h
@@ -33,7 +33,8 @@ class TalkMediatorImpl
: public TalkMediator,
public sigslot::has_slots<> {
public:
- explicit TalkMediatorImpl(NotificationMethod notification_method);
+ TalkMediatorImpl(NotificationMethod notification_method,
+ bool invalidate_xmpp_auth_token);
explicit TalkMediatorImpl(MediatorThread* thread);
virtual ~TalkMediatorImpl();
@@ -109,6 +110,8 @@ class TalkMediatorImpl
// Channel through which to broadcast events.
scoped_ptr<TalkMediatorChannel> channel_;
+ bool invalidate_xmpp_auth_token_;
+
FRIEND_TEST(TalkMediatorImplTest, SetAuthTokenWithBadInput);
FRIEND_TEST(TalkMediatorImplTest, SetAuthTokenWithGoodInput);
FRIEND_TEST(TalkMediatorImplTest, SendNotification);
diff --git a/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc b/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc
index 4c37eba..0a3b057 100644
--- a/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc
+++ b/chrome/browser/sync/notifier/listener/talk_mediator_unittest.cc
@@ -37,7 +37,7 @@ class TalkMediatorImplTest : public testing::Test {
TEST_F(TalkMediatorImplTest, ConstructionOfTheClass) {
// Constructing a single talk mediator enables SSL through the singleton.
scoped_ptr<TalkMediatorImpl> talk1(new TalkMediatorImpl(
- browser_sync::kDefaultNotificationMethod));
+ browser_sync::kDefaultNotificationMethod, false));
talk1.reset(NULL);
}
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 60da90d..fd22c67 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -161,13 +161,18 @@ std::string ProfileSyncService::GetLsidForAuthBootstraping() {
void ProfileSyncService::InitializeBackend(bool delete_sync_data_folder) {
bool invalidate_sync_login = false;
+ bool invalidate_sync_xmpp_login = false;
#if !defined(NDEBUG)
invalidate_sync_login = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kInvalidateSyncLogin);
+ invalidate_sync_xmpp_login = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kInvalidateSyncXmppLogin);
#endif
backend_->Initialize(sync_service_url_, profile_->GetRequestContext(),
GetLsidForAuthBootstraping(), delete_sync_data_folder,
- invalidate_sync_login, notification_method_);
+ invalidate_sync_login,
+ invalidate_sync_xmpp_login,
+ notification_method_);
}
void ProfileSyncService::StartUp() {