summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/profile_sync_service.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/sync/profile_sync_service.cc')
-rw-r--r--chrome/browser/sync/profile_sync_service.cc59
1 files changed, 53 insertions, 6 deletions
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index cc0508b..7b210d0 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -8,12 +8,14 @@
#include <set>
#include "app/l10n_util.h"
+#include "base/basictypes.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/stl_util-inl.h"
#include "base/string16.h"
+#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/task.h"
#include "base/utf_string_conversions.h"
@@ -205,10 +207,10 @@ void ProfileSyncService::RegisterAuthNotifications() {
Source<TokenService>(profile_->GetTokenService()));
registrar_.Add(this,
NotificationType::GOOGLE_SIGNIN_SUCCESSFUL,
- Source<SigninManager>(&signin_));
+ Source<Profile>(profile_));
registrar_.Add(this,
NotificationType::GOOGLE_SIGNIN_FAILED,
- Source<SigninManager>(&signin_));
+ Source<Profile>(profile_));
}
void ProfileSyncService::RegisterDataTypeController(
@@ -248,6 +250,32 @@ void ProfileSyncService::GetDataTypeControllerStates(
(*state_map)[iter->first] = iter->second.get()->state();
}
+namespace {
+
+// TODO(akalin): Figure out whether this should be a method of
+// HostPortPair.
+net::HostPortPair StringToHostPortPair(const std::string& host_port_str,
+ uint16 default_port) {
+ std::string::size_type colon_index = host_port_str.find(':');
+ if (colon_index == std::string::npos) {
+ return net::HostPortPair(host_port_str, default_port);
+ }
+
+ std::string host = host_port_str.substr(0, colon_index);
+ std::string port_str = host_port_str.substr(colon_index + 1);
+ int port = default_port;
+ if (!base::StringToInt(port_str, &port) ||
+ (port <= 0) || (port > kuint16max)) {
+ LOG(WARNING) << "Could not parse valid port from " << port_str
+ << "; using port " << default_port;
+ return net::HostPortPair(host, default_port);
+ }
+
+ return net::HostPortPair(host, port);
+}
+
+} // namespace
+
void ProfileSyncService::InitSettings() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
@@ -272,18 +300,30 @@ void ProfileSyncService::InitSettings() {
std::string value(command_line.GetSwitchValueASCII(
switches::kSyncNotificationHost));
if (!value.empty()) {
- notifier_options_.xmpp_host_port.set_host(value);
- notifier_options_.xmpp_host_port.set_port(notifier::kDefaultXmppPort);
+ notifier_options_.xmpp_host_port =
+ StringToHostPortPair(value, notifier::kDefaultXmppPort);
}
VLOG(1) << "Using " << notifier_options_.xmpp_host_port.ToString()
<< " for test sync notification server.";
}
notifier_options_.try_ssltcp_first =
- command_line.HasSwitch(switches::kSyncUseSslTcp);
+ command_line.HasSwitch(switches::kSyncTrySsltcpFirstForXmpp);
if (notifier_options_.try_ssltcp_first)
VLOG(1) << "Trying SSL/TCP port before XMPP port for notifications.";
+ notifier_options_.invalidate_xmpp_login =
+ command_line.HasSwitch(switches::kSyncInvalidateXmppLogin);
+ if (notifier_options_.invalidate_xmpp_login) {
+ VLOG(1) << "Invalidating sync XMPP login.";
+ }
+
+ notifier_options_.allow_insecure_connection =
+ command_line.HasSwitch(switches::kSyncAllowInsecureXmppConnection);
+ if (notifier_options_.allow_insecure_connection) {
+ VLOG(1) << "Allowing insecure XMPP connections.";
+ }
+
if (command_line.HasSwitch(switches::kSyncNotificationMethod)) {
const std::string notification_method_str(
command_line.GetSwitchValueASCII(switches::kSyncNotificationMethod));
@@ -390,7 +430,7 @@ void ProfileSyncService::CreateBackend() {
void ProfileSyncService::StartUp() {
// Don't start up multiple times.
if (backend_.get()) {
- LOG(INFO) << "Skipping bringing up backend host.";
+ VLOG(1) << "Skipping bringing up backend host.";
return;
}
@@ -451,6 +491,7 @@ void ProfileSyncService::Shutdown(bool sync_disabled) {
backend_initialized_ = false;
observed_passphrase_required_ = false;
last_attempted_user_email_.clear();
+ last_auth_error_ = GoogleServiceAuthError::None();
}
void ProfileSyncService::ClearServerData() {
@@ -774,6 +815,12 @@ void ProfileSyncService::OnUserSubmittedAuth(
signin_.SignOut();
}
+ // The user has submitted credentials, which indicates they don't
+ // want to suppress start up anymore.
+ PrefService* prefs = profile_->GetPrefs();
+ prefs->SetBoolean(prefs::kSyncSuppressStart, false);
+ prefs->ScheduleSavePersistentPrefs();
+
signin_.StartSignIn(username,
password,
last_auth_error_.captcha().token,