summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/notifier/gaia_auth
diff options
context:
space:
mode:
authoridana@chromium.org <idana@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 18:34:07 +0000
committeridana@chromium.org <idana@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 18:34:07 +0000
commit5af80facfb9fa87d213ad45366cba6e83d5a7f97 (patch)
treed9b17db4f8189af5febc9f16d7ff17896f22c321 /chrome/browser/sync/notifier/gaia_auth
parent9ac7fcb5fdf8aa1c31e0c7665e567e59255235e8 (diff)
downloadchromium_src-5af80facfb9fa87d213ad45366cba6e83d5a7f97.zip
chromium_src-5af80facfb9fa87d213ad45366cba6e83d5a7f97.tar.gz
chromium_src-5af80facfb9fa87d213ad45366cba6e83d5a7f97.tar.bz2
Made some style fixes in the remaining code under chrom/browser/sync and under chrome/test/sync.
Review URL: http://codereview.chromium.org/203043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/notifier/gaia_auth')
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc60
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/gaiaauth.h10
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc36
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/gaiahelper.h2
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/inet_aton.h2
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h125
-rw-r--r--chrome/browser/sync/notifier/gaia_auth/win32window.cc2
7 files changed, 116 insertions, 121 deletions
diff --git a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc
index 3bc6550..dfcdf7a 100644
--- a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc
+++ b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.cc
@@ -29,14 +29,13 @@ GaiaServer buzz::g_gaia_server;
// GaiaAuth::WorkerThread
///////////////////////////////////////////////////////////////////////////////
-// GaiaAuth is NOT invoked during SASL authenticatioin, but
-// it is invoked even before XMPP login begins. As a PreXmppAuth
-// object, it is driven by XmppClient before the XMPP socket is
-// opened. The job of GaiaAuth is to goes out using HTTPS
-// POST to grab cookies from GAIA.
-
-// It is used by XmppClient.
-// It grabs a SaslAuthenticator which knows how to play the cookie login.
+// GaiaAuth is NOT invoked during SASL authentication, but it is invoked even
+// before XMPP login begins. As a PreXmppAuth object, it is driven by
+// XmppClient before the XMPP socket is opened. The job of GaiaAuth is to goes
+// out using HTTPS POST to grab cookies from GAIA.
+//
+// It is used by XmppClient. It grabs a SaslAuthenticator which knows how to
+// play the cookie login.
class GaiaAuth::WorkerThread : public talk_base::SignalThread {
public:
@@ -82,7 +81,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
error_ = false;
} else {
talk_base::PhysicalSocketServer physical;
- talk_base::SocketServer * ss = &physical;
+ talk_base::SocketServer* ss = &physical;
if (firewall_) {
ss = new talk_base::FirewallSocketServer(ss, firewall_);
}
@@ -108,7 +107,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
g_gaia_server);
ss->Wait(kGaiaAuthTimeoutMs, true);
- error_code_ = monitor.error(); // save off the error code
+ error_code_ = monitor.error(); // Save off the error code.
if (!monitor.done()) {
LOG(INFO) << "GaiaAuth request timed out";
@@ -136,7 +135,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
captcha_challenge_ = buzz::CaptchaChallenge(captcha_token,
captcha_url);
}
- // We had no "error" - we were just unauthorized
+ // We had no "error" - we were just unauthorized.
error_ = false;
error_code_ = 0;
goto Cleanup;
@@ -159,7 +158,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
GaiaRequestAuthToken(&http, sid_, lsid_, service_, g_gaia_server);
ss->Wait(kGaiaAuthTimeoutMs, true);
- error_code_ = monitor.error(); // save off the error code
+ error_code_ = monitor.error(); // Save off the error code.
if (!monitor.done()) {
LOG(INFO) << "GaiaAuth request timed out";
@@ -182,7 +181,7 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
}
}
- // done authenticating
+ // Done authenticating.
Cleanup:
done_ = true;
@@ -236,8 +235,8 @@ class GaiaAuth::WorkerThread : public talk_base::SignalThread {
///////////////////////////////////////////////////////////////////////////////
GaiaAuth::GaiaAuth(const std::string &user_agent, const std::string &sig)
- : agent_(user_agent), signature_(sig),
- firewall_(0), worker_(NULL), done_(false) {
+ : agent_(user_agent), signature_(sig), firewall_(0), worker_(NULL),
+ done_(false) {
}
GaiaAuth::~GaiaAuth() {
@@ -257,15 +256,15 @@ void GaiaAuth::StartPreXmppAuth(const buzz::Jid& jid,
void GaiaAuth::StartTokenAuth(const buzz::Jid& jid,
const talk_base::CryptString& pass,
const std::string& service) {
- InternalStartGaiaAuth(jid, talk_base::SocketAddress(),
- pass, "", service, false);
+ InternalStartGaiaAuth(jid, talk_base::SocketAddress(), pass, "", service,
+ false);
}
void GaiaAuth::StartAuth(const buzz::Jid& jid,
const talk_base::CryptString& pass,
const std::string & service) {
- InternalStartGaiaAuth(jid, talk_base::SocketAddress(),
- pass, "", service, true);
+ InternalStartGaiaAuth(jid, talk_base::SocketAddress(), pass, "", service,
+ true);
}
void GaiaAuth::StartAuthFromSid(const buzz::Jid& jid,
@@ -281,9 +280,8 @@ void GaiaAuth::InternalStartGaiaAuth(const buzz::Jid& jid,
const std::string& token,
const std::string& service,
bool obtain_auth) {
- worker_ = new WorkerThread(jid.Str(), pass, token,
- service, agent_, signature_,
- obtain_auth, token_service_);
+ worker_ = new WorkerThread(jid.Str(), pass, token, service, agent_,
+ signature_, obtain_auth, token_service_);
worker_->set_proxy(proxy_);
worker_->set_firewall(firewall_);
worker_->set_captcha_answer(captcha_answer_);
@@ -315,36 +313,35 @@ std::string GaiaAuth::ChooseBestSaslMechanism(
std::vector<std::string>::const_iterator it;
- // a token is the weakest auth - 15s, service-limited, so prefer it.
+ // A token is the weakest auth - 15s, service-limited, so prefer it.
it = std::find(mechanisms.begin(), mechanisms.end(), "X-GOOGLE-TOKEN");
if (it != mechanisms.end())
return "X-GOOGLE-TOKEN";
- // a cookie is the next weakest - 14 days
+ // A cookie is the next weakest - 14 days.
it = std::find(mechanisms.begin(), mechanisms.end(), "X-GOOGLE-COOKIE");
if (it != mechanisms.end())
return "X-GOOGLE-COOKIE";
- // never pass @google.com passwords without encryption!!
+ // Never pass @google.com passwords without encryption!!
if (!encrypted &&
buzz::Jid(worker_->GetUsername()).domain() == "google.com") {
return "";
}
- // as a last resort, use plain authentication
+ // As a last resort, use plain authentication.
if (buzz::Jid(worker_->GetUsername()).domain() != "google.com") {
it = std::find(mechanisms.begin(), mechanisms.end(), "PLAIN");
if (it != mechanisms.end())
return "PLAIN";
}
- // No good mechanism found
+ // No good mechanism found.
return "";
}
buzz::SaslMechanism* GaiaAuth::CreateSaslMechanism(
const std::string& mechanism) {
-
if (!done_) {
return NULL;
}
@@ -370,7 +367,7 @@ buzz::SaslMechanism* GaiaAuth::CreateSaslMechanism(
worker_->GetPassword());
}
- // oh well - none of the above
+ // Oh well - none of the above.
return NULL;
}
@@ -380,10 +377,10 @@ std::string GaiaAuth::CreateAuthenticatedUrl(
return "";
std::string url;
- // Note that http_prefix always ends with a "/"
+ // Note that http_prefix always ends with a "/".
url += g_gaia_server.http_prefix()
+ "accounts/TokenAuth?auth="
- + worker_->GetToken(); // Do not URL encode - GAIA doesn't like that
+ + worker_->GetToken(); // Do not URL encode - GAIA doesn't like that.
url += "&service=" + service;
url += "&continue=" + UrlEncodeString(continue_url);
url += "&source=" + signature_;
@@ -439,4 +436,5 @@ buzz::CaptchaChallenge GaiaAuth::GetCaptchaChallenge() {
}
return worker_->GetCaptchaChallenge();
}
+
} // namespace buzz
diff --git a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.h b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.h
index 8919bbc..e2f3a6e 100644
--- a/chrome/browser/sync/notifier/gaia_auth/gaiaauth.h
+++ b/chrome/browser/sync/notifier/gaia_auth/gaiaauth.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Gaia auth code for XMPP notifier support. This should be merged with
-// the other gaia auth file when we have time.
+// Gaia auth code for XMPP notifier support. This should be merged with the
+// other gaia auth file when we have time.
#ifndef CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_GAIAAUTH_H_
#define CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_GAIAAUTH_H_
@@ -43,7 +43,7 @@ class GaiaAuth : public PreXmppAuth, public sigslot::has_slots<> {
captcha_answer_ = captcha_answer;
}
- // From inside XMPP login, this is called
+ // From inside XMPP login, this is called.
virtual void StartPreXmppAuth(const buzz::Jid& jid,
const talk_base::SocketAddress& server,
const talk_base::CryptString& pass,
@@ -53,12 +53,12 @@ class GaiaAuth : public PreXmppAuth, public sigslot::has_slots<> {
const talk_base::CryptString& pass,
const std::string& service);
- // This is used when calling GetAuth()
+ // This is used when calling GetAuth().
void StartAuth(const buzz::Jid& jid,
const talk_base::CryptString& pass,
const std::string& service);
- // This is used when bootstrapping from a download page
+ // This is used when bootstrapping from a download page.
void StartAuthFromSid(const buzz::Jid& jid,
const std::string& sid,
const std::string& service);
diff --git a/chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc b/chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc
index 3e0683c..95ca023 100644
--- a/chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc
+++ b/chrome/browser/sync/notifier/gaia_auth/gaiahelper.cc
@@ -16,10 +16,10 @@
namespace {
-std::string GetValueForKey(const std::string & key, const std::string & nvp) {
+std::string GetValueForKey(const std::string& key, const std::string& nvp) {
size_t start_of_line = 0;
size_t end_of_line = 0;
- for (;;) { // for each line
+ for (;;) { // For each line.
start_of_line = nvp.find_first_not_of("\r\n", end_of_line);
if (start_of_line == std::string::npos)
break;
@@ -41,7 +41,7 @@ std::string GetValueForKey(const std::string & key, const std::string & nvp) {
return "";
}
-} // anonymous namespace
+} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -58,14 +58,14 @@ bool GaiaServer::SetServer(const char* url) {
hostname_ = parsed.server();
port_ = parsed.port();
use_ssl_ = parsed.secure();
- return true; // parsed.valid();
+ return true;
}
bool GaiaServer::SetDebugServer(const char* server) {
const char* colon = strchr(server, ':');
if (colon) {
hostname_ = std::string(server, colon - server);
- port_ = atoi(colon+1);
+ port_ = atoi(colon + 1);
use_ssl_ = false;
return true;
}
@@ -90,10 +90,10 @@ bool GaiaRequestSid(talk_base::HttpClient* client,
buzz::Jid jid(username);
std::string usable_name = username;
if (jid.domain() == buzz::STR_DEFAULT_DOMAIN) {
- // The default domain (default.talk.google.com) is not usable
- // for Gaia auth. But both gmail.com and googlemain.com will
- // work, because the gaia server doesn't check to make sure the
- // appropriate one is being used. So we just slam on gmail.com
+ // The default domain (default.talk.google.com) is not usable for Gaia
+ // auth. But both gmail.com and googlemain.com will work, because the gaia
+ // server doesn't check to make sure the appropriate one is being used. So
+ // we just slam on gmail.com
usable_name = jid.node() + "@" + buzz::STR_GMAIL_COM;
}
@@ -138,8 +138,8 @@ GaiaResponse GaiaParseSidResponse(const talk_base::HttpClient& client,
std::string* auth) {
uint32 status_code = client.response().scode;
const talk_base::MemoryStream* stream =
- static_cast<const talk_base::MemoryStream*>(
- client.response().document.get());
+ static_cast<const talk_base::MemoryStream*>(
+ client.response().document.get());
size_t length;
stream->GetPosition(&length);
std::string response;
@@ -156,8 +156,8 @@ GaiaResponse GaiaParseSidResponse(const talk_base::HttpClient& client,
std::string image_url = GetValueForKey("CaptchaUrl", response);
if (!image_url.empty()) {
// We should activate this "full url code" once we have a better ways
- // to crack the URL for later download. Right now we are too
- // dependent on what Gaia returns.
+ // to crack the URL for later download. Right now we are too dependent
+ // on what Gaia returns.
#if 0
if (image_url.find("http://") != 0 &&
image_url.find("https://") != 0) {
@@ -202,15 +202,15 @@ bool GaiaRequestAuthToken(talk_base::HttpClient* client,
post_data += "SID=" + UrlEncodeString(sid);
post_data += "&LSID=" + UrlEncodeString(lsid);
post_data += "&service=" + service;
- post_data += "&Session=true"; // creates two week cookie
+ post_data += "&Session=true"; // Creates two week cookie.
client->reset();
client->set_server(talk_base::SocketAddress(gaia_server.hostname(),
- gaia_server.port(), false));
+ gaia_server.port(), false));
client->request().verb = talk_base::HV_POST;
client->request().path = "/accounts/IssueAuthToken";
client->request().setContent("application/x-www-form-urlencoded",
- new talk_base::MemoryStream(post_data.data(), post_data.size()));
+ new talk_base::MemoryStream(post_data.data(), post_data.size()));
client->response().document.reset(new talk_base::MemoryStream);
client->start();
return true;
@@ -223,8 +223,8 @@ GaiaResponse GaiaParseAuthTokenResponse(const talk_base::HttpClient& client,
}
const talk_base::MemoryStream* stream =
- static_cast<const talk_base::MemoryStream*>(
- client.response().document.get());
+ static_cast<const talk_base::MemoryStream*>(
+ client.response().document.get());
size_t length;
stream->GetPosition(&length);
while ((length > 0) && isspace(stream->GetBuffer()[length-1]))
diff --git a/chrome/browser/sync/notifier/gaia_auth/gaiahelper.h b/chrome/browser/sync/notifier/gaia_auth/gaiahelper.h
index e0303d0..933bc97 100644
--- a/chrome/browser/sync/notifier/gaia_auth/gaiahelper.h
+++ b/chrome/browser/sync/notifier/gaia_auth/gaiahelper.h
@@ -34,7 +34,7 @@ class GaiaServer {
public:
GaiaServer();
- bool SetServer(const char* url); // protocol://server:port
+ bool SetServer(const char* url); // protocol://server:port
bool SetDebugServer(const char* server); // server:port
const std::string& hostname() const { return hostname_; }
diff --git a/chrome/browser/sync/notifier/gaia_auth/inet_aton.h b/chrome/browser/sync/notifier/gaia_auth/inet_aton.h
index a10d6cf..6a5aee5 100644
--- a/chrome/browser/sync/notifier/gaia_auth/inet_aton.h
+++ b/chrome/browser/sync/notifier/gaia_auth/inet_aton.h
@@ -8,7 +8,7 @@
#define CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_INET_ATON_H_
#ifdef WIN32
-int inet_aton(const char * cp, struct in_addr* inp);
+int inet_aton(const char* cp, struct in_addr* inp);
#endif
#endif // CHROME_BROWSER_SYNC_NOTIFIER_GAIA_AUTH_INET_ATON_H_
diff --git a/chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h b/chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h
index 3e223b9..3c0941e 100644
--- a/chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h
+++ b/chrome/browser/sync/notifier/gaia_auth/sigslotrepeater.h
@@ -16,70 +16,67 @@
namespace sigslot {
- template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
- class repeater0 : public signal0<mt_policy>,
- public has_slots<mt_policy> {
- public:
- typedef signal0<mt_policy> base_type;
- typedef repeater0<mt_policy> this_type;
-
- repeater0() { }
- explicit repeater0(const this_type& s) : base_type(s) { }
-
- void reemit() { signal0<mt_policy>::emit(); }
- void repeat(base_type &s) { s.connect(this, &this_type::reemit); }
- };
-
- template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
- class repeater1 : public signal1<arg1_type, mt_policy>,
- public has_slots<mt_policy>
- {
- public:
- typedef signal1<arg1_type, mt_policy> base_type;
- typedef repeater1<arg1_type, mt_policy> this_type;
-
- repeater1() { }
- repeater1(const this_type& s) : base_type(s) { }
-
- void reemit(arg1_type a1) { signal1<arg1_type, mt_policy>::emit(a1); }
- void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
- };
-
- template<class arg1_type, class arg2_type,
- class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
- class repeater2 : public signal2<arg1_type, arg2_type, mt_policy>,
- public has_slots<mt_policy>
- {
- public:
- typedef signal2<arg1_type, arg2_type, mt_policy> base_type;
- typedef repeater2<arg1_type, arg2_type, mt_policy> this_type;
-
- repeater2() { }
- repeater2(const this_type& s) : base_type(s) { }
-
- void reemit(arg1_type a1, arg2_type a2) {
- signal2<arg1_type, arg2_type, mt_policy>::emit(a1, a2);
- }
- void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
- };
-
- template<class arg1_type, class arg2_type, class arg3_type,
- class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
- class repeater3 : public signal3<arg1_type, arg2_type, arg3_type, mt_policy>,
- public has_slots<mt_policy>
- {
- public:
- typedef signal3<arg1_type, arg2_type, arg3_type, mt_policy> base_type;
- typedef repeater3<arg1_type, arg2_type, arg3_type, mt_policy> this_type;
-
- repeater3() { }
- repeater3(const this_type& s) : base_type(s) { }
-
- void reemit(arg1_type a1, arg2_type a2, arg3_type a3) {
- signal3<arg1_type, arg2_type, arg3_type, mt_policy>::emit(a1, a2, a3);
- }
- void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
- };
+template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
+class repeater0 : public signal0<mt_policy>,
+ public has_slots<mt_policy> {
+ public:
+ typedef signal0<mt_policy> base_type;
+ typedef repeater0<mt_policy> this_type;
+
+ repeater0() { }
+ explicit repeater0(const this_type& s) : base_type(s) { }
+
+ void reemit() { signal0<mt_policy>::emit(); }
+ void repeat(base_type &s) { s.connect(this, &this_type::reemit); }
+};
+
+template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
+class repeater1 : public signal1<arg1_type, mt_policy>,
+ public has_slots<mt_policy> {
+ public:
+ typedef signal1<arg1_type, mt_policy> base_type;
+ typedef repeater1<arg1_type, mt_policy> this_type;
+
+ repeater1() { }
+ repeater1(const this_type& s) : base_type(s) { }
+
+ void reemit(arg1_type a1) { signal1<arg1_type, mt_policy>::emit(a1); }
+ void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
+};
+
+template<class arg1_type, class arg2_type,
+ class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
+class repeater2 : public signal2<arg1_type, arg2_type, mt_policy>,
+ public has_slots<mt_policy> {
+ public:
+ typedef signal2<arg1_type, arg2_type, mt_policy> base_type;
+ typedef repeater2<arg1_type, arg2_type, mt_policy> this_type;
+
+ repeater2() { }
+ repeater2(const this_type& s) : base_type(s) { }
+
+ void reemit(arg1_type a1, arg2_type a2) {
+ signal2<arg1_type, arg2_type, mt_policy>::emit(a1, a2);
+ }
+ void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
+};
+
+template<class arg1_type, class arg2_type, class arg3_type,
+ class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
+class repeater3 : public signal3<arg1_type, arg2_type, arg3_type, mt_policy>,
+ public has_slots<mt_policy> {
+ public:
+ typedef signal3<arg1_type, arg2_type, arg3_type, mt_policy> base_type;
+ typedef repeater3<arg1_type, arg2_type, arg3_type, mt_policy> this_type;
+
+ repeater3() { }
+ repeater3(const this_type& s) : base_type(s) { }
+
+ void reemit(arg1_type a1, arg2_type a2, arg3_type a3) {
+ signal3<arg1_type, arg2_type, arg3_type, mt_policy>::emit(a1, a2, a3);
+ }
+ void repeat(base_type& s) { s.connect(this, &this_type::reemit); }
+};
} // namespace sigslot
diff --git a/chrome/browser/sync/notifier/gaia_auth/win32window.cc b/chrome/browser/sync/notifier/gaia_auth/win32window.cc
index f1eb8bf..25ea0a3 100644
--- a/chrome/browser/sync/notifier/gaia_auth/win32window.cc
+++ b/chrome/browser/sync/notifier/gaia_auth/win32window.cc
@@ -1,7 +1,7 @@
// Copyright (c) 2009 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.
-
+//
// Originally from libjingle. Minor alterations to compile it in Chrome.
#include "talk/base/common.h"