summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 02:53:55 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 02:53:55 +0000
commitf3d0174b68971b96dd2e8f518d81abee1fc87645 (patch)
treedc8b5e279042af86343784c90c2b85553a100ab9 /chrome
parent92e83e01a65d77e69978360250979ddea41987ca (diff)
downloadchromium_src-f3d0174b68971b96dd2e8f518d81abee1fc87645.zip
chromium_src-f3d0174b68971b96dd2e8f518d81abee1fc87645.tar.gz
chromium_src-f3d0174b68971b96dd2e8f518d81abee1fc87645.tar.bz2
Moved GaiaAuthenticator from chrome/browser/sync/engine/net to chrome/common/net/gaia.
BUG=None TEST=None, no functional change. Review URL: http://codereview.chromium.org/1998004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/sync/engine/all_status.cc10
-rw-r--r--chrome/browser/sync/engine/all_status.h11
-rw-r--r--chrome/browser/sync/engine/auth_watcher.cc34
-rw-r--r--chrome/browser/sync/engine/auth_watcher.h8
-rw-r--r--chrome/browser/sync/engine/auth_watcher_unittest.cc12
-rw-r--r--chrome/browser/sync/engine/authenticator.cc10
-rw-r--r--chrome/browser/sync/engine/net/server_connection_manager.cc2
-rw-r--r--chrome/browser/sync/engine/net/server_connection_manager.h6
-rw-r--r--chrome/browser/sync/engine/net/syncapi_server_connection_manager.cc4
-rw-r--r--chrome/browser/sync/engine/syncapi.cc10
-rw-r--r--chrome/browser/sync/util/user_settings.cc10
-rw-r--r--chrome/browser/sync/util/user_settings.h7
-rw-r--r--chrome/chrome.gyp4
-rw-r--r--chrome/chrome_common.gypi4
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--chrome/common/net/gaia/gaia_authenticator.cc (renamed from chrome/browser/sync/engine/net/gaia_authenticator.cc)14
-rw-r--r--chrome/common/net/gaia/gaia_authenticator.h (renamed from chrome/browser/sync/engine/net/gaia_authenticator.h)33
-rw-r--r--chrome/common/net/gaia/gaia_authenticator_unittest.cc (renamed from chrome/browser/sync/engine/net/gaia_authenticator_unittest.cc)9
-rw-r--r--chrome/common/net/gaia/signin.h (renamed from chrome/browser/sync/util/signin.h)9
-rw-r--r--chrome/common/net/http_return.h (renamed from chrome/browser/sync/engine/net/http_return.h)11
-rw-r--r--chrome/test/sync/engine/mock_gaia_authenticator.cc8
-rw-r--r--chrome/test/sync/engine/mock_gaia_authenticator.h12
-rw-r--r--chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc10
23 files changed, 131 insertions, 109 deletions
diff --git a/chrome/browser/sync/engine/all_status.cc b/chrome/browser/sync/engine/all_status.cc
index 983833c..abd0e56 100644
--- a/chrome/browser/sync/engine/all_status.cc
+++ b/chrome/browser/sync/engine/all_status.cc
@@ -10,7 +10,6 @@
#include "base/port.h"
#include "base/rand_util.h"
#include "chrome/browser/sync/engine/auth_watcher.h"
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
#include "chrome/browser/sync/engine/net/server_connection_manager.h"
#include "chrome/browser/sync/engine/syncer.h"
#include "chrome/browser/sync/engine/syncer_thread.h"
@@ -18,6 +17,7 @@
#include "chrome/browser/sync/sessions/session_state.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/common/deprecated/event_sys-inl.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
#include "chrome/common/net/notifier/listener/talk_mediator.h"
namespace browser_sync {
@@ -59,7 +59,7 @@ void AllStatus::WatchConnectionManager(ServerConnectionManager* conn_mgr) {
&AllStatus::HandleServerConnectionEvent));
}
-void AllStatus::WatchAuthenticator(GaiaAuthenticator* gaia) {
+void AllStatus::WatchAuthenticator(gaia::GaiaAuthenticator* gaia) {
gaia_hookup_.reset(NewEventListenerHookup(gaia->channel(), this,
&AllStatus::HandleGaiaAuthEvent));
}
@@ -171,13 +171,13 @@ int AllStatus::CalcStatusChanges(Status* old_status) {
return what_changed;
}
-void AllStatus::HandleGaiaAuthEvent(const GaiaAuthEvent& gaia_event) {
+void AllStatus::HandleGaiaAuthEvent(const gaia::GaiaAuthEvent& gaia_event) {
ScopedStatusLockWithNotify lock(this);
switch (gaia_event.what_happened) {
- case GaiaAuthEvent::GAIA_AUTH_FAILED:
+ case gaia::GaiaAuthEvent::GAIA_AUTH_FAILED:
status_.authenticated = false;
break;
- case GaiaAuthEvent::GAIA_AUTH_SUCCEEDED:
+ case gaia::GaiaAuthEvent::GAIA_AUTH_SUCCEEDED:
status_.authenticated = true;
break;
default:
diff --git a/chrome/browser/sync/engine/all_status.h b/chrome/browser/sync/engine/all_status.h
index 3cd74cc..3e70119 100644
--- a/chrome/browser/sync/engine/all_status.h
+++ b/chrome/browser/sync/engine/all_status.h
@@ -15,6 +15,11 @@
#include "base/scoped_ptr.h"
#include "chrome/common/deprecated/event_sys.h"
+namespace gaia {
+class GaiaAuthenticator;
+struct GaiaAuthEvent;
+}
+
namespace notifier {
class TalkMediator;
struct TalkMediatorEvent;
@@ -23,14 +28,12 @@ struct TalkMediatorEvent;
namespace browser_sync {
class AuthWatcher;
-class GaiaAuthenticator;
class ScopedStatusLockWithNotify;
class ServerConnectionManager;
class Syncer;
class SyncerThread;
struct AllStatusEvent;
struct AuthWatcherEvent;
-struct GaiaAuthEvent;
struct ServerConnectionEvent;
struct SyncerEvent;
@@ -106,8 +109,8 @@ class AllStatus {
// HandleAuthWatcherEventachieve have the same goal; use only one of the
// following two. (The AuthWatcher is watched under Windows; the
// GaiaAuthenticator is watched under Mac/Linux.)
- void WatchAuthenticator(GaiaAuthenticator* gaia);
- void HandleGaiaAuthEvent(const GaiaAuthEvent& event);
+ void WatchAuthenticator(gaia::GaiaAuthenticator* gaia);
+ void HandleGaiaAuthEvent(const gaia::GaiaAuthEvent& event);
void WatchAuthWatcher(AuthWatcher* auth_watcher);
void HandleAuthWatcherEvent(const AuthWatcherEvent& event);
diff --git a/chrome/browser/sync/engine/auth_watcher.cc b/chrome/browser/sync/engine/auth_watcher.cc
index 7b98439..53c21cf 100644
--- a/chrome/browser/sync/engine/auth_watcher.cc
+++ b/chrome/browser/sync/engine/auth_watcher.cc
@@ -8,12 +8,12 @@
#include "base/string_util.h"
#include "chrome/browser/sync/engine/all_status.h"
#include "chrome/browser/sync/engine/authenticator.h"
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
#include "chrome/browser/sync/engine/net/server_connection_manager.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/util/user_settings.h"
#include "chrome/common/deprecated/event_sys-inl.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
#include "chrome/common/net/notifier/listener/talk_mediator.h"
// How authentication happens:
@@ -45,7 +45,7 @@ AuthWatcher::AuthWatcher(DirectoryManager* dirman,
const string& service_id,
const string& gaia_url,
UserSettings* user_settings,
- GaiaAuthenticator* gaia_auth,
+ gaia::GaiaAuthenticator* gaia_auth,
notifier::TalkMediator* talk_mediator)
: gaia_(gaia_auth),
dirman_(dirman),
@@ -71,7 +71,7 @@ AuthWatcher::AuthWatcher(DirectoryManager* dirman,
void AuthWatcher::PersistCredentials() {
DCHECK_EQ(MessageLoop::current(), message_loop());
- GaiaAuthenticator::AuthResults results = gaia_->results();
+ gaia::GaiaAuthenticator::AuthResults results = gaia_->results();
// We just successfully signed in again, let's clear out any residual cached
// login data from earlier sessions.
@@ -85,7 +85,7 @@ void AuthWatcher::PersistCredentials() {
if (!user_settings_->VerifyAgainstStoredHash(results.email, results.password))
user_settings_->StoreHashedPassword(results.email, results.password);
- if (PERSIST_TO_DISK == results.credentials_saved) {
+ if (gaia::PERSIST_TO_DISK == results.credentials_saved) {
user_settings_->SetAuthTokenForService(results.email,
SYNC_SERVICE_NAME,
gaia_->auth_token());
@@ -161,7 +161,7 @@ void AuthWatcher::DoAuthenticateWithToken(const std::string& gaia_email,
}
AuthWatcherEvent event = {AuthWatcherEvent::ILLEGAL_VALUE , 0};
gaia_->SetUsername(email);
- gaia_->SetAuthToken(auth_token, SAVE_IN_MEMORY_ONLY);
+ gaia_->SetAuthToken(auth_token, gaia::SAVE_IN_MEMORY_ONLY);
const bool was_authenticated = NOT_AUTHENTICATED != status_;
switch (result) {
case Authenticator::SUCCESS:
@@ -231,22 +231,23 @@ bool AuthWatcher::AuthenticateLocally(string email, const string& password) {
void AuthWatcher::ProcessGaiaAuthFailure() {
DCHECK_EQ(MessageLoop::current(), message_loop());
- GaiaAuthenticator::AuthResults results = gaia_->results();
+ gaia::GaiaAuthenticator::AuthResults results = gaia_->results();
if (LOCALLY_AUTHENTICATED == status_) {
return; // nothing todo
} else if (AuthenticateLocally(results.email, results.password)) {
// We save the "Remember me" checkbox by putting a non-null auth
// token into the last_user table. So if we're offline and the
// user checks the box, insert a bogus auth token.
- if (PERSIST_TO_DISK == results.credentials_saved) {
+ if (gaia::PERSIST_TO_DISK == results.credentials_saved) {
const string auth_token("bogus");
user_settings_->SetAuthTokenForService(results.email,
SYNC_SERVICE_NAME,
auth_token);
}
- const bool unavailable = ConnectionUnavailable == results.auth_error ||
- Unknown == results.auth_error ||
- ServiceUnavailable == results.auth_error;
+ const bool unavailable =
+ gaia::ConnectionUnavailable == results.auth_error ||
+ gaia::Unknown == results.auth_error ||
+ gaia::ServiceUnavailable == results.auth_error;
if (unavailable)
return;
}
@@ -262,10 +263,10 @@ void AuthWatcher::DoAuthenticate(const AuthRequest& request) {
current_attempt_trigger_ = request.trigger;
- SaveCredentials save = request.persist_creds_to_disk ?
- PERSIST_TO_DISK : SAVE_IN_MEMORY_ONLY;
- SignIn const signin = user_settings_->
- RecallSigninType(request.email, GMAIL_SIGNIN);
+ gaia::SaveCredentials save = request.persist_creds_to_disk ?
+ gaia::PERSIST_TO_DISK : gaia::SAVE_IN_MEMORY_ONLY;
+ gaia::SignIn const signin = user_settings_->
+ RecallSigninType(request.email, gaia::GMAIL_SIGNIN);
// We let the caller be lazy and try using the last captcha token seen by
// the gaia authenticator if they haven't provided a token but have sent
@@ -329,11 +330,12 @@ void AuthWatcher::DoHandleServerConnectionEvent(
// the auth failure should trigger UI indications that we're not logged in.
// METRIC: If we get a SYNC_AUTH_ERROR, our token expired.
- GaiaAuthenticator::AuthResults authresults = gaia_->results();
+ gaia::GaiaAuthenticator::AuthResults authresults = gaia_->results();
AuthRequest request = { authresults.email, authresults.password,
authresults.auth_token, std::string(),
std::string(),
- PERSIST_TO_DISK == authresults.credentials_saved,
+ gaia::PERSIST_TO_DISK ==
+ authresults.credentials_saved,
AuthWatcherEvent::EXPIRED_CREDENTIALS };
DoAuthenticate(request);
}
diff --git a/chrome/browser/sync/engine/auth_watcher.h b/chrome/browser/sync/engine/auth_watcher.h
index 149ade3..7ae3f98 100644
--- a/chrome/browser/sync/engine/auth_watcher.h
+++ b/chrome/browser/sync/engine/auth_watcher.h
@@ -15,10 +15,10 @@
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/thread.h"
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
#include "chrome/browser/sync/protocol/service_constants.h"
#include "chrome/browser/sync/util/sync_types.h"
#include "chrome/common/deprecated/event_sys.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
#include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST
namespace notifier {
@@ -53,7 +53,7 @@ struct AuthWatcherEvent {
ILLEGAL_VALUE,
};
WhatHappened what_happened;
- const GaiaAuthenticator::AuthResults* auth_results;
+ const gaia::GaiaAuthenticator::AuthResults* auth_results;
// use AuthWatcherEvent as its own traits type in hookups.
typedef AuthWatcherEvent EventType;
static inline bool IsChannelShutdownEvent(const AuthWatcherEvent& event) {
@@ -94,7 +94,7 @@ class AuthWatcher : public base::RefCountedThreadSafe<AuthWatcher> {
const std::string& service_id,
const std::string& gaia_url,
UserSettings* user_settings,
- GaiaAuthenticator* gaia_auth,
+ gaia::GaiaAuthenticator* gaia_auth,
notifier::TalkMediator* talk_mediator);
~AuthWatcher();
@@ -205,7 +205,7 @@ class AuthWatcher : public base::RefCountedThreadSafe<AuthWatcher> {
const ServerConnectionEvent& event,
const std::string& auth_token_snapshot);
- scoped_ptr<GaiaAuthenticator> const gaia_;
+ scoped_ptr<gaia::GaiaAuthenticator> const gaia_;
syncable::DirectoryManager* const dirman_;
ServerConnectionManager* const scm_;
scoped_ptr<EventListenerHookup> connmgr_hookup_;
diff --git a/chrome/browser/sync/engine/auth_watcher_unittest.cc b/chrome/browser/sync/engine/auth_watcher_unittest.cc
index 601d65f..f314155 100644
--- a/chrome/browser/sync/engine/auth_watcher_unittest.cc
+++ b/chrome/browser/sync/engine/auth_watcher_unittest.cc
@@ -8,11 +8,11 @@
#include "base/waitable_event.h"
#include "chrome/browser/sync/engine/all_status.h"
#include "chrome/browser/sync/engine/auth_watcher.h"
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
-#include "chrome/browser/sync/engine/net/http_return.h"
#include "chrome/browser/sync/util/user_settings.h"
#include "chrome/common/deprecated/event_sys-inl.h"
+#include "chrome/common/net/http_return.h"
#include "chrome/common/net/notifier/listener/talk_mediator_impl.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
#include "chrome/test/sync/engine/mock_server_connection.h"
#include "chrome/test/sync/engine/test_directory_setter_upper.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -34,9 +34,9 @@ static const char* kValidAuthToken = "validAuthToken";
namespace browser_sync {
-class GaiaAuthMockForAuthWatcher : public browser_sync::GaiaAuthenticator {
+class GaiaAuthMockForAuthWatcher : public gaia::GaiaAuthenticator {
public:
- GaiaAuthMockForAuthWatcher() : browser_sync::GaiaAuthenticator(
+ GaiaAuthMockForAuthWatcher() : GaiaAuthenticator(
kTestUserAgent, kTestServiceId, kTestGaiaURL),
use_bad_auth_token_(false) {}
virtual ~GaiaAuthMockForAuthWatcher() {}
@@ -55,7 +55,7 @@ class GaiaAuthMockForAuthWatcher : public browser_sync::GaiaAuthenticator {
protected:
bool PerformGaiaRequest(const AuthParams& params, AuthResults* results) {
if (params.password == kWrongPassword) {
- results->auth_error = browser_sync::BadAuthentication;
+ results->auth_error = gaia::BadAuthentication;
return false;
}
if (params.password == kCorrectPassword) {
@@ -71,7 +71,7 @@ class GaiaAuthMockForAuthWatcher : public browser_sync::GaiaAuthenticator {
}
bool LookupEmail(AuthResults* results) {
- results->signin = GMAIL_SIGNIN;
+ results->signin = gaia::GMAIL_SIGNIN;
return true;
}
diff --git a/chrome/browser/sync/engine/authenticator.cc b/chrome/browser/sync/engine/authenticator.cc
index 48f64fe..f8b3ce1 100644
--- a/chrome/browser/sync/engine/authenticator.cc
+++ b/chrome/browser/sync/engine/authenticator.cc
@@ -4,12 +4,12 @@
#include "chrome/browser/sync/engine/authenticator.h"
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
#include "chrome/browser/sync/engine/net/server_connection_manager.h"
#include "chrome/browser/sync/engine/syncproto.h"
#include "chrome/browser/sync/protocol/sync.pb.h"
#include "chrome/browser/sync/util/user_settings.h"
#include "chrome/common/deprecated/event_sys-inl.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
namespace browser_sync {
@@ -33,12 +33,12 @@ Authenticator::AuthenticationResult Authenticator::Authenticate(
string username, string password, bool save_credentials) {
// TODO(sync): need to figure out if this routine is used anywhere other
// than the test code.
- GaiaAuthenticator auth_service("ChromiumBrowser", "chromiumsync",
+ gaia::GaiaAuthenticator auth_service("ChromiumBrowser", "chromiumsync",
"https://www.google.com:443/accounts/ClientLogin");
auth_service.set_message_loop(MessageLoop::current());
- const SignIn signin_type =
- settings_->RecallSigninType(username, GMAIL_SIGNIN);
- if (!auth_service.Authenticate(username, password, SAVE_IN_MEMORY_ONLY,
+ const gaia::SignIn signin_type =
+ settings_->RecallSigninType(username, gaia::GMAIL_SIGNIN);
+ if (!auth_service.Authenticate(username, password, gaia::SAVE_IN_MEMORY_ONLY,
signin_type)) {
return UNSPECIFIC_ERROR_RETURN;
}
diff --git a/chrome/browser/sync/engine/net/server_connection_manager.cc b/chrome/browser/sync/engine/net/server_connection_manager.cc
index 225e3fb..7fbd9da 100644
--- a/chrome/browser/sync/engine/net/server_connection_manager.cc
+++ b/chrome/browser/sync/engine/net/server_connection_manager.cc
@@ -11,7 +11,6 @@
#include <vector>
#include "build/build_config.h"
-#include "chrome/browser/sync/engine/net/http_return.h"
#include "chrome/browser/sync/engine/net/url_translator.h"
#include "chrome/browser/sync/engine/syncapi.h"
#include "chrome/browser/sync/engine/syncer.h"
@@ -19,6 +18,7 @@
#include "chrome/browser/sync/protocol/sync.pb.h"
#include "chrome/browser/sync/syncable/directory_manager.h"
#include "chrome/common/deprecated/event_sys-inl.h"
+#include "chrome/common/net/http_return.h"
#include "googleurl/src/gurl.h"
namespace browser_sync {
diff --git a/chrome/browser/sync/engine/net/server_connection_manager.h b/chrome/browser/sync/engine/net/server_connection_manager.h
index 3681d06..05deddd 100644
--- a/chrome/browser/sync/engine/net/server_connection_manager.h
+++ b/chrome/browser/sync/engine/net/server_connection_manager.h
@@ -14,11 +14,11 @@
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
-#include "chrome/browser/sync/engine/net/http_return.h"
#include "chrome/browser/sync/syncable/syncable_id.h"
-#include "chrome/browser/sync/util/signin.h"
#include "chrome/browser/sync/util/sync_types.h"
#include "chrome/common/deprecated/event_sys.h"
+#include "chrome/common/net/http_return.h"
+#include "chrome/common/net/gaia/signin.h"
namespace syncable {
class WriteTransaction;
@@ -258,7 +258,7 @@ class ServerConnectionManager {
const std::string client_id() const { return client_id_; }
- void SetDomainFromSignIn(SignIn signin_type, const std::string& signin);
+ void SetDomainFromSignIn(gaia::SignIn signin_type, const std::string& signin);
// This changes the server info used by the connection manager. This allows
// a single client instance to talk to different backing servers. This is
diff --git a/chrome/browser/sync/engine/net/syncapi_server_connection_manager.cc b/chrome/browser/sync/engine/net/syncapi_server_connection_manager.cc
index d5b387e..08e5623 100644
--- a/chrome/browser/sync/engine/net/syncapi_server_connection_manager.cc
+++ b/chrome/browser/sync/engine/net/syncapi_server_connection_manager.cc
@@ -4,8 +4,8 @@
#include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h"
-#include "chrome/browser/sync/engine/net/http_return.h"
#include "chrome/browser/sync/engine/syncapi.h"
+#include "chrome/common/net/http_return.h"
using browser_sync::HttpResponse;
using std::string;
@@ -50,7 +50,7 @@ bool SyncAPIBridgedPost::Init(const char* path, const string& auth_token,
static_cast<int64>(http->GetResponseContentLength());
if (response->response_code < 400)
response->server_status = HttpResponse::SERVER_CONNECTION_OK;
- else if (response->response_code == browser_sync::RC_UNAUTHORIZED)
+ else if (response->response_code == RC_UNAUTHORIZED)
response->server_status = HttpResponse::SYNC_AUTH_ERROR;
else
response->server_status = HttpResponse::SYNC_SERVER_ERROR;
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index 1469927..20bfc12 100644
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -42,7 +42,6 @@
#include "chrome/browser/sync/engine/auth_watcher.h"
#include "chrome/browser/sync/engine/change_reorder_buffer.h"
#include "chrome/browser/sync/engine/model_safe_worker.h"
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
#include "chrome/browser/sync/engine/net/server_connection_manager.h"
#include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h"
#include "chrome/browser/sync/engine/syncer.h"
@@ -63,6 +62,7 @@
#include "chrome/browser/sync/util/user_settings.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/deprecated/event_sys.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
#include "chrome/common/net/notifier/listener/notification_constants.h"
#include "chrome/common/net/notifier/listener/talk_mediator.h"
#include "chrome/common/net/notifier/listener/talk_mediator_impl.h"
@@ -940,7 +940,7 @@ syncable::BaseTransaction* WriteTransaction::GetWrappedTrans() const {
}
// A GaiaAuthenticator that uses HttpPostProviders instead of CURL.
-class BridgedGaiaAuthenticator : public browser_sync::GaiaAuthenticator {
+class BridgedGaiaAuthenticator : public gaia::GaiaAuthenticator {
public:
BridgedGaiaAuthenticator(const string& user_agent, const string& service_id,
const string& gaia_url,
@@ -1424,7 +1424,7 @@ bool SyncManager::SyncInternal::Init(
// Watch various objects for aggregated status.
allstatus()->WatchConnectionManager(connection_manager());
- std::string gaia_url = browser_sync::kGaiaUrl;
+ std::string gaia_url = gaia::kGaiaUrl;
const char* service_id = gaia_service_id ?
gaia_service_id : SYNC_SERVICE_NAME;
@@ -1961,7 +1961,7 @@ void SyncManager::SyncInternal::HandleAuthWatcherEvent(
return;
// Authentication failures translate to GoogleServiceAuthError events.
case AuthWatcherEvent::GAIA_AUTH_FAILED: // Invalid GAIA credentials.
- if (event.auth_results->auth_error == browser_sync::CaptchaRequired) {
+ if (event.auth_results->auth_error == gaia::CaptchaRequired) {
auth_problem_ = AuthError::CAPTCHA_REQUIRED;
std::string url_string("https://www.google.com/accounts/");
url_string += event.auth_results->captcha_url;
@@ -1971,7 +1971,7 @@ void SyncManager::SyncInternal::HandleAuthWatcherEvent(
GURL(event.auth_results->auth_error_url)));
return;
} else if (event.auth_results->auth_error ==
- browser_sync::ConnectionUnavailable) {
+ gaia::ConnectionUnavailable) {
auth_problem_ = AuthError::CONNECTION_FAILED;
} else {
auth_problem_ = AuthError::INVALID_GAIA_CREDENTIALS;
diff --git a/chrome/browser/sync/util/user_settings.cc b/chrome/browser/sync/util/user_settings.cc
index 9c492e1..043d532 100644
--- a/chrome/browser/sync/util/user_settings.cc
+++ b/chrome/browser/sync/util/user_settings.cc
@@ -429,8 +429,8 @@ void UserSettings::SwitchUser(const string& username) {
}
}
-void UserSettings::RememberSigninType(const string& signin, SignIn signin_type)
-{
+void UserSettings::RememberSigninType(const string& signin,
+ gaia::SignIn signin_type) {
ScopedDBHandle dbhandle(this);
SQLStatement statement;
statement.prepare(dbhandle.get(),
@@ -443,8 +443,8 @@ void UserSettings::RememberSigninType(const string& signin, SignIn signin_type)
}
}
-SignIn UserSettings::RecallSigninType(const string& signin, SignIn default_type)
-{
+gaia::SignIn UserSettings::RecallSigninType(const string& signin,
+ gaia::SignIn default_type) {
ScopedDBHandle dbhandle(this);
SQLStatement statement;
statement.prepare(dbhandle.get(),
@@ -453,7 +453,7 @@ SignIn UserSettings::RecallSigninType(const string& signin, SignIn default_type)
int query_result = statement.step();
if (SQLITE_ROW == query_result) {
int signin_type = statement.column_int(0);
- return static_cast<SignIn>(signin_type);
+ return static_cast<gaia::SignIn>(signin_type);
}
return default_type;
}
diff --git a/chrome/browser/sync/util/user_settings.h b/chrome/browser/sync/util/user_settings.h
index 17de505..e379cc0 100644
--- a/chrome/browser/sync/util/user_settings.h
+++ b/chrome/browser/sync/util/user_settings.h
@@ -12,8 +12,8 @@
#include "base/file_path.h"
#include "base/lock.h"
#include "build/build_config.h"
-#include "chrome/browser/sync/util/signin.h"
#include "chrome/browser/sync/util/sync_types.h"
+#include "chrome/common/net/gaia/signin.h"
extern "C" struct sqlite3;
@@ -59,8 +59,9 @@ class UserSettings {
std::string* username,
std::string* service_token);
- void RememberSigninType(const std::string& signin, SignIn signin_type);
- SignIn RecallSigninType(const std::string& signin, SignIn default_type);
+ void RememberSigninType(const std::string& signin, gaia::SignIn signin_type);
+ gaia::SignIn RecallSigninType(const std::string& signin,
+ gaia::SignIn default_type);
void RemoveAllGuestSettings();
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 614521c..a622be2 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -842,9 +842,6 @@
'browser/sync/engine/model_changing_syncer_command.h',
'browser/sync/engine/model_safe_worker.cc',
'browser/sync/engine/model_safe_worker.h',
- 'browser/sync/engine/net/gaia_authenticator.cc',
- 'browser/sync/engine/net/gaia_authenticator.h',
- 'browser/sync/engine/net/http_return.h',
'browser/sync/engine/net/server_connection_manager.cc',
'browser/sync/engine/net/server_connection_manager.h',
'browser/sync/engine/net/syncapi_server_connection_manager.cc',
@@ -920,7 +917,6 @@
'browser/sync/util/nigori.cc',
'browser/sync/util/nigori.h',
'browser/sync/util/row_iterator.h',
- 'browser/sync/util/signin.h',
'browser/sync/util/sync_types.h',
'browser/sync/util/user_settings.cc',
'browser/sync/util/user_settings.h',
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 93728d5..4845f34 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -306,6 +306,7 @@
'type': '<(library)',
'sources': [
'common/net/dns.h',
+ 'common/net/http_return.h',
'common/net/net_resource_provider.cc',
'common/net/net_resource_provider.h',
'common/net/network_change_notifier_proxy.cc',
@@ -316,6 +317,9 @@
'common/net/socket_stream.h',
'common/net/url_request_intercept_job.cc',
'common/net/url_request_intercept_job.h',
+ 'common/net/gaia/gaia_authenticator.cc',
+ 'common/net/gaia/gaia_authenticator.h',
+ 'common/net/gaia/signin.h',
],
'dependencies': [
'chrome_resources',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 016af11..17bbb12 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -979,6 +979,7 @@
'common/extensions/user_script_unittest.cc',
'common/json_value_serializer_unittest.cc',
'common/mru_cache_unittest.cc',
+ 'common/net/gaia/gaia_authenticator_unittest.cc',
'common/notification_service_unittest.cc',
'common/process_watcher_unittest.cc',
'common/property_bag_unittest.cc',
@@ -1773,7 +1774,6 @@
'browser/sync/engine/auth_watcher_unittest.cc',
'browser/sync/engine/download_updates_command_unittest.cc',
'browser/sync/engine/mock_model_safe_workers.h',
- 'browser/sync/engine/net/gaia_authenticator_unittest.cc',
'browser/sync/engine/process_commit_response_command_unittest.cc',
'browser/sync/engine/syncapi_unittest.cc',
'browser/sync/engine/syncer_proto_util_unittest.cc',
diff --git a/chrome/browser/sync/engine/net/gaia_authenticator.cc b/chrome/common/net/gaia/gaia_authenticator.cc
index 2be47f8..38fc19b 100644
--- a/chrome/browser/sync/engine/net/gaia_authenticator.cc
+++ b/chrome/common/net/gaia/gaia_authenticator.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
#include <string>
#include <utility>
@@ -11,8 +11,8 @@
#include "base/basictypes.h"
#include "base/port.h"
#include "base/string_split.h"
-#include "chrome/browser/sync/engine/net/http_return.h"
#include "chrome/common/deprecated/event_sys-inl.h"
+#include "chrome/common/net/http_return.h"
#include "googleurl/src/gurl.h"
#include "net/base/escape.h"
@@ -20,7 +20,7 @@ using std::pair;
using std::string;
using std::vector;
-namespace browser_sync {
+namespace gaia {
static const char kGaiaV1IssueAuthTokenPath[] = "/accounts/IssueAuthToken";
@@ -132,7 +132,12 @@ bool GaiaAuthenticator::AuthenticateImpl(const AuthParams& params,
// The aim of this code is to start failing requests if due to a logic error
// in the program we're hammering GAIA.
+#if defined(OS_WIN)
+ __time32_t now = _time32(0);
+#else // defined(OS_WIN)
time_t now = time(0);
+#endif // defined(OS_WIN)
+
if (now > next_allowed_auth_attempt_time_) {
next_allowed_auth_attempt_time_ = now + 1;
// If we're more than 2 minutes past the allowed time we reset the early
@@ -395,4 +400,5 @@ bool GaiaAuthenticator::Authenticate(const string& user_name,
empty, try_first);
}
-} // namespace browser_sync
+} // namepace gaia
+
diff --git a/chrome/browser/sync/engine/net/gaia_authenticator.h b/chrome/common/net/gaia/gaia_authenticator.h
index a489cca..b165cf6 100644
--- a/chrome/browser/sync/engine/net/gaia_authenticator.h
+++ b/chrome/common/net/gaia/gaia_authenticator.h
@@ -3,11 +3,14 @@
// found in the LICENSE file.
//
// Use this class to authenticate users with Gaia and access cookies sent
-// by the Gaia servers. This class lives on the SyncEngine_AuthWatcherThread.
+// by the Gaia servers. This class cannot be used on its own becaue it relies
+// on a subclass to provide the virtual Post and GetBackoffDelaySeconds methods.
//
// Sample usage:
-// GaiaAuthenticator gaia_auth("User-Agent", SYNC_SERVICE_NAME,
-// browser_sync::kExternalGaiaUrl);
+// class ActualGaiaAuthenticator : public gaia::GaiaAuthenticator {
+// Provides actual implementation of Post and GetBackoffDelaySeconds.
+// };
+// ActualGaiaAuthenticator gaia_auth("User-Agent", SERVICE_NAME, kGaiaUrl);
// if (gaia_auth.Authenticate("email", "passwd", SAVE_IN_MEMORY_ONLY,
// true)) { // Synchronous
// // Do something with: gaia_auth.auth_token(), or gaia_auth.sid(),
@@ -19,29 +22,30 @@
// email address associated with the Gaia account can be read; the password is
// write-only.
-#ifndef CHROME_BROWSER_SYNC_ENGINE_NET_GAIA_AUTHENTICATOR_H_
-#define CHROME_BROWSER_SYNC_ENGINE_NET_GAIA_AUTHENTICATOR_H_
+// TODO(sanjeevr): This class has been moved here from the bookmarks sync code.
+// While it is a generic class that handles GAIA authentication, there are some
+// artifacts of the sync code such as the SaveCredentials enum which needs to
+// be cleaned up.
+#ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR_H_
+#define CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR_H_
#include <string>
#include "base/basictypes.h"
#include "base/message_loop.h"
-#include "chrome/browser/sync/util/signin.h"
+#include "chrome/common/net/gaia/signin.h"
#include "chrome/common/deprecated/event_sys.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest_prod.h" // For FRIEND_TEST
-namespace browser_sync {
+namespace gaia {
static const char kGaiaUrl[] =
"https://www.google.com:443/accounts/ClientLogin";
// Use of the following enum is odd. GaiaAuthenticator only looks at
// and DONT_SAVE_CREDENTIALS and SAVE_IN_MEMORY_ONLY (PERSIST_TO_DISK is == to
-// SAVE_IN_MEMORY_ONLY for GaiaAuthenticator). The sync engine never uses
-// DONT_SAVE_CREDENTIALS. AuthWatcher does look in GaiaAuthenticator's results
-// object to decide if it should save credentials to disk. This currently
-// works so I'm leaving the odd dance alone.
+// SAVE_IN_MEMORY_ONLY for GaiaAuthenticator).
enum SaveCredentials {
DONT_SAVE_CREDENTIALS,
@@ -318,11 +322,10 @@ class GaiaAuthenticator {
#endif // defined(OS_WIN)
int early_auth_attempt_count_;
- // The message loop all our methods are invoked on. Generally this is the
- // SyncEngine_AuthWatcherThread's message loop.
+ // The message loop all our methods are invoked on.
const MessageLoop* message_loop_;
};
-} // namespace browser_sync
+} // namespace gaia
+#endif // CHROME_COMMON_NET_GAIA_GAIA_AUTHENTICATOR_H_
-#endif // CHROME_BROWSER_SYNC_ENGINE_NET_GAIA_AUTHENTICATOR_H_
diff --git a/chrome/browser/sync/engine/net/gaia_authenticator_unittest.cc b/chrome/common/net/gaia/gaia_authenticator_unittest.cc
index 6955a0a..1f9813d 100644
--- a/chrome/browser/sync/engine/net/gaia_authenticator_unittest.cc
+++ b/chrome/common/net/gaia/gaia_authenticator_unittest.cc
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
#include <string>
-#include "chrome/browser/sync/engine/net/http_return.h"
+#include "chrome/common/net/http_return.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
using std::string;
-namespace browser_sync {
+namespace gaia {
class GaiaAuthenticatorTest : public testing::Test { };
@@ -45,4 +45,5 @@ TEST(GaiaAuthenticatorTest, TestNewlineAtEndOfAuthTokenRemoved) {
EXPECT_EQ(0, results.auth_token.compare("body"));
}
-} // namespace browser_sync
+} // namespace gaia
+
diff --git a/chrome/browser/sync/util/signin.h b/chrome/common/net/gaia/signin.h
index 0664d38..48f3654 100644
--- a/chrome/browser/sync/util/signin.h
+++ b/chrome/common/net/gaia/signin.h
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SYNC_UTIL_SIGNIN_H_
-#define CHROME_BROWSER_SYNC_UTIL_SIGNIN_H_
+#ifndef CHROME_COMMON_NET_GAIA_SIGNIN_H_
+#define CHROME_COMMON_NET_GAIA_SIGNIN_H_
+namespace gaia {
// This enumeration is here since we used to support hosted and non-hosted
// accounts, but now only the latter is supported.
enum SignIn {
@@ -12,4 +13,6 @@ enum SignIn {
GMAIL_SIGNIN
};
-#endif // CHROME_BROWSER_SYNC_UTIL_SIGNIN_H_
+} // namespace gaia
+#endif // CHROME_COMMON_NET_GAIA_SIGNIN_H_
+
diff --git a/chrome/browser/sync/engine/net/http_return.h b/chrome/common/net/http_return.h
index fd5167b..f47d1bb 100644
--- a/chrome/browser/sync/engine/net/http_return.h
+++ b/chrome/common/net/http_return.h
@@ -2,15 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SYNC_ENGINE_NET_HTTP_RETURN_H_
-#define CHROME_BROWSER_SYNC_ENGINE_NET_HTTP_RETURN_H_
+#ifndef CHROME_COMMON_NET_HTTP_RETURN_H_
+#define CHROME_COMMON_NET_HTTP_RETURN_H_
-namespace browser_sync {
+// TODO(sanjeevr): This has been moved from the sync library so it only
+// contains a few HTTP return codes. Add more HTTP return codes.
enum HTTPReturnCode {
RC_REQUEST_OK = 200,
RC_UNAUTHORIZED = 401,
RC_FORBIDDEN = 403,
};
-} // namespace browser_sync
-#endif // CHROME_BROWSER_SYNC_ENGINE_NET_HTTP_RETURN_H_
+#endif // CHROME_COMMON_NET_HTTP_RETURN_H_
+
diff --git a/chrome/test/sync/engine/mock_gaia_authenticator.cc b/chrome/test/sync/engine/mock_gaia_authenticator.cc
index 867da59..ebcf566 100644
--- a/chrome/test/sync/engine/mock_gaia_authenticator.cc
+++ b/chrome/test/sync/engine/mock_gaia_authenticator.cc
@@ -29,7 +29,8 @@ void MockGaiaAuthenticator::AddMockUser(MockUser mock_user) {
// A convenience method to add a mock user to internal list of users.
void MockGaiaAuthenticator::AddMockUser(string email, string passwd,
string auth_token, string lsid,
- string sid, enum AuthenticationError
+ string sid,
+ enum gaia::AuthenticationError
auth_error, string error_url,
string captcha_token,
string captcha_url) {
@@ -49,7 +50,8 @@ void MockGaiaAuthenticator::AddMockUser(string email, string passwd,
// A convenience method to add a mock user to internal list of users.
void MockGaiaAuthenticator::AddMockUser(string email, string passwd,
string auth_token, string lsid,
- string sid, enum AuthenticationError
+ string sid,
+ enum gaia::AuthenticationError
auth_error) {
MockUser mock_user;
mock_user.email = email;
@@ -96,7 +98,7 @@ bool MockGaiaAuthenticator::Authenticate(const char* email,
// Finding a user does not necessarily imply that the user was logged in OK.
// Therefore also check if the AuthenticationError is None.
- return (mock_credentials_[current_user_].auth_error == None);
+ return (mock_credentials_[current_user_].auth_error == gaia::None);
}
// Remove any stored knowledge about the currently logged-in user, but keep
diff --git a/chrome/test/sync/engine/mock_gaia_authenticator.h b/chrome/test/sync/engine/mock_gaia_authenticator.h
index 1968200..7eff11a 100644
--- a/chrome/test/sync/engine/mock_gaia_authenticator.h
+++ b/chrome/test/sync/engine/mock_gaia_authenticator.h
@@ -29,7 +29,7 @@
#include "base/port.h"
#include "base/basictypes.h"
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
namespace browser_sync {
@@ -42,7 +42,7 @@ typedef struct {
std::string auth_token;
std::string sid;
std::string lsid;
- AuthenticationError auth_error;
+ gaia::AuthenticationError auth_error;
std::string captcha_token;
std::string captcha_url;
std::string error_url;
@@ -66,7 +66,7 @@ class MockGaiaAuthenticator {
void AddMockUser(std::string email, std::string passwd,
std::string auth_token,
std::string lsid, std::string sid,
- AuthenticationError auth_error,
+ gaia::AuthenticationError auth_error,
std::string error_url, std::string captcha_token,
std::string captcha_url);
@@ -76,7 +76,7 @@ class MockGaiaAuthenticator {
void AddMockUser(std::string email, std::string passwd,
std::string auth_token,
std::string lsid, std::string sid,
- enum AuthenticationError auth_error);
+ enum gaia::AuthenticationError auth_error);
// Removes a mock user from the current list of added users.
void RemoveMockUser(const char* email);
@@ -115,8 +115,8 @@ class MockGaiaAuthenticator {
mock_credentials_[current_user_].lsid;
}
- AuthenticationError auth_error() {
- return (current_user_.length() == 0) ? CredentialsNotSet :
+ gaia::AuthenticationError auth_error() {
+ return (current_user_.length() == 0) ? gaia::CredentialsNotSet :
mock_credentials_[current_user_].auth_error;
}
diff --git a/chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc b/chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc
index 76c08aa..cf0b994 100644
--- a/chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc
+++ b/chrome/test/sync/engine/mock_gaia_authenticator_unittest.cc
@@ -6,8 +6,8 @@
#include "base/basictypes.h"
#include "base/port.h"
-#include "chrome/browser/sync/engine/net/gaia_authenticator.h"
#include "chrome/browser/sync/protocol/service_constants.h"
+#include "chrome/common/net/gaia/gaia_authenticator.h"
#include "chrome/test/sync/engine/mock_gaia_authenticator.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -26,7 +26,7 @@ TEST(MockGaiaAuthenticatorTest, TestAuthenticationSuccess) {
mock_user.auth_token = "SomeAuthToken";
mock_user.lsid = "SomeLSID";
mock_user.sid = "SomeSID";
- mock_user.auth_error = browser_sync::None;
+ mock_user.auth_error = gaia::None;
mock_gaia_auth.AddMockUser(mock_user);
// Assert away ...
@@ -63,7 +63,7 @@ TEST(MockGaiaAuthenticatorTest, TestRemoveMockUser) {
// Add our mock user
mock_gaia_auth.AddMockUser("test", "passwd", "SomeAuthToken", "SomeLSID",
- "SomeSID", browser_sync::None);
+ "SomeSID", gaia::None);
// Make sure authentication succeeds.
ASSERT_TRUE(mock_gaia_auth.Authenticate("test", "passwd"));
@@ -90,7 +90,7 @@ TEST(MockGaiaAuthenticatorTest, TestRemoveAllMockUsers) {
// Add our sample mock user.
mock_gaia_auth.AddMockUser("test", "passwd", "SomeAuthToken", "SomeLSID",
- "SomeSID", browser_sync::None);
+ "SomeSID", gaia::None);
// Make sure authentication succeeds
ASSERT_TRUE(mock_gaia_auth.Authenticate("test", "passwd"));
@@ -117,7 +117,7 @@ TEST(MockGaiaAuthenticatorTest, TestSavedCredentials) {
// Add our sample mock user.
mock_gaia_auth.AddMockUser("test", "passwd", "SomeAuthToken", "SomeLSID",
- "SomeSID", browser_sync::None);
+ "SomeSID", gaia::None);
// Ask to save credentials.
ASSERT_TRUE(mock_gaia_auth.Authenticate("test", "passwd", true));