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

Unified Diff: chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc

Issue 10413016: It seems GAIA had changed dosserver rules today, so we can go back to accounts.google.com. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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/browser/ui/webui/sync_promo/sync_promo_ui.cc
===================================================================
--- chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc (revision 137977)
+++ chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc (working copy)
@@ -25,6 +25,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "chrome/common/net/url_util.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "googleurl/src/url_util.h"
@@ -79,29 +80,6 @@
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) {
@@ -248,12 +226,9 @@
// static
GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) {
std::string value;
- if (GetValueForKeyInQuery(url, kSyncPromoQueryKeyNextPage, &value)) {
- url_canon::RawCanonOutputT<char16> output;
- url_util::DecodeURLEscapeSequences(value.c_str(), value.length(), &output);
- std::string url;
- UTF16ToUTF8(output.data(), output.length(), &url);
- return GURL(url);
+ if (chrome_common_net::GetValueForKeyInQuery(
+ url, kSyncPromoQueryKeyNextPage, &value)) {
+ return GURL(value);
}
return GURL();
}
@@ -261,7 +236,8 @@
// static
SyncPromoUI::Source SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) {
std::string value;
- if (GetValueForKeyInQuery(url, kSyncPromoQueryKeySource, &value)) {
+ if (chrome_common_net::GetValueForKeyInQuery(
+ url, kSyncPromoQueryKeySource, &value)) {
int source = 0;
if (base::StringToInt(value, &source) && source >= SOURCE_START_PAGE &&
source < SOURCE_UNKNOWN) {
Property changes on: chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
___________________________________________________________________
Added: svn:mergeinfo
« no previous file with comments | « chrome/browser/sync/resources/gaia_login_test.html ('k') | chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698