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

Side by Side Diff: chrome/browser/net/browser_url_util.cc

Issue 9271025: Update Gaia URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits, fix unit_tests failure and update license headers Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/browser_url_util.h ('k') | chrome/browser/net/browser_url_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/net/browser_url_util.h" 5 #include "chrome/browser/net/browser_url_util.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 #include "googleurl/src/url_util.h"
11 #include "net/base/escape.h" 12 #include "net/base/escape.h"
12 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
13 #include "ui/base/clipboard/scoped_clipboard_writer.h" 14 #include "ui/base/clipboard/scoped_clipboard_writer.h"
14 15
15 namespace chrome_browser_net { 16 namespace chrome_browser_net {
16 17
17 void WriteURLToClipboard(const GURL& url, 18 void WriteURLToClipboard(const GURL& url,
18 const std::string& languages, 19 const std::string& languages,
19 ui::Clipboard *clipboard) { 20 ui::Clipboard *clipboard) {
20 if (url.is_empty() || !url.is_valid() || !clipboard) 21 if (url.is_empty() || !url.is_valid() || !clipboard)
(...skipping 16 matching lines...) Expand all
37 std::string query(url.query()); 38 std::string query(url.query());
38 if (!query.empty()) 39 if (!query.empty())
39 query += "&"; 40 query += "&";
40 query += (net::EscapeQueryParamValue(name, true) + "=" + 41 query += (net::EscapeQueryParamValue(name, true) + "=" +
41 net::EscapeQueryParamValue(value, true)); 42 net::EscapeQueryParamValue(value, true));
42 GURL::Replacements replacements; 43 GURL::Replacements replacements;
43 replacements.SetQueryStr(query); 44 replacements.SetQueryStr(query);
44 return url.ReplaceComponents(replacements); 45 return url.ReplaceComponents(replacements);
45 } 46 }
46 47
48 bool GetValueForKeyInQuery(const GURL& url,
49 const std::string& search_key,
50 std::string* out_value) {
51 url_parse::Component query = url.parsed_for_possibly_invalid_spec().query;
52 url_parse::Component key, value;
53 while (url_parse::ExtractQueryKeyValue(
54 url.spec().c_str(), &query, &key, &value)) {
55 if (key.is_nonempty()) {
56 std::string key_string = url.spec().substr(key.begin, key.len);
57 if (key_string == search_key) {
58 if (value.is_nonempty()) {
59 *out_value = net::UnescapeURLComponent(
60 url.spec().substr(value.begin, value.len),
61 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS);
62 } else {
63 *out_value = "";
64 }
65 return true;
66 }
67 }
68 }
69 return false;
70 }
71
47 } // namespace chrome_browser_net 72 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/browser_url_util.h ('k') | chrome/browser/net/browser_url_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698