Index: chrome/common/net/url_util.cc |
diff --git a/chrome/common/net/url_util.cc b/chrome/common/net/url_util.cc |
index c72c2087abf9ae2f1e65821e146f2fe920ce8da1..4c8f001f2351f7ba78f4db275a89b3b28b5f2625 100644 |
--- a/chrome/common/net/url_util.cc |
+++ b/chrome/common/net/url_util.cc |
@@ -47,7 +47,6 @@ GURL AppendQueryParameter(const GURL& url, |
return url.ReplaceComponents(replacements); |
} |
- |
GURL AppendOrReplaceQueryParameter(const GURL& url, |
const std::string& name, |
const std::string& value) { |
@@ -91,4 +90,28 @@ GURL AppendOrReplaceQueryParameter(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); |
willchan no longer on Chromium
2012/05/10 16:10:21
I don't know the actual form of the URL you are ap
xiyuan
2012/05/10 16:54:02
This CL uses this function to decode Gaia redirect
zel
2012/05/10 18:53:56
Done.
|
+ } else { |
+ *out_value = ""; |
+ } |
+ return true; |
+ } |
+ } |
+ } |
+ return false; |
+} |
+ |
} // namespace chrome_common_net |