Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5170)

Unified Diff: chrome/common/net/gaia/authentication_fetcher.cc

Issue 6894027: Initial refactoring complete Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed some tests that were broken by previous refactoring Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/net/gaia/authentication_fetcher.cc
diff --git a/chrome/common/net/gaia/authentication_fetcher.cc b/chrome/common/net/gaia/authentication_fetcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..226174284dbf91cd021525b5a8276487934c388b
--- /dev/null
+++ b/chrome/common/net/gaia/authentication_fetcher.cc
@@ -0,0 +1,163 @@
+// Copyright (c) 2011 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.
+
+#include "chrome/common/net/gaia/authentication_fetcher.h"
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/logging.h"
+#include "base/string_split.h"
+#include "base/string_util.h"
+#include "chrome/browser/net/gaia/authentication_service.h"
+#include "chrome/common/net/gaia/gaia_auth_fetcher.h"
+#include "chrome/common/net/gaia/gaia_constants.h"
+#include "chrome/common/net/gaia/google_service_auth_error.h"
+#include "chrome/common/net/gaia/authentication_consumer_oauth.h"
+#include "chrome/common/net/gaia/authentication_fetcher_oauth.h"
+#include "chrome/common/net/http_return.h"
+#include "net/base/load_flags.h"
+#include "net/url_request/url_request_context_getter.h"
+#include "net/url_request/url_request_status.h"
+#include "third_party/libjingle/source/talk/base/urlencode.h"
+
+// TODO(chron): Add sourceless version of this formatter.
+// static
+const char AuthenticationFetcher::kAuthenticationFormat[] =
+ "Email=%s&"
+ "Passwd=%s&"
+ "PersistentCookie=%s&"
+ "accountType=%s&"
+ "source=%s&"
+ "service=%s";
+// static
+const char AuthenticationFetcher::kAuthenticationCaptchaFormat[] =
+ "Email=%s&"
+ "Passwd=%s&"
+ "PersistentCookie=%s&"
+ "accountType=%s&"
+ "source=%s&"
+ "service=%s&"
+ "logintoken=%s&"
+ "logincaptcha=%s";
+// static
+const char AuthenticationFetcher::kIssueAuthTokenFormat[] =
+ "SID=%s&"
+ "LSID=%s&"
+ "service=%s&"
+ "Session=%s";
+// static
+const char AuthenticationFetcher::kGetUserInfoFormat[] =
+ "LSID=%s";
+
+// static
+const char AuthenticationFetcher::kAccountDeletedError[] = "AccountDeleted";
+// static
+const char AuthenticationFetcher::kAccountDisabledError[] = "AccountDisabled";
+// static
+const char AuthenticationFetcher::kBadAuthenticationError[] =
+ "BadAuthentication";
+// static
+const char AuthenticationFetcher::kCaptchaError[] = "CaptchaRequired";
+// static
+const char AuthenticationFetcher::kServiceUnavailableError[] =
+ "ServiceUnavailable";
+// static
+const char AuthenticationFetcher::kErrorParam[] = "Error";
+// static
+const char AuthenticationFetcher::kErrorUrlParam[] = "Url";
+// static
+const char AuthenticationFetcher::kCaptchaUrlParam[] = "CaptchaUrl";
+// static
+const char AuthenticationFetcher::kCaptchaTokenParam[] = "CaptchaToken";
+// static
+const char AuthenticationFetcher::kCaptchaUrlPrefix[] =
+ "http://www.google.com/accounts/";
+
+// static
+const char AuthenticationFetcher::kCookiePersistence[] = "true";
+// static
+// TODO(johnnyg): When hosted accounts are supported by sync,
+// we can always use "HOSTED_OR_GOOGLE"
+const char AuthenticationFetcher::kAccountTypeHostedOrGoogle[] =
+ "HOSTED_OR_GOOGLE";
+const char AuthenticationFetcher::kAccountTypeGoogle[] =
+ "GOOGLE";
+
+// static
+const char AuthenticationFetcher::kSecondFactor[] = "Info=InvalidSecondFactor";
+
+// TODO(chron): These urls are also in auth_response_handler.h.
+// The URLs for different calls in the Google Accounts programmatic login API.
+const char AuthenticationFetcher::kAuthenticationUrl[] =
+ "https://www.google.com/accounts/ClientLogin";
+const char AuthenticationFetcher::kIssueAuthTokenUrl[] =
+ "https://www.google.com/accounts/IssueAuthToken";
+const char AuthenticationFetcher::kGetUserInfoUrl[] =
+ "https://www.google.com/accounts/GetUserInfo";
+
+AuthenticationFetcher::AuthenticationFetcher(
+ AuthenticationConsumer* consumer,
+ const std::string& source,
+ net::URLRequestContextGetter* getter)
+ : consumer_(consumer),
+ getter_(getter),
+ source_(source),
+ fetch_pending_(false) {}
+
+AuthenticationFetcher::~AuthenticationFetcher() {}
+
+bool AuthenticationFetcher::HasPendingFetch() const {
+ return fetch_pending_;
+}
+
+void AuthenticationFetcher::CancelRequest() {
+ fetcher_.reset();
+ fetch_pending_ = false;
+}
+
+void AuthenticationFetcher::ClearPending() {
+ fetch_pending_ = false;
+}
+
+void AuthenticationFetcher::SetPending() {
+ fetch_pending_ = true;
+}
+
+// static
+AuthenticationFetcher* AuthenticationFetcher::CreateAuthenticationFetcher(
+ const std::string& variant,
+ AuthenticationConsumer* consumer,
+ const std::string& source,
+ net::URLRequestContextGetter* getter) {
+ if (variant == AuthenticationService::kClientLoginVariant) {
+ return new GaiaAuthFetcher(
+ static_cast<GaiaAuthConsumer*>(consumer), source, getter);
+ }
+ if (variant == AuthenticationService::kOAuthVariant) {
+ return new AuthenticationFetcherOAuth(
+ static_cast<AuthenticationConsumerOAuth*>(consumer), source, getter);
+ }
+ NOTREACHED();
+ return NULL;
+}
+
+// static
+URLFetcher* AuthenticationFetcher::CreateAuthenticationFetcher(
+ net::URLRequestContextGetter* getter,
+ const std::string& body,
+ const GURL& gaia_gurl,
+ URLFetcher::Delegate* delegate) {
+
+ URLFetcher* to_return =
+ URLFetcher::Create(0,
+ gaia_gurl,
+ URLFetcher::POST,
+ delegate);
+ to_return->set_request_context(getter);
+ to_return->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES);
+ to_return->set_upload_data("application/x-www-form-urlencoded", body);
+ return to_return;
+}
« no previous file with comments | « chrome/common/net/gaia/authentication_fetcher.h ('k') | chrome/common/net/gaia/authentication_fetcher_oauth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698