summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 02:45:20 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-06 02:45:20 +0000
commit622b74522b0ee8aa0343dd48fbbd0230e9806d5e (patch)
tree3b75d81e9ea9e17277b8485f0694ea557d7b9a35 /chrome
parent713b3cc40bc2bb48ff756f9adebe4b06561f8e88 (diff)
downloadchromium_src-622b74522b0ee8aa0343dd48fbbd0230e9806d5e.zip
chromium_src-622b74522b0ee8aa0343dd48fbbd0230e9806d5e.tar.gz
chromium_src-622b74522b0ee8aa0343dd48fbbd0230e9806d5e.tar.bz2
Removed some dependencies on sync from GaiaAuthenticator so that it can be moved to common.
BUG=None TEST=Test Bookmarks Sync Review URL: http://codereview.chromium.org/1964005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46543 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/sync/engine/auth_watcher_unittest.cc5
-rw-r--r--chrome/browser/sync/engine/net/gaia_authenticator.cc19
-rw-r--r--chrome/browser/sync/engine/net/gaia_authenticator.h11
-rw-r--r--chrome/browser/sync/engine/net/gaia_authenticator_unittest.cc7
4 files changed, 30 insertions, 12 deletions
diff --git a/chrome/browser/sync/engine/auth_watcher_unittest.cc b/chrome/browser/sync/engine/auth_watcher_unittest.cc
index 436ab80..601d65f 100644
--- a/chrome/browser/sync/engine/auth_watcher_unittest.cc
+++ b/chrome/browser/sync/engine/auth_watcher_unittest.cc
@@ -41,6 +41,11 @@ class GaiaAuthMockForAuthWatcher : public browser_sync::GaiaAuthenticator {
use_bad_auth_token_(false) {}
virtual ~GaiaAuthMockForAuthWatcher() {}
+ virtual int GetBackoffDelaySeconds(
+ int current_backoff_delay) {
+ return AllStatus::GetRecommendedDelaySeconds(current_backoff_delay);
+ }
+
void SendBadAuthTokenForNextRequest() { use_bad_auth_token_ = true; }
std::string renewed_token() {
diff --git a/chrome/browser/sync/engine/net/gaia_authenticator.cc b/chrome/browser/sync/engine/net/gaia_authenticator.cc
index 661bf6d..2be47f8 100644
--- a/chrome/browser/sync/engine/net/gaia_authenticator.cc
+++ b/chrome/browser/sync/engine/net/gaia_authenticator.cc
@@ -11,11 +11,10 @@
#include "base/basictypes.h"
#include "base/port.h"
#include "base/string_split.h"
-#include "chrome/browser/sync/engine/all_status.h"
#include "chrome/browser/sync/engine/net/http_return.h"
-#include "chrome/browser/sync/engine/net/url_translator.h"
#include "chrome/common/deprecated/event_sys-inl.h"
#include "googleurl/src/gurl.h"
+#include "net/base/escape.h"
using std::pair;
using std::string;
@@ -146,7 +145,7 @@ bool GaiaAuthenticator::AuthenticateImpl(const AuthParams& params,
++early_auth_attempt_count_;
// Allow 3 attempts, but then limit.
if (early_auth_attempt_count_ > 3) {
- delay_ = AllStatus::GetRecommendedDelaySeconds(delay_);
+ delay_ = GetBackoffDelaySeconds(delay_);
next_allowed_auth_attempt_time_ = now + delay_;
return false;
}
@@ -161,13 +160,13 @@ bool GaiaAuthenticator::PerformGaiaRequest(const AuthParams& params,
GURL gaia_auth_url(gaia_url_);
string post_body;
- post_body += "Email=" + CgiEscapeString(params.email);
- post_body += "&Passwd=" + CgiEscapeString(params.password);
- post_body += "&source=" + CgiEscapeString(user_agent_);
+ post_body += "Email=" + EscapeUrlEncodedData(params.email);
+ post_body += "&Passwd=" + EscapeUrlEncodedData(params.password);
+ post_body += "&source=" + EscapeUrlEncodedData(user_agent_);
post_body += "&service=" + service_id_;
if (!params.captcha_token.empty() && !params.captcha_value.empty()) {
- post_body += "&logintoken=" + CgiEscapeString(params.captcha_token);
- post_body += "&logincaptcha=" + CgiEscapeString(params.captcha_value);
+ post_body += "&logintoken=" + EscapeUrlEncodedData(params.captcha_token);
+ post_body += "&logincaptcha=" + EscapeUrlEncodedData(params.captcha_value);
}
post_body += "&PersistentCookie=true";
// We set it to GOOGLE (and not HOSTED or HOSTED_OR_GOOGLE) because we only
@@ -215,7 +214,7 @@ bool GaiaAuthenticator::LookupEmail(AuthResults* results) {
string post_body;
post_body += "LSID=";
- post_body += CgiEscapeString(results->lsid);
+ post_body += EscapeUrlEncodedData(results->lsid);
unsigned long server_response_code;
string message_text;
@@ -262,7 +261,7 @@ bool GaiaAuthenticator::IssueAuthToken(AuthResults* results,
string post_body;
post_body += "LSID=";
- post_body += CgiEscapeString(results->lsid);
+ post_body += EscapeUrlEncodedData(results->lsid);
post_body += "&service=" + service_id;
if (long_lived) {
post_body += "&Session=true";
diff --git a/chrome/browser/sync/engine/net/gaia_authenticator.h b/chrome/browser/sync/engine/net/gaia_authenticator.h
index 949f9f8..a489cca 100644
--- a/chrome/browser/sync/engine/net/gaia_authenticator.h
+++ b/chrome/browser/sync/engine/net/gaia_authenticator.h
@@ -26,7 +26,6 @@
#include "base/basictypes.h"
#include "base/message_loop.h"
-#include "chrome/browser/sync/engine/net/http_return.h"
#include "chrome/browser/sync/util/signin.h"
#include "chrome/common/deprecated/event_sys.h"
#include "googleurl/src/gurl.h"
@@ -207,6 +206,16 @@ class GaiaAuthenticator {
// results->primary_email.
virtual bool LookupEmail(AuthResults* results);
+ // Subclasses must override to provide a backoff delay. It is virtual instead
+ // of pure virtual for testing purposes.
+ // TODO(sanjeevr): This should be made pure virtual. But this class is
+ // currently directly being used in sync/engine/authenticator.cc, which is
+ // wrong.
+ virtual int GetBackoffDelaySeconds(int current_backoff_delay) {
+ NOTREACHED();
+ return current_backoff_delay;
+ }
+
public:
// Retrieve email.
inline std::string email() const {
diff --git a/chrome/browser/sync/engine/net/gaia_authenticator_unittest.cc b/chrome/browser/sync/engine/net/gaia_authenticator_unittest.cc
index e4ef2df..6955a0a 100644
--- a/chrome/browser/sync/engine/net/gaia_authenticator_unittest.cc
+++ b/chrome/browser/sync/engine/net/gaia_authenticator_unittest.cc
@@ -7,7 +7,6 @@
#include <string>
#include "chrome/browser/sync/engine/net/http_return.h"
-#include "chrome/browser/sync/util/sync_types.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -29,6 +28,12 @@ class GaiaAuthMockForGaiaAuthenticator : public GaiaAuthenticator {
response_body->assign("body\n");
return true;
}
+
+ int GetBackoffDelaySeconds(
+ int current_backoff_delay) {
+ // Dummy delay value.
+ return 5;
+ }
};
TEST(GaiaAuthenticatorTest, TestNewlineAtEndOfAuthTokenRemoved) {