From 0fe62ca2d641de1d917ad2e004e6b51472821984 Mon Sep 17 00:00:00 2001 From: "xiyuan@chromium.org" Date: Tue, 24 Jan 2012 22:27:04 +0000 Subject: [PATCH] Revert "Update Gaia URL." This change reverts r118627 and r118640. BUG=hromium-os:24612 TEST=Login/sync works and policy fetched as before the gaia url change. TBR=zelidrag@chromium.org Review URL: https://chromiumcodereview.appspot.com/9117048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118919 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/chromeos/login/mock_url_fetchers.cc | 4 +- chrome/browser/net/browser_url_util.cc | 27 +------------- chrome/browser/net/browser_url_util.h | 9 +---- chrome/browser/net/browser_url_util_unittest.cc | 21 +---------- chrome/browser/net/gaia/gaia_oauth_fetcher.cc | 43 +--------------------- chrome/browser/sync/test/integration/sync_test.cc | 6 +-- .../browser/ui/webui/sync_promo/sync_promo_ui.cc | 39 ++++++++++++++++---- .../common/net/gaia/gaia_auth_fetcher_unittest.cc | 4 +- chrome/common/net/gaia/gaia_urls.cc | 42 +++++++-------------- chrome/common/net/gaia/gaia_urls.h | 4 +- 10 files changed, 58 insertions(+), 141 deletions(-) diff --git a/chrome/browser/chromeos/login/mock_url_fetchers.cc b/chrome/browser/chromeos/login/mock_url_fetchers.cc index fa70a5cf675b..5636a4480eeb 100644 --- a/chrome/browser/chromeos/login/mock_url_fetchers.cc +++ b/chrome/browser/chromeos/login/mock_url_fetchers.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. @@ -100,7 +100,7 @@ void FailFetcher::Start() { // static const char CaptchaFetcher::kCaptchaToken[] = "token"; // static -const char CaptchaFetcher::kCaptchaUrlBase[] = "http://accounts.google.com/"; +const char CaptchaFetcher::kCaptchaUrlBase[] = "http://www.google.com/accounts/"; // static const char CaptchaFetcher::kCaptchaUrlFragment[] = "fragment"; // static diff --git a/chrome/browser/net/browser_url_util.cc b/chrome/browser/net/browser_url_util.cc index b3e967d76113..4c33181b1354 100644 --- a/chrome/browser/net/browser_url_util.cc +++ b/chrome/browser/net/browser_url_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. @@ -8,7 +8,6 @@ #include "base/utf_string_conversions.h" #include "chrome/common/url_constants.h" #include "googleurl/src/gurl.h" -#include "googleurl/src/url_util.h" #include "net/base/escape.h" #include "net/base/net_util.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" @@ -45,28 +44,4 @@ GURL AppendQueryParameter(const GURL& url, return url.ReplaceComponents(replacements); } -bool GetValueForKeyInQuery(const GURL& url, - const std::string& search_key, - std::string* out_value) { - url_parse::Component query = url.parsed_for_possibly_invalid_spec().query; - url_parse::Component key, value; - while (url_parse::ExtractQueryKeyValue( - url.spec().c_str(), &query, &key, &value)) { - if (key.is_nonempty()) { - std::string key_string = url.spec().substr(key.begin, key.len); - if (key_string == search_key) { - if (value.is_nonempty()) { - *out_value = net::UnescapeURLComponent( - url.spec().substr(value.begin, value.len), - net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); - } else { - *out_value = ""; - } - return true; - } - } - } - return false; -} - } // namespace chrome_browser_net diff --git a/chrome/browser/net/browser_url_util.h b/chrome/browser/net/browser_url_util.h index 9825acba466a..1f6e4e20df3f 100644 --- a/chrome/browser/net/browser_url_util.h +++ b/chrome/browser/net/browser_url_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. @@ -35,13 +35,6 @@ GURL AppendQueryParameter(const GURL& url, const std::string& name, const std::string& value); -// Looks for |search_key| in the query portion of |url|. Returns true if the -// key is found and sets |out_value| to the unescaped value for the key. -// Returns false if the key is not found. -bool GetValueForKeyInQuery(const GURL& url, - const std::string& search_key, - std::string* out_value); - } // namespace chrome_browser_net #endif // CHROME_BROWSER_NET_BROWSER_URL_UTIL_H_ diff --git a/chrome/browser/net/browser_url_util_unittest.cc b/chrome/browser/net/browser_url_util_unittest.cc index e3c43881b30d..830024f19402 100644 --- a/chrome/browser/net/browser_url_util_unittest.cc +++ b/chrome/browser/net/browser_url_util_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. @@ -29,23 +29,4 @@ TEST(BrowserUrlUtilTest, AppendQueryParameter) { "na me", "v.alue=").spec()); } -TEST(BrowserUrlUtilTest, GetValueForKeyInQuery) { - GURL url("http://example.com/path?name=value&boolParam&" - "url=http://test.com/q?n1%3Dv1%26n2"); - std::string value; - - // False when getting a non-existent query param. - EXPECT_FALSE(GetValueForKeyInQuery(url, "non-exist", &value)); - - // True when query param exist. - EXPECT_TRUE(GetValueForKeyInQuery(url, "name", &value)); - EXPECT_EQ("value", value); - - EXPECT_TRUE(GetValueForKeyInQuery(url, "boolParam", &value)); - EXPECT_EQ("", value); - - EXPECT_TRUE(GetValueForKeyInQuery(url, "url", &value)); - EXPECT_EQ("http://test.com/q?n1=v1&n2", value); -} - } // namespace chrome_browser_net. diff --git a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc index 9145390403a0..4ede11e45278 100644 --- a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc +++ b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. @@ -11,7 +11,6 @@ #include "base/json/json_reader.h" #include "base/string_split.h" #include "base/string_util.h" -#include "chrome/browser/net/browser_url_util.h" #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tabs/tab_strip_model.h" @@ -687,45 +686,7 @@ void GaiaOAuthFetcher::OnURLFetchComplete(const content::URLFetcher* source) { true)) { OnOAuthRevokeTokenFetched(data, status, response_code); } else { - // Invalid cookies cause Gaia to redirect to ServiceLogin. Check if - // this is the case and report failure properly. - std::string url_no_query = url.GetOrigin().spec() + url.path().substr(1); - std::string continue_url; - if (url_no_query == gaia_urls->service_login_url() && - chrome_browser_net::GetValueForKeyInQuery(url, "continue", - &continue_url)) { - LOG(ERROR) << "GaiaOAuthFetcher redirected to service login" - << " , url=" << url.spec(); - - if (StartsWithASCII(continue_url, - gaia_urls->get_oauth_token_url(), - true)) { - consumer_->OnGetOAuthTokenFailure(GoogleServiceAuthError( - GoogleServiceAuthError::SERVICE_UNAVAILABLE)); - } else if (continue_url == gaia_urls->oauth1_login_url()) { - consumer_->OnOAuthLoginFailure(GoogleServiceAuthError( - GoogleServiceAuthError::SERVICE_UNAVAILABLE)); - } else if (continue_url == gaia_urls->oauth_get_access_token_url()) { - consumer_->OnOAuthGetAccessTokenFailure(GoogleServiceAuthError( - GoogleServiceAuthError::SERVICE_UNAVAILABLE)); - } else if (continue_url == gaia_urls->oauth_wrap_bridge_url()) { - consumer_->OnOAuthWrapBridgeFailure(service_scope_, - GoogleServiceAuthError( - GoogleServiceAuthError::SERVICE_UNAVAILABLE)); - } else if (continue_url == gaia_urls->oauth_user_info_url()) { - consumer_->OnUserInfoFailure(GoogleServiceAuthError( - GoogleServiceAuthError::SERVICE_UNAVAILABLE)); - } else if (StartsWithASCII(continue_url, - gaia_urls->oauth_revoke_token_url(), - true)) { - consumer_->OnOAuthRevokeTokenFailure(GoogleServiceAuthError( - GoogleServiceAuthError::SERVICE_UNAVAILABLE)); - } else { - NOTREACHED(); - } - } else { - NOTREACHED() << "GaiaOAuthFetcher unknown url=" << url.spec(); - } + NOTREACHED(); } } diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc index 44e33a446cb5..f2c03490de5a 100644 --- a/chrome/browser/sync/test/integration/sync_test.cc +++ b/chrome/browser/sync/test/integration/sync_test.cc @@ -61,10 +61,10 @@ const char kSyncServerCommandLine[] = "sync-server-command-line"; namespace { // The URLs for different calls in the Google Accounts programmatic login API. -const char kClientLoginUrl[] = "https://accounts.google.com/ClientLogin"; -const char kGetUserInfoUrl[] = "https://accounts.google.com/GetUserInfo"; +const char kClientLoginUrl[] = "https://www.google.com/accounts/ClientLogin"; +const char kGetUserInfoUrl[] = "https://www.google.com/accounts/GetUserInfo"; const char kIssueAuthTokenUrl[] = - "https://accounts.google.com/IssueAuthToken"; + "https://www.google.com/accounts/IssueAuthToken"; const char kSearchDomainCheckUrl[] = "https://www.google.com/searchdomaincheck?format=domain&type=chrome"; const char kOAuth2LoginTokenValidResponse[] = diff --git a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc index a9be8aa4802a..f84da82d16a9 100644 --- a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. @@ -9,7 +9,6 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/google/google_util.h" -#include "chrome/browser/net/browser_url_util.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/sync/profile_sync_service.h" @@ -82,6 +81,29 @@ SyncPromoUIHTMLSource::SyncPromoUIHTMLSource(content::WebUI* web_ui) AddLocalizedStrings(localized_strings); } +// Looks for |search_key| in the query portion of |url|. Returns true if the +// key is found and sets |out_value| to the value for the key. Returns false if +// the key is not found. +bool GetValueForKeyInQuery(const GURL& url, const std::string& search_key, + std::string* out_value) { + url_parse::Component query = url.parsed_for_possibly_invalid_spec().query; + url_parse::Component key, value; + while (url_parse::ExtractQueryKeyValue( + url.spec().c_str(), &query, &key, &value)) { + if (key.is_nonempty()) { + std::string key_string = url.spec().substr(key.begin, key.len); + if (key_string == search_key) { + if (value.is_nonempty()) + *out_value = url.spec().substr(value.begin, value.len); + else + *out_value = ""; + return true; + } + } + } + return false; +} + } // namespace SyncPromoUI::SyncPromoUI(content::WebUI* web_ui) : WebUIController(web_ui) { @@ -233,19 +255,20 @@ bool SyncPromoUI::GetIsLaunchPageForSyncPromoURL(const GURL& url) { std::string value; // Show the title if the promo is currently the Chrome launch page (and not // the page accessed through the NTP). - if (chrome_browser_net::GetValueForKeyInQuery(url, - kSyncPromoQueryKeyIsLaunchPage, &value)) { + if (GetValueForKeyInQuery(url, kSyncPromoQueryKeyIsLaunchPage, &value)) return value == "true"; - } return false; } // static GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) { std::string value; - if (chrome_browser_net::GetValueForKeyInQuery(url, - kSyncPromoQueryKeyNextPage, &value)) { - return GURL(value); + if (GetValueForKeyInQuery(url, kSyncPromoQueryKeyNextPage, &value)) { + url_canon::RawCanonOutputT output; + url_util::DecodeURLEscapeSequences(value.c_str(), value.length(), &output); + std::string url; + UTF16ToUTF8(output.data(), output.length(), &url); + return GURL(url); } return GURL(); } diff --git a/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc index b3a4b239e216..8a17a831c988 100644 --- a/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc +++ b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. // @@ -380,7 +380,7 @@ TEST_F(GaiaAuthFetcherTest, CaptchaParse) { GaiaAuthFetcher::GenerateAuthError(data, status); std::string token = "CCTOKEN"; - GURL image_url("http://accounts.google.com/Captcha?ctoken=CCTOKEN"); + GURL image_url("http://www.google.com/accounts/Captcha?ctoken=CCTOKEN"); GURL unlock_url("http://www.google.com/login/captcha"); EXPECT_EQ(error.state(), GoogleServiceAuthError::CAPTCHA_REQUIRED); diff --git a/chrome/common/net/gaia/gaia_urls.cc b/chrome/common/net/gaia/gaia_urls.cc index 260d74767741..49a33c02d5ef 100644 --- a/chrome/common/net/gaia/gaia_urls.cc +++ b/chrome/common/net/gaia/gaia_urls.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. @@ -9,25 +9,20 @@ namespace { -// Gaia service constants -const char kDefaultGaiaBaseUrl[] = "accounts.google.com"; +const char kDefaultGaiaBaseUrl[] = "www.google.com"; -const char kCaptchaUrlPrefixSuffix[] = "/"; -const char kClientLoginUrlSuffix[] = "/ClientLogin"; -const char kServiceLoginUrlSuffix[] = "/ServiceLogin"; -const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken"; -const char kGetUserInfoUrlSuffix[] = "/GetUserInfo"; -const char kTokenAuthUrlSuffix[] = "/TokenAuth"; -const char kMergeSessionUrlSuffix[] = "/MergeSession"; +const char kCaptchaUrlPrefixSuffix[] = "/accounts/"; +const char kClientLoginUrlSuffix[] = "/accounts/ClientLogin"; +const char kIssueAuthTokenUrlSuffix[] = "/accounts/IssueAuthToken"; +const char kGetUserInfoUrlSuffix[] = "/accounts/GetUserInfo"; +const char kTokenAuthUrlSuffix[] = "/accounts/TokenAuth"; +const char kMergeSessionUrlSuffix[] = "/accounts/MergeSession"; -const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken"; -const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge"; -const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin"; -const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken"; - -// Federated login constants -const char kDefaultFederatedLoginBaseUrl[] = "https://www.google.com/accounts"; -const char kGetOAuthTokenUrlSuffix[] = "/o8/GetOAuthToken"; +const char kGetOAuthTokenUrlSuffix[] = "/accounts/o8/GetOAuthToken"; +const char kOAuthGetAccessTokenUrlSuffix[] = "/accounts/OAuthGetAccessToken"; +const char kOAuthWrapBridgeUrlSuffix[] = "/accounts/OAuthWrapBridge"; +const char kOAuth1LoginUrlSuffix[] = "/accounts/OAuthLogin"; +const char kOAuthRevokeTokenUrlSuffix[] = "/accounts/AuthSubRevokeToken"; // OAuth2 client id for Google Chrome which is registered as an // installed application. @@ -43,7 +38,6 @@ const char kClientLoginToOAuth2Url[] = "https://accounts.google.com/o/oauth2/programmatic_auth"; const char kOAuth2TokenUrl[] = "https://accounts.google.com/o/oauth2/token"; - } // namespacce GaiaUrls* GaiaUrls::GetInstance() { @@ -62,16 +56,12 @@ GaiaUrls::GaiaUrls() { captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix; gaia_origin_url_ = "https://" + host_base; client_login_url_ = gaia_origin_url_ + kClientLoginUrlSuffix; - service_login_url_ = gaia_origin_url_ + kServiceLoginUrlSuffix; issue_auth_token_url_ = gaia_origin_url_ + kIssueAuthTokenUrlSuffix; get_user_info_url_ = gaia_origin_url_ + kGetUserInfoUrlSuffix; token_auth_url_ = gaia_origin_url_ + kTokenAuthUrlSuffix; merge_session_url_ = gaia_origin_url_ + kMergeSessionUrlSuffix; - // Federated login is not part of Gaia and has its own endpoints. - get_oauth_token_url_ = std::string(kDefaultFederatedLoginBaseUrl) + - kGetOAuthTokenUrlSuffix; - + get_oauth_token_url_ = gaia_origin_url_ + kGetOAuthTokenUrlSuffix; oauth_get_access_token_url_ = gaia_origin_url_ + kOAuthGetAccessTokenUrlSuffix; oauth_wrap_bridge_url_ = gaia_origin_url_ + kOAuthWrapBridgeUrlSuffix; @@ -107,10 +97,6 @@ const std::string& GaiaUrls::client_login_url() { return client_login_url_; } -const std::string& GaiaUrls::service_login_url() { - return service_login_url_; -} - const std::string& GaiaUrls::issue_auth_token_url() { return issue_auth_token_url_; } diff --git a/chrome/common/net/gaia/gaia_urls.h b/chrome/common/net/gaia/gaia_urls.h index f3991b22ae37..c8c1b46a37ba 100644 --- a/chrome/common/net/gaia/gaia_urls.h +++ b/chrome/common/net/gaia/gaia_urls.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. @@ -20,7 +20,6 @@ class GaiaUrls { const std::string& gaia_origin_url(); const std::string& client_login_url(); - const std::string& service_login_url(); const std::string& issue_auth_token_url(); const std::string& get_user_info_url(); const std::string& token_auth_url(); @@ -50,7 +49,6 @@ class GaiaUrls { std::string gaia_origin_url_; std::string client_login_url_; - std::string service_login_url_; std::string issue_auth_token_url_; std::string get_user_info_url_; std::string token_auth_url_; -- 2.11.4.GIT