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

Unified Diff: chrome/browser/net/browser_url_util.cc

Issue 10384086: Moved url_utils from chrome/browser/net to chrome/common/net. (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
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/browser_url_util.cc
diff --git a/chrome/browser/net/browser_url_util.cc b/chrome/browser/net/browser_url_util.cc
deleted file mode 100644
index a21625b5ff88895aa9c4b5756458c9ec1df9aa38..0000000000000000000000000000000000000000
--- a/chrome/browser/net/browser_url_util.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (c) 2012 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.
-
-#include "chrome/browser/net/browser_url_util.h"
-
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/common/url_constants.h"
-#include "googleurl/src/gurl.h"
-#include "googleurl/src/url_parse.h"
-#include "net/base/escape.h"
-#include "net/base/net_util.h"
-#include "ui/base/clipboard/scoped_clipboard_writer.h"
-
-namespace chrome_browser_net {
-
-void WriteURLToClipboard(const GURL& url,
- const std::string& languages,
- ui::Clipboard *clipboard) {
- if (url.is_empty() || !url.is_valid() || !clipboard)
- return;
-
- // Unescaping path and query is not a good idea because other applications
- // may not encode non-ASCII characters in UTF-8. See crbug.com/2820.
- string16 text = url.SchemeIs(chrome::kMailToScheme) ?
- ASCIIToUTF16(url.path()) :
- net::FormatUrl(url, languages, net::kFormatUrlOmitNothing,
- net::UnescapeRule::NONE, NULL, NULL, NULL);
-
- ui::ScopedClipboardWriter scw(clipboard, ui::Clipboard::BUFFER_STANDARD);
- scw.WriteURL(text);
-}
-
-GURL AppendQueryParameter(const GURL& url,
- const std::string& name,
- const std::string& value) {
- std::string query(url.query());
-
- if (!query.empty())
- query += "&";
-
- query += (net::EscapeQueryParamValue(name, true) + "=" +
- net::EscapeQueryParamValue(value, true));
- GURL::Replacements replacements;
- replacements.SetQueryStr(query);
- return url.ReplaceComponents(replacements);
-}
-
-
-GURL AppendOrReplaceQueryParameter(const GURL& url,
- const std::string& name,
- const std::string& value) {
- bool replaced = false;
- std::string param_name = net::EscapeQueryParamValue(name, true);
- std::string param_value = net::EscapeQueryParamValue(value, true);
-
- const std::string input = url.query();
- url_parse::Component cursor(0, input.size());
- std::string output;
- url_parse::Component key_range, value_range;
- while (url_parse::ExtractQueryKeyValue(
- input.data(), &cursor, &key_range, &value_range)) {
- const base::StringPiece key(
- input.data() + key_range.begin, key_range.len);
- const base::StringPiece value(
- input.data() + value_range.begin, value_range.len);
- std::string key_value_pair;
- // Check |replaced| as only the first pair should be replaced.
- if (!replaced && key == param_name) {
- replaced = true;
- key_value_pair = (param_name + "=" + param_value);
- } else {
- key_value_pair.assign(input.data(),
- key_range.begin,
- value_range.end() - key_range.begin);
- }
- if (!output.empty())
- output += "&";
-
- output += key_value_pair;
- }
- if (!replaced) {
- if (!output.empty())
- output += "&";
-
- output += (param_name + "=" + param_value);
- }
- GURL::Replacements replacements;
- replacements.SetQueryStr(output);
- return url.ReplaceComponents(replacements);
-}
-
-} // namespace chrome_browser_net
« 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