summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autofill/wallet/wallet_service_url.cc13
-rw-r--r--chrome/browser/chromeos/cros/network_library.cc14
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.cc1
-rw-r--r--chrome/browser/google/google_util.cc8
-rw-r--r--chrome/browser/google_apis/DEPS1
-rw-r--r--chrome/browser/google_apis/drive_api_service.cc1
-rw-r--r--chrome/browser/google_apis/drive_api_url_generator.cc7
-rw-r--r--chrome/browser/google_apis/gdata_contacts_operations.cc9
-rw-r--r--chrome/browser/google_apis/gdata_wapi_operations.cc4
-rw-r--r--chrome/browser/google_apis/gdata_wapi_service.cc2
-rw-r--r--chrome/browser/google_apis/gdata_wapi_url_generator.cc29
-rw-r--r--chrome/browser/intents/cws_intents_registry.cc17
-rw-r--r--chrome/browser/net/gaia/gaia_oauth_fetcher.cc1
-rw-r--r--chrome/browser/ui/chrome_pages.cc8
-rw-r--r--chrome/browser/ui/sync/one_click_signin_helper.cc4
-rw-r--r--chrome/browser/ui/webui/sync_promo/sync_promo_ui.cc10
-rw-r--r--chrome/browser/web_resource/notification_promo.cc4
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--chrome/common/extensions/extension_constants.cc6
-rw-r--r--chrome/common/net/url_util.cc86
-rw-r--r--chrome/common/net/url_util.h38
-rw-r--r--net/base/url_util.cc97
-rw-r--r--net/base/url_util.h56
-rw-r--r--net/base/url_util_unittest.cc (renamed from chrome/common/net/url_util_unittest.cc)12
-rw-r--r--net/net.gyp3
25 files changed, 221 insertions, 211 deletions
diff --git a/chrome/browser/autofill/wallet/wallet_service_url.cc b/chrome/browser/autofill/wallet/wallet_service_url.cc
index 890cca0..1dd1afb 100644
--- a/chrome/browser/autofill/wallet/wallet_service_url.cc
+++ b/chrome/browser/autofill/wallet/wallet_service_url.cc
@@ -8,9 +8,9 @@
#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/net/url_util.h"
#include "google_apis/gaia/gaia_urls.h"
#include "googleurl/src/gurl.h"
+#include "net/base/url_util.h"
namespace {
@@ -82,12 +82,11 @@ GURL GetEscrowUrl() {
GURL GetSignInUrl() {
GURL url(GaiaUrls::GetInstance()->service_login_url());
- url = chrome_common_net::AppendQueryParameter(url, "service", "sierra");
- url = chrome_common_net::AppendQueryParameter(url, "btmpl", "popup");
- url = chrome_common_net::AppendQueryParameter(
- url,
- "continue",
- GetSignInContinueUrl().spec());
+ url = net::AppendQueryParameter(url, "service", "sierra");
+ url = net::AppendQueryParameter(url, "btmpl", "popup");
+ url = net::AppendQueryParameter(url,
+ "continue",
+ GetSignInContinueUrl().spec());
return url;
}
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc
index d34a743..50048d8 100644
--- a/chrome/browser/chromeos/cros/network_library.cc
+++ b/chrome/browser/chromeos/cros/network_library.cc
@@ -17,11 +17,11 @@
#include "chrome/browser/chromeos/cros/native_network_parser.h"
#include "chrome/browser/chromeos/cros/network_library_impl_cros.h"
#include "chrome/browser/chromeos/cros/network_library_impl_stub.h"
-#include "chrome/common/net/url_util.h"
#include "chrome/common/net/x509_certificate_model.h"
#include "chromeos/network/cros_network_functions.h"
#include "content/public/browser/browser_thread.h"
#include "grit/generated_resources.h"
+#include "net/base/url_util.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/l10n/l10n_util.h"
@@ -907,12 +907,12 @@ GURL CellularNetwork::GetAccountInfoUrl() const {
return GURL(payment_url());
GURL base_url(kRedirectExtensionPage);
- GURL temp_url = chrome_common_net::AppendQueryParameter(base_url,
- "post_data",
- post_data_);
- GURL redir_url = chrome_common_net::AppendQueryParameter(temp_url,
- "formUrl",
- payment_url());
+ GURL temp_url = net::AppendQueryParameter(base_url,
+ "post_data",
+ post_data_);
+ GURL redir_url = net::AppendQueryParameter(temp_url,
+ "formUrl",
+ payment_url());
return redir_url;
}
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 0cf370e..85ac35b 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -40,7 +40,6 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
-#include "chrome/common/net/url_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chromeos/dbus/dbus_thread_manager.h"
diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc
index f48856b..7146303 100644
--- a/chrome/browser/google/google_util.cc
+++ b/chrome/browser/google/google_util.cc
@@ -16,10 +16,10 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_url_tracker.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/net/url_util.h"
#include "chrome/installer/util/google_update_settings.h"
#include "googleurl/src/gurl.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
+#include "net/base/url_util.h"
#if defined(OS_MACOSX)
#include "chrome/browser/mac/keystone_glue.h"
@@ -86,7 +86,7 @@ GURL AppendGoogleLocaleParam(const GURL& url) {
std::string locale = g_browser_process->GetApplicationLocale();
if (locale == "nb")
locale = "no";
- return chrome_common_net::AppendQueryParameter(url, "hl", locale);
+ return net::AppendQueryParameter(url, "hl", locale);
}
std::string StringAppendGoogleLocaleParam(const std::string& url) {
@@ -105,8 +105,8 @@ GURL AppendGoogleTLDParam(Profile* profile, const GURL& url) {
NOTREACHED();
return url;
}
- return chrome_common_net::AppendQueryParameter(
- url, "sd", google_domain.substr(first_dot + 1));
+ return net::AppendQueryParameter(url, "sd",
+ google_domain.substr(first_dot + 1));
}
#if defined(OS_WIN)
diff --git a/chrome/browser/google_apis/DEPS b/chrome/browser/google_apis/DEPS
index 62843b1..840807d 100644
--- a/chrome/browser/google_apis/DEPS
+++ b/chrome/browser/google_apis/DEPS
@@ -9,7 +9,6 @@ include_rules = [
"!chrome/browser/signin/token_service_factory.h",
"!chrome/browser/signin/token_service.h",
"!chrome/common/chrome_notification_types.h",
- "!chrome/common/net/url_util.h",
"!content/public/browser/browser_thread.h",
"!content/public/browser/notification_details.h",
"!content/public/browser/notification_observer.h",
diff --git a/chrome/browser/google_apis/drive_api_service.cc b/chrome/browser/google_apis/drive_api_service.cc
index 494f8f9..23d3415 100644
--- a/chrome/browser/google_apis/drive_api_service.cc
+++ b/chrome/browser/google_apis/drive_api_service.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/google_apis/operation_runner.h"
#include "chrome/browser/google_apis/time_util.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/net/url_util.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
diff --git a/chrome/browser/google_apis/drive_api_url_generator.cc b/chrome/browser/google_apis/drive_api_url_generator.cc
index 1c2c9f0..59494eb 100644
--- a/chrome/browser/google_apis/drive_api_url_generator.cc
+++ b/chrome/browser/google_apis/drive_api_url_generator.cc
@@ -6,7 +6,7 @@
#include "base/string_number_conversions.h"
#include "base/stringprintf.h"
-#include "chrome/common/net/url_util.h"
+#include "net/base/url_util.h"
namespace google_apis {
@@ -49,7 +49,7 @@ GURL DriveApiUrlGenerator::GetChangelistUrl(
base_url_.Resolve(kDriveV2ChangelistUrl) :
override_url;
return start_changestamp ?
- chrome_common_net::AppendOrReplaceQueryParameter(
+ net::AppendOrReplaceQueryParameter(
url, "startChangeId", base::Int64ToString(start_changestamp)) :
url;
}
@@ -63,8 +63,7 @@ GURL DriveApiUrlGenerator::GetFilelistUrl(
override_url;
return search_string.empty() ?
url :
- chrome_common_net::AppendOrReplaceQueryParameter(
- url, "q", search_string);
+ net::AppendOrReplaceQueryParameter(url, "q", search_string);
}
GURL DriveApiUrlGenerator::GetFileUrl(const std::string& file_id) const {
diff --git a/chrome/browser/google_apis/gdata_contacts_operations.cc b/chrome/browser/google_apis/gdata_contacts_operations.cc
index 517c4ad..42dc694 100644
--- a/chrome/browser/google_apis/gdata_contacts_operations.cc
+++ b/chrome/browser/google_apis/gdata_contacts_operations.cc
@@ -5,8 +5,8 @@
#include "chrome/browser/google_apis/gdata_contacts_operations.h"
#include "chrome/browser/google_apis/time_util.h"
-#include "chrome/common/net/url_util.h"
#include "googleurl/src/gurl.h"
+#include "net/base/url_util.h"
namespace google_apis {
@@ -73,13 +73,12 @@ GURL GetContactsOperation::GetURL() const {
GURL url(kGetContactsURL);
if (!group_id_.empty()) {
- url = chrome_common_net::AppendQueryParameter(
- url, kGetContactsGroupParam, group_id_);
+ url = net::AppendQueryParameter(url, kGetContactsGroupParam, group_id_);
}
if (!min_update_time_.is_null()) {
std::string time_rfc3339 = util::FormatTimeAsString(min_update_time_);
- url = chrome_common_net::AppendQueryParameter(
- url, kGetContactsUpdatedMinParam, time_rfc3339);
+ url = net::AppendQueryParameter(
+ url, kGetContactsUpdatedMinParam, time_rfc3339);
}
return url;
}
diff --git a/chrome/browser/google_apis/gdata_wapi_operations.cc b/chrome/browser/google_apis/gdata_wapi_operations.cc
index e2a6bdc..faec2b9 100644
--- a/chrome/browser/google_apis/gdata_wapi_operations.cc
+++ b/chrome/browser/google_apis/gdata_wapi_operations.cc
@@ -10,9 +10,9 @@
#include "chrome/browser/google_apis/gdata_wapi_parser.h"
#include "chrome/browser/google_apis/gdata_wapi_url_generator.h"
#include "chrome/browser/google_apis/time_util.h"
-#include "chrome/common/net/url_util.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/escape.h"
+#include "net/base/url_util.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "third_party/libxml/chromium/libxml_utils.h"
@@ -566,7 +566,7 @@ InitiateUploadOperation::InitiateUploadOperation(
params.drive_file_path),
callback_(callback),
params_(params),
- initiate_upload_url_(chrome_common_net::AppendOrReplaceQueryParameter(
+ initiate_upload_url_(net::AppendOrReplaceQueryParameter(
params.upload_location,
kUploadParamConvertKey,
kUploadParamConvertValue)) {
diff --git a/chrome/browser/google_apis/gdata_wapi_service.cc b/chrome/browser/google_apis/gdata_wapi_service.cc
index 336aca8..5a72f47 100644
--- a/chrome/browser/google_apis/gdata_wapi_service.cc
+++ b/chrome/browser/google_apis/gdata_wapi_service.cc
@@ -18,8 +18,8 @@
#include "chrome/browser/google_apis/gdata_wapi_url_generator.h"
#include "chrome/browser/google_apis/operation_runner.h"
#include "chrome/browser/google_apis/time_util.h"
-#include "chrome/common/net/url_util.h"
#include "content/public/browser/browser_thread.h"
+#include "net/base/url_util.h"
using content::BrowserThread;
diff --git a/chrome/browser/google_apis/gdata_wapi_url_generator.cc b/chrome/browser/google_apis/gdata_wapi_url_generator.cc
index 8375b0c..486bb02 100644
--- a/chrome/browser/google_apis/gdata_wapi_url_generator.cc
+++ b/chrome/browser/google_apis/gdata_wapi_url_generator.cc
@@ -6,9 +6,9 @@
#include "base/logging.h"
#include "base/stringprintf.h"
-#include "chrome/common/net/url_util.h"
#include "googleurl/src/gurl.h"
#include "net/base/escape.h"
+#include "net/base/url_util.h"
namespace google_apis {
namespace {
@@ -66,17 +66,15 @@ const char GDataWapiUrlGenerator::kBaseUrlForProduction[] =
// static
GURL GDataWapiUrlGenerator::AddStandardUrlParams(const GURL& url) {
- GURL result =
- chrome_common_net::AppendOrReplaceQueryParameter(url, "v", "3");
- result =
- chrome_common_net::AppendOrReplaceQueryParameter(result, "alt", "json");
+ GURL result = net::AppendOrReplaceQueryParameter(url, "v", "3");
+ result = net::AppendOrReplaceQueryParameter(result, "alt", "json");
return result;
}
// static
GURL GDataWapiUrlGenerator::AddMetadataUrlParams(const GURL& url) {
GURL result = AddStandardUrlParams(url);
- result = chrome_common_net::AppendOrReplaceQueryParameter(
+ result = net::AppendOrReplaceQueryParameter(
result, "include-installed-apps", "true");
return result;
}
@@ -88,27 +86,22 @@ GURL GDataWapiUrlGenerator::AddFeedUrlParams(
int changestamp,
const std::string& search_string) {
GURL result = AddStandardUrlParams(url);
- result = chrome_common_net::AppendOrReplaceQueryParameter(
- result,
- "showfolders",
- "true");
- result = chrome_common_net::AppendOrReplaceQueryParameter(
+ result = net::AppendOrReplaceQueryParameter(result, "showfolders", "true");
+ result = net::AppendOrReplaceQueryParameter(
result,
"max-results",
base::StringPrintf("%d", num_items_to_fetch));
- result = chrome_common_net::AppendOrReplaceQueryParameter(
+ result = net::AppendOrReplaceQueryParameter(
result, "include-installed-apps", "true");
if (changestamp) {
- result = chrome_common_net::AppendQueryParameter(
- result,
- "start-index",
- base::StringPrintf("%d", changestamp));
+ result = net::AppendQueryParameter(result,
+ "start-index",
+ base::StringPrintf("%d", changestamp));
}
if (!search_string.empty()) {
- result = chrome_common_net::AppendOrReplaceQueryParameter(
- result, "q", search_string);
+ result = net::AppendOrReplaceQueryParameter(result, "q", search_string);
}
return result;
}
diff --git a/chrome/browser/intents/cws_intents_registry.cc b/chrome/browser/intents/cws_intents_registry.cc
index ee238b6..4211499 100644
--- a/chrome/browser/intents/cws_intents_registry.cc
+++ b/chrome/browser/intents/cws_intents_registry.cc
@@ -14,10 +14,10 @@
#include "chrome/common/extensions/message_bundle.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/common/net/url_util.h"
#include "google_apis/google_api_keys.h"
#include "net/base/load_flags.h"
#include "net/base/mime_util.h"
+#include "net/base/url_util.h"
#include "net/url_request/url_fetcher.h"
namespace {
@@ -225,16 +225,11 @@ void CWSIntentsRegistry::GetIntentServices(const string16& action,
GURL CWSIntentsRegistry::BuildQueryURL(const string16& action,
const string16& type) {
GURL request(kCWSIntentServiceURL);
- request = chrome_common_net::AppendQueryParameter(request, "intent",
- UTF16ToUTF8(action));
- request = chrome_common_net::AppendQueryParameter(request, "mime_types",
- UTF16ToUTF8(type));
- request = chrome_common_net::AppendQueryParameter(request, "start_index",
- "0");
- request = chrome_common_net::AppendQueryParameter(request, "num_results",
- kMaxSuggestions);
- request = chrome_common_net::AppendQueryParameter(request, "key",
- google_apis::GetAPIKey());
+ request = net::AppendQueryParameter(request, "intent", UTF16ToUTF8(action));
+ request = net::AppendQueryParameter(request, "mime_types", UTF16ToUTF8(type));
+ request = net::AppendQueryParameter(request, "start_index", "0");
+ request = net::AppendQueryParameter(request, "num_results", kMaxSuggestions);
+ request = net::AppendQueryParameter(request, "key", google_apis::GetAPIKey());
return request;
}
diff --git a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc
index b25a291..cf67ff8 100644
--- a/chrome/browser/net/gaia/gaia_oauth_fetcher.cc
+++ b/chrome/browser/net/gaia/gaia_oauth_fetcher.cc
@@ -13,7 +13,6 @@
#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
-#include "chrome/common/net/url_util.h"
#include "google_apis/gaia/gaia_auth_fetcher.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
diff --git a/chrome/browser/ui/chrome_pages.cc b/chrome/browser/ui/chrome_pages.cc
index 1041ad2..0864296 100644
--- a/chrome/browser/ui/chrome_pages.cc
+++ b/chrome/browser/ui/chrome_pages.cc
@@ -21,11 +21,11 @@
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
#include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
-#include "chrome/common/net/url_util.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/user_metrics.h"
#include "google_apis/gaia/gaia_urls.h"
#include "googleurl/src/gurl.h"
+#include "net/base/url_util.h"
using content::UserMetricsAction;
@@ -226,11 +226,9 @@ void ShowGaiaSignin(Browser* browser,
const std::string& service,
const GURL& continue_url) {
GURL url(GaiaUrls::GetInstance()->service_login_url());
- url = chrome_common_net::AppendQueryParameter(url, "service", service);
+ url = net::AppendQueryParameter(url, "service", service);
if (continue_url.is_valid())
- url = chrome_common_net::AppendQueryParameter(url,
- "continue",
- continue_url.spec());
+ url = net::AppendQueryParameter(url, "continue", continue_url.spec());
NavigateToSingletonTab(browser, url);
}
diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc
index 0f3d7ae..5750e341 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc
@@ -43,7 +43,6 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
-#include "chrome/common/net/url_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
@@ -59,6 +58,7 @@
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
+#include "net/base/url_util.h"
#include "net/cookies/cookie_monster.h"
#include "net/url_request/url_request.h"
#include "ui/base/l10n/l10n_util.h"
@@ -136,7 +136,7 @@ void ClearPendingEmailOnIOThread(content::ResourceContext* context) {
// "service" is also checked to make sure its "chromiumsync".
SyncPromoUI::Source GetSigninSource(const GURL& url, GURL* continue_url) {
std::string value;
- chrome_common_net::GetValueForKeyInQuery(url, "service", &value);
+ net::GetValueForKeyInQuery(url, "service", &value);
bool possibly_an_explicit_signin = value == "chromiumsync";
// Find the final continue URL for this sign in. In some cases, Gaia can
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 6e00ca1..cb140ef 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/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
@@ -36,6 +35,7 @@
#include "grit/theme_resources.h"
#include "net/base/escape.h"
#include "net/base/network_change_notifier.h"
+#include "net/base/url_util.h"
#include "ui/base/l10n/l10n_util.h"
using content::WebContents;
@@ -267,7 +267,7 @@ GURL SyncPromoUI::GetNextPageURLForSyncPromoURL(const GURL& url) {
const char* key_name = UseWebBasedSigninFlow() ? kSyncPromoQueryKeyContinue :
kSyncPromoQueryKeyNextPage;
std::string value;
- if (chrome_common_net::GetValueForKeyInQuery(url, key_name, &value)) {
+ if (net::GetValueForKeyInQuery(url, key_name, &value)) {
return GURL(value);
}
return GURL();
@@ -276,8 +276,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 (net::GetValueForKeyInQuery(url, kSyncPromoQueryKeySource, &value)) {
int source = 0;
if (base::StringToInt(value, &source) && source >= SOURCE_START_PAGE &&
source < SOURCE_UNKNOWN) {
@@ -290,8 +289,7 @@ SyncPromoUI::Source SyncPromoUI::GetSourceForSyncPromoURL(const GURL& url) {
// static
bool SyncPromoUI::GetAutoCloseForSyncPromoURL(const GURL& url) {
std::string value;
- if (chrome_common_net::GetValueForKeyInQuery(
- url, kSyncPromoQueryKeyAutoClose, &value)) {
+ if (net::GetValueForKeyInQuery(url, kSyncPromoQueryKeyAutoClose, &value)) {
int source = 0;
base::StringToInt(value, &source);
return (source == 1);
diff --git a/chrome/browser/web_resource/notification_promo.cc b/chrome/browser/web_resource/notification_promo.cc
index 749d5fa..1c13333 100644
--- a/chrome/browser/web_resource/notification_promo.cc
+++ b/chrome/browser/web_resource/notification_promo.cc
@@ -21,10 +21,10 @@
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/web_resource/promo_resource_service.h"
#include "chrome/common/chrome_version_info.h"
-#include "chrome/common/net/url_util.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/user_metrics.h"
#include "googleurl/src/gurl.h"
+#include "net/base/url_util.h"
#if defined(OS_ANDROID)
#include "base/command_line.h"
@@ -184,7 +184,7 @@ base::Value* DeepCopyAndResolveStrings(
void AppendQueryParameter(GURL* url,
const std::string& param,
const std::string& value) {
- *url = chrome_common_net::AppendQueryParameter(*url, param, value);
+ *url = net::AppendQueryParameter(*url, param, value);
}
} // namespace
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index e6d4892..04bdb45 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1546,7 +1546,6 @@
'common/metrics/metrics_util_unittest.cc',
'common/metrics/variations/variations_util_unittest.cc',
'common/multi_process_lock_unittest.cc',
- 'common/net/url_util_unittest.cc',
'common/net/x509_certificate_model_unittest.cc',
'common/pref_names_util_unittest.cc',
'common/service_process_util_unittest.cc',
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index 7ef5d27..948966b 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -10,7 +10,7 @@
#include "base/command_line.h"
#include "base/string_util.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/net/url_util.h"
+#include "net/base/url_util.h"
namespace extension_urls {
@@ -38,8 +38,8 @@ GURL GetWebstoreIntentQueryURL(const std::string& action,
GURL url(std::string(kGalleryBrowsePrefix) + "/");
url = url.Resolve(kIntentsCategoryPath);
- url = chrome_common_net::AppendQueryParameter(url, "_wi", action);
- url = chrome_common_net::AppendQueryParameter(url, "_mt", type);
+ url = net::AppendQueryParameter(url, "_wi", action);
+ url = net::AppendQueryParameter(url, "_mt", type);
return url;
}
diff --git a/chrome/common/net/url_util.cc b/chrome/common/net/url_util.cc
index 9d58317..2062d14 100644
--- a/chrome/common/net/url_util.cc
+++ b/chrome/common/net/url_util.cc
@@ -4,11 +4,9 @@
#include "chrome/common/net/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"
@@ -32,88 +30,4 @@ void WriteURLToClipboard(const GURL& url,
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);
-}
-
-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 |
- net::UnescapeRule::REPLACE_PLUS_WITH_SPACE);
- } else {
- *out_value = "";
- }
- return true;
- }
- }
- }
- return false;
-}
-
} // namespace chrome_common_net
diff --git a/chrome/common/net/url_util.h b/chrome/common/net/url_util.h
index f6bf296..053b09b 100644
--- a/chrome/common/net/url_util.h
+++ b/chrome/common/net/url_util.h
@@ -20,44 +20,6 @@ void WriteURLToClipboard(const GURL& url,
const std::string& languages,
ui::Clipboard *clipboard);
-// Returns a new GURL by appending the given query parameter name and the
-// value. Unsafe characters in the name and the value are escaped like
-// %XX%XX. The original query component is preserved if it's present.
-//
-// Examples:
-//
-// AppendQueryParameter(GURL("http://example.com"), "name", "value").spec()
-// => "http://example.com?name=value"
-// AppendQueryParameter(GURL("http://example.com?x=y"), "name", "value").spec()
-// => "http://example.com?x=y&name=value"
-GURL AppendQueryParameter(const GURL& url,
- const std::string& name,
- const std::string& value);
-
-// Returns a new GURL by appending or replacing the given query parameter name
-// and the value. If |name| appears more than once, only the first name-value
-// pair is replaced. Unsafe characters in the name and the value are escaped
-// like %XX%XX. The original query component is preserved if it's present.
-//
-// Examples:
-//
-// AppendOrReplaceQueryParameter(
-// GURL("http://example.com"), "name", "new").spec()
-// => "http://example.com?name=value"
-// AppendOrReplaceQueryParameter(
-// GURL("http://example.com?x=y&name=old"), "name", "new").spec()
-// => "http://example.com?x=y&name=new"
-GURL AppendOrReplaceQueryParameter(const GURL& url,
- const std::string& name,
- const std::string& value);
-
-// Looks for |search_key| in the query portion of |url|. Returns true if the
-// key is found and sets |out_value| to the unescaped 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);
-
} // namespace chrome_common_net
#endif // CHROME_COMMON_NET_URL_UTIL_H_
diff --git a/net/base/url_util.cc b/net/base/url_util.cc
new file mode 100644
index 0000000..99dbbbe
--- /dev/null
+++ b/net/base/url_util.cc
@@ -0,0 +1,97 @@
+// Copyright 2013 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 "net/base/url_util.h"
+
+#include "base/string_piece.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/escape.h"
+
+namespace net {
+
+GURL AppendQueryParameter(const GURL& url,
+ const std::string& name,
+ const std::string& value) {
+ std::string query(url.query());
+
+ if (!query.empty())
+ query += "&";
+
+ query += (EscapeQueryParamValue(name, true) + "=" +
+ 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 = EscapeQueryParamValue(name, true);
+ std::string param_value = 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);
+}
+
+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 = UnescapeURLComponent(
+ url.spec().substr(value.begin, value.len),
+ UnescapeRule::SPACES |
+ UnescapeRule::URL_SPECIAL_CHARS |
+ UnescapeRule::REPLACE_PLUS_WITH_SPACE);
+ } else {
+ *out_value = "";
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+} // namespace net
diff --git a/net/base/url_util.h b/net/base/url_util.h
new file mode 100644
index 0000000..5d5e58b
--- /dev/null
+++ b/net/base/url_util.h
@@ -0,0 +1,56 @@
+// Copyright 2013 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.
+
+#ifndef NET_BASE_URL_UTIL_H_
+#define NET_BASE_URL_UTIL_H_
+
+#include <string>
+
+#include "net/base/net_export.h"
+
+class GURL;
+
+namespace net {
+
+// Returns a new GURL by appending the given query parameter name and the
+// value. Unsafe characters in the name and the value are escaped like
+// %XX%XX. The original query component is preserved if it's present.
+//
+// Examples:
+//
+// AppendQueryParameter(GURL("http://example.com"), "name", "value").spec()
+// => "http://example.com?name=value"
+// AppendQueryParameter(GURL("http://example.com?x=y"), "name", "value").spec()
+// => "http://example.com?x=y&name=value"
+NET_EXPORT GURL AppendQueryParameter(const GURL& url,
+ const std::string& name,
+ const std::string& value);
+
+// Returns a new GURL by appending or replacing the given query parameter name
+// and the value. If |name| appears more than once, only the first name-value
+// pair is replaced. Unsafe characters in the name and the value are escaped
+// like %XX%XX. The original query component is preserved if it's present.
+//
+// Examples:
+//
+// AppendOrReplaceQueryParameter(
+// GURL("http://example.com"), "name", "new").spec()
+// => "http://example.com?name=value"
+// AppendOrReplaceQueryParameter(
+// GURL("http://example.com?x=y&name=old"), "name", "new").spec()
+// => "http://example.com?x=y&name=new"
+NET_EXPORT GURL AppendOrReplaceQueryParameter(const GURL& url,
+ const std::string& name,
+ const std::string& value);
+
+// Looks for |search_key| in the query portion of |url|. Returns true if the
+// key is found and sets |out_value| to the unescaped value for the key.
+// Returns false if the key is not found.
+NET_EXPORT bool GetValueForKeyInQuery(const GURL& url,
+ const std::string& search_key,
+ std::string* out_value);
+
+} // namespace net
+
+#endif // NET_BASE_URL_UTIL_H_
diff --git a/chrome/common/net/url_util_unittest.cc b/net/base/url_util_unittest.cc
index 1d7fdda..8d1efde 100644
--- a/chrome/common/net/url_util_unittest.cc
+++ b/net/base/url_util_unittest.cc
@@ -1,13 +1,14 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 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/common/net/url_util.h"
+#include "net/base/url_util.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace chrome_common_net {
+namespace net {
+namespace {
TEST(UrlUtilTest, AppendQueryParameter) {
// Appending a name-value pair to a URL without a query component.
@@ -80,7 +81,7 @@ TEST(UrlUtilTest, AppendOrReplaceQueryParameter) {
"name", "new").spec());
}
-TEST(BrowserUrlUtilTest, GetValueForKeyInQuery) {
+TEST(UrlUtilTest, GetValueForKeyInQuery) {
GURL url("http://example.com/path?name=value&boolParam&"
"url=http://test.com/q?n1%3Dv1%26n2");
std::string value;
@@ -99,4 +100,5 @@ TEST(BrowserUrlUtilTest, GetValueForKeyInQuery) {
EXPECT_EQ("http://test.com/q?n1=v1&n2", value);
}
-} // namespace chrome_common_net.
+} // namespace
+} // namespace net
diff --git a/net/net.gyp b/net/net.gyp
index eeaeab5..035ec22 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -306,6 +306,8 @@
'base/upload_file_element_reader.cc',
'base/upload_file_element_reader.h',
'base/upload_progress.h',
+ 'base/url_util.cc',
+ 'base/url_util.h',
'base/winsock_init.cc',
'base/winsock_init.h',
'base/winsock_util.cc',
@@ -1361,6 +1363,7 @@
'base/upload_bytes_element_reader_unittest.cc',
'base/upload_data_stream_unittest.cc',
'base/upload_file_element_reader_unittest.cc',
+ 'base/url_util_unittest.cc',
'base/x509_certificate_unittest.cc',
'base/x509_cert_types_unittest.cc',
'base/x509_util_unittest.cc',