| Index: chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
|
| 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 f269484ae7bcb2d5f77ce8aa6cf4086100c8af6b..9e26010981b9c1ecb0b8585ef2f67a4bf4515c95 100644
|
| --- a/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
|
| +++ b/chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc
|
| @@ -25,7 +25,6 @@
|
| #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"
|
| @@ -80,6 +79,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) {
|
| @@ -226,9 +248,12 @@ GURL SyncPromoUI::GetSyncPromoURL(const GURL& next_page, Source source) {
|
| // static
|
| GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) {
|
| std::string value;
|
| - if (chrome_common_net::GetValueForKeyInQuery(
|
| - url, kSyncPromoQueryKeyNextPage, &value)) {
|
| - return GURL(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);
|
| }
|
| return GURL();
|
| }
|
| @@ -236,8 +261,7 @@ GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) {
|
| // static
|
| SyncPromoUI::Source SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) {
|
| std::string value;
|
| - if (chrome_common_net::GetValueForKeyInQuery(
|
| - url, kSyncPromoQueryKeySource, &value)) {
|
| + if (GetValueForKeyInQuery(url, kSyncPromoQueryKeySource, &value)) {
|
| int source = 0;
|
| if (base::StringToInt(value, &source) && source >= SOURCE_START_PAGE &&
|
| source < SOURCE_UNKNOWN) {
|
|
|