summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 00:37:15 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 00:37:15 +0000
commitb7f4422f074031c809e60f873cbb51e553b3bbca (patch)
tree867e8282d2bcd641cdcc983f1d6441fefeba0535 /net/base
parent62cdc5679c1b752752e0289bb0e45cf254e0a67e (diff)
downloadchromium_src-b7f4422f074031c809e60f873cbb51e553b3bbca.zip
chromium_src-b7f4422f074031c809e60f873cbb51e553b3bbca.tar.gz
chromium_src-b7f4422f074031c809e60f873cbb51e553b3bbca.tar.bz2
Refactor the ICU dependency in escape.cc into escape_icu.cc.
Review URL: http://codereview.chromium.org/6693082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/escape.cc18
-rw-r--r--net/base/escape_icu.cc25
2 files changed, 27 insertions, 16 deletions
diff --git a/net/base/escape.cc b/net/base/escape.cc
index ae8411b..64bd107 100644
--- a/net/base/escape.cc
+++ b/net/base/escape.cc
@@ -6,7 +6,6 @@
#include "net/base/escape.h"
-#include "base/i18n/icu_string_conversions.h"
#include "base/logging.h"
#include "base/string_piece.h"
#include "base/string_util.h"
@@ -45,8 +44,8 @@ class Charmap {
// return an escaped string. If use_plus is true, spaces are converted
// to +, otherwise, if spaces are in the charmap, they are converted to
// %20.
-const std::string Escape(const std::string& text, const Charmap& charmap,
- bool use_plus) {
+std::string Escape(const std::string& text, const Charmap& charmap,
+ bool use_plus) {
std::string escaped;
escaped.reserve(text.length() * 3);
for (unsigned int i = 0; i < text.length(); ++i) {
@@ -235,19 +234,6 @@ std::string EscapeExternalHandlerValue(const std::string& text) {
return Escape(text, kExternalHandlerCharmap, false);
}
-bool EscapeQueryParamValue(const string16& text, const char* codepage,
- bool use_plus, string16* escaped) {
- // TODO(brettw) bug 1201094: this function should be removed, this "SKIP"
- // behavior is wrong when the character can't be encoded properly.
- std::string encoded;
- if (!base::UTF16ToCodepage(text, codepage,
- base::OnStringConversionError::SKIP, &encoded))
- return false;
-
- escaped->assign(UTF8ToUTF16(Escape(encoded, kQueryCharmap, use_plus)));
- return true;
-}
-
string16 UnescapeAndDecodeUTF8URLComponent(const std::string& text,
UnescapeRule::Type rules,
size_t* offset_for_adjustment) {
diff --git a/net/base/escape_icu.cc b/net/base/escape_icu.cc
new file mode 100644
index 0000000..bae93074
--- /dev/null
+++ b/net/base/escape_icu.cc
@@ -0,0 +1,25 @@
+// Copyright (c) 2011 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 <algorithm>
+
+#include "net/base/escape.h"
+
+#include "base/i18n/icu_string_conversions.h"
+#include "base/utf_string_conversions.h"
+
+// This file exists to avoid having escape.cc depend on ICU.
+
+bool EscapeQueryParamValue(const string16& text, const char* codepage,
+ bool use_plus, string16* escaped) {
+ // TODO(brettw) bug 1201094: this function should be removed, this "SKIP"
+ // behavior is wrong when the character can't be encoded properly.
+ std::string encoded;
+ if (!base::UTF16ToCodepage(text, codepage,
+ base::OnStringConversionError::SKIP, &encoded))
+ return false;
+
+ escaped->assign(UTF8ToUTF16(EscapeQueryParamValue(encoded, use_plus)));
+ return true;
+}