Skip to content

Commit

Permalink
Revert of Move net::FormatUrl and friends outside of //net and into /…
Browse files Browse the repository at this point in the history
…/components (patchset chromium#16 id:290001 of https://codereview.chromium.org/1171333003/ )

Reason for revert:
breaks gn_check on Android: https://build.chromium.org/p/chromium.linux/builders/Android%20GN/builds/28796/steps/gn_check/logs/stdio

Original issue's description:
> Move net::FormatUrl and friends outside of //net and into //components
>
> net::FormatUrl and related are specifically concerned with display
> policies of URLs, which is not something that //net needs to be aware
> of, as that's a UX question.
>
> This folds in net::FormatURL along with the existing //components/url_fixer
> and //components/secure_display into a common component,
> //components/url_formatter, that handles reformatting URLs for user-friendly
> or data storage (url_formatter), for use in security prompts (elide_url),
> or for reformatting URLs from user input (url_fixer)
>
> (Disabling presubmit since this is intentionally not fixing a legacy API, just moving it for future cleanups)
>
> BUG=486979
> NOPRESUBMIT=true
>
> Committed: https://crrev.com/1659865c3eb47166c82378bb840801135b057a09
> Cr-Commit-Position: refs/heads/master@{#341605}

TBR=droger@chromium.org,jam@chromium.org,mkwst@chromium.org,pkasting@chromium.org,sky@chromium.org,stuartmorgan@chromium.org,felt@chromium.org,rsleevi@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=486979

Review URL: https://codereview.chromium.org/1260033005

Cr-Commit-Position: refs/heads/master@{#341691}
  • Loading branch information
jeisinger authored and Commit bot committed Aug 4, 2015
1 parent 31ad3e6 commit 90437dd
Show file tree
Hide file tree
Showing 172 changed files with 2,518 additions and 2,593 deletions.
2 changes: 1 addition & 1 deletion .gn
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ check_targets = [
"//components/pref_registry/*",
"//components/undo/*",
"//components/update_client/*",
"//components/url_formatter/*",
"//components/url_fixer/*",
"//components/url_matcher/*",
"//components/user_manager/*",
"//components/user_prefs/*",
Expand Down
2 changes: 1 addition & 1 deletion chrome/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ include_rules = [
"+components/content_settings/core/common",
"+components/error_page/common",
"+components/omnibox/common",
"+components/url_formatter",
"+components/url_fixer",
"+components/variations",
"+content/public/common",
"+content/public/test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static boolean isInternalScheme(URI uri) {
}

/**
* Refer to url_formatter::FixupURL.
* Refer to url_fixer::FixupURL.
*
* Given a URL-like string, returns a real URL or null. For example:
* - "google.com" -> "http://google.com/"
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ source_set("browser") {
"//components/ui/zoom:ui_zoom",
"//components/undo",
"//components/update_client",
"//components/url_formatter",
"//components/url_fixer",
"//components/user_prefs",
"//components/variations",
"//components/variations/net",
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ include_rules = [
"+components/ui",
"+components/undo",
"+components/update_client",
"+components/url_formatter",
"+components/url_matcher",
"+components/user_manager",
"+components/user_prefs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/infobars/core/infobar.h"
#include "components/url_formatter/url_formatter.h"
#include "grit/components_strings.h"
#include "grit/theme_resources.h"
#include "jni/FullscreenInfoBarDelegate_jni.h"
#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"

Expand Down Expand Up @@ -69,8 +69,7 @@ base::string16 FullscreenInfoBarDelegate::GetMessageText() const {
std::string language =
profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
return l10n_util::GetStringFUTF16(
IDS_FULLSCREEN_INFOBAR_TEXT,
url_formatter::FormatUrl(GURL(origin_), language));
IDS_FULLSCREEN_INFOBAR_TEXT, net::FormatUrl(GURL(origin_), language));
}

base::string16 FullscreenInfoBarDelegate::GetButtonLabel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
#include "components/search/search.h"
#include "components/search_engines/template_url_service.h"
#include "components/toolbar/toolbar_model.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "jni/AutocompleteController_jni.h"
#include "net/base/escape.h"
#include "net/base/net_util.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"

using base::android::AttachCurrentThread;
Expand Down Expand Up @@ -475,9 +475,8 @@ base::string16 AutocompleteControllerAndroid::FormatURLUsingAcceptLanguages(
std::string languages(
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));

return url_formatter::FormatUrl(
url, languages, url_formatter::kFormatUrlOmitAll,
net::UnescapeRule::SPACES, nullptr, nullptr, nullptr);
return net::FormatUrl(url, languages, net::kFormatUrlOmitAll,
net::UnescapeRule::SPACES, NULL, NULL, NULL);
}

ScopedJavaLocalRef<jobject>
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/android/tab_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include "components/infobars/core/infobar_container.h"
#include "components/navigation_interception/intercept_navigation_delegate.h"
#include "components/navigation_interception/navigation_params.h"
#include "components/url_formatter/url_fixer.h"
#include "components/url_fixer/url_fixer.h"
#include "content/public/browser/android/compositor.h"
#include "content/public/browser/android/content_view_core.h"
#include "content/public/browser/browser_thread.h"
Expand Down Expand Up @@ -570,7 +570,7 @@ TabAndroid::TabLoadStatus TabAndroid::LoadUrl(JNIEnv* env,
}

GURL fixed_url(
url_formatter::FixupURL(gurl.possibly_invalid_spec(), std::string()));
url_fixer::FixupURL(gurl.possibly_invalid_spec(), std::string()));
if (!fixed_url.is_valid())
return PAGE_LOAD_FAILED;

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/android/url_utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "components/google/core/browser/google_util.h"
#include "components/url_formatter/url_fixer.h"
#include "components/url_fixer/url_fixer.h"
#include "jni/UrlUtilities_jni.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "url/gurl.h"
Expand Down Expand Up @@ -80,7 +80,7 @@ static jstring FixupUrl(JNIEnv* env,
jstring url,
jstring optional_desired_tld) {
DCHECK(url);
GURL fixed_url = url_formatter::FixupURL(
GURL fixed_url = url_fixer::FixupURL(
base::android::ConvertJavaStringToUTF8(env, url),
optional_desired_tld
? base::android::ConvertJavaStringToUTF8(env, optional_desired_tld)
Expand Down
9 changes: 4 additions & 5 deletions chrome/browser/autocomplete/history_url_provider_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h"
#include "components/url_formatter/url_fixer.h"
#include "components/url_fixer/url_fixer.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand Down Expand Up @@ -728,7 +728,7 @@ TEST_F(HistoryURLProviderTest, IntranetURLsWithPaths) {
RunTest(ASCIIToUTF16(test_cases[i].input), std::string(), false, NULL, 0);
} else {
const UrlAndLegalDefault output[] = {
{url_formatter::FixupURL(test_cases[i].input, std::string()).spec(),
{url_fixer::FixupURL(test_cases[i].input, std::string()).spec(),
true}};
ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input),
std::string(), false, output, arraysize(output)));
Expand Down Expand Up @@ -1042,9 +1042,8 @@ TEST_F(HistoryURLProviderTest, HUPScoringExperiment) {
if (test_cases[i].matches[max_matches].url == NULL)
break;
output[max_matches].url =
url_formatter::FixupURL(test_cases[i].matches[max_matches].url,
std::string())
.spec();
url_fixer::FixupURL(test_cases[i].matches[max_matches].url,
std::string()).spec();
output[max_matches].allowed_to_be_default_match = true;
}
autocomplete_->scoring_params_ = test_cases[i].scoring_params;
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/browser_about_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "components/url_formatter/url_fixer.h"
#include "components/url_fixer/url_fixer.h"

bool FixupBrowserAboutURL(GURL* url,
content::BrowserContext* browser_context) {
// Ensure that any cleanup done by FixupURL happens before the rewriting
// phase that determines the virtual URL, by including it in an initial
// URLHandler. This prevents minor changes from producing a virtual URL,
// which could lead to a URL spoof.
*url = url_formatter::FixupURL(url->possibly_invalid_spec(), std::string());
*url = url_fixer::FixupURL(url->possibly_invalid_spec(), std::string());
return true;
}

Expand All @@ -34,11 +34,11 @@ bool WillHandleBrowserAboutURL(GURL* url,
// then hopefully we can remove this forced fixup.
FixupBrowserAboutURL(url, browser_context);

// Check that about: URLs are fixed up to chrome: by url_formatter::FixupURL.
// Check that about: URLs are fixed up to chrome: by url_fixer::FixupURL.
DCHECK((*url == GURL(url::kAboutBlankURL)) ||
!url->SchemeIs(url::kAboutScheme));

// Only handle chrome://foo/, url_formatter::FixupURL translates about:foo.
// Only handle chrome://foo/, url_fixer::FixupURL translates about:foo.
if (!url->SchemeIs(content::kChromeUIScheme))
return false;

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/browser_about_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool FixupBrowserAboutURL(GURL* url, content::BrowserContext* browser_context);

// Returns true if the given URL will be handled by the browser about handler.
// Nowadays, these go through the webui, so the return is always false.
// Either way, |url| will be processed by url_formatter::FixupURL, which
// Either way, |url| will be processed by url_fixer::FixupURL, which
// replaces the about: scheme with chrome:// for all about:foo URLs except
// "about:blank".
// Some |url| host values will be replaced with their respective redirects.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
#include "components/rappor/rappor_utils.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "components/translate/core/common/translate_switches.h"
#include "components/url_formatter/url_fixer.h"
#include "components/url_fixer/url_fixer.h"
#include "components/variations/variations_associated_data.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_child_process_host.h"
Expand Down
34 changes: 17 additions & 17 deletions chrome/browser/chrome_quota_permission_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#include "chrome/grit/locale_settings.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "components/infobars/core/infobar.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/web_contents.h"
#include "grit/theme_resources.h"
#include "net/base/net_util.h"
#include "storage/common/quota/quota_types.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
Expand Down Expand Up @@ -93,14 +93,14 @@ int QuotaPermissionRequest::GetIconID() const {

base::string16 QuotaPermissionRequest::GetMessageText() const {
return l10n_util::GetStringFUTF16(
(requested_quota_ > kRequestLargeQuotaThreshold
? IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION
: IDS_REQUEST_QUOTA_INFOBAR_QUESTION),
url_formatter::FormatUrl(
origin_url_, display_languages_,
url_formatter::kFormatUrlOmitUsernamePassword |
url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname,
net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));
(requested_quota_ > kRequestLargeQuotaThreshold ?
IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION :
IDS_REQUEST_QUOTA_INFOBAR_QUESTION),
net::FormatUrl(origin_url_, display_languages_,
net::kFormatUrlOmitUsernamePassword |
net::kFormatUrlOmitTrailingSlashOnBareHostname,
net::UnescapeRule::SPACES, NULL, NULL, NULL)
);
}

base::string16 QuotaPermissionRequest::GetMessageTextFragment() const {
Expand Down Expand Up @@ -219,14 +219,14 @@ base::string16 RequestQuotaInfoBarDelegate::GetMessageText() const {
// If the site requested larger quota than this threshold, show a different
// message to the user.
return l10n_util::GetStringFUTF16(
(requested_quota_ > kRequestLargeQuotaThreshold
? IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION
: IDS_REQUEST_QUOTA_INFOBAR_QUESTION),
url_formatter::FormatUrl(
origin_url_, display_languages_,
url_formatter::kFormatUrlOmitUsernamePassword |
url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname,
net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));
(requested_quota_ > kRequestLargeQuotaThreshold ?
IDS_REQUEST_LARGE_QUOTA_INFOBAR_QUESTION :
IDS_REQUEST_QUOTA_INFOBAR_QUESTION),
net::FormatUrl(origin_url_, display_languages_,
net::kFormatUrlOmitUsernamePassword |
net::kFormatUrlOmitTrailingSlashOnBareHostname,
net::UnescapeRule::SPACES, NULL, NULL, NULL)
);
}

bool RequestQuotaInfoBarDelegate::Accept() {
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/custom_home_pages_table_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "components/history/core/browser/history_service.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/browser/web_contents.h"
#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/table_model_observer.h"
#include "ui/gfx/codec/png_codec.h"
Expand Down Expand Up @@ -305,7 +305,7 @@ void CustomHomePagesTableModel::OnGotTitle(const GURL& entry_url,
base::string16 CustomHomePagesTableModel::FormattedURL(int row) const {
std::string languages =
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
base::string16 url = url_formatter::FormatUrl(entries_[row].url, languages);
base::string16 url = net::FormatUrl(entries_[row].url, languages);
url = base::i18n::GetDisplayStringInLTRDirectionality(url);
return url;
}
13 changes: 8 additions & 5 deletions chrome/browser/dom_distiller/tab_utils_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/pref_names.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_constants.h"
#include "jni/DomDistillerTabUtils_jni.h"
Expand Down Expand Up @@ -57,10 +56,14 @@ jstring GetFormattedUrlFromOriginalDistillerUrl(JNIEnv* env,
// and pastes it into another program, that program may think the URL ends at
// the space.
return base::android::ConvertUTF16ToJavaString(
env, url_formatter::FormatUrl(
url, languages, url_formatter::kFormatUrlOmitAll,
net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr))
.Release();
env,
net::FormatUrl(url,
languages,
net::kFormatUrlOmitAll,
net::UnescapeRule::NORMAL,
NULL,
NULL,
NULL)).Release();
}

} // namespace android
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/download/download_query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/download_item.h"
#include "net/base/net_util.h"
#include "third_party/re2/re2/re2.h"
#include "url/gurl.h"

Expand Down Expand Up @@ -77,7 +77,7 @@ static bool MatchesQuery(
base::string16 url_formatted = url_raw;
if (item.GetBrowserContext()) {
Profile* profile = Profile::FromBrowserContext(item.GetBrowserContext());
url_formatted = url_formatter::FormatUrl(
url_formatted = net::FormatUrl(
item.GetOriginalUrl(),
profile->GetPrefs()->GetString(prefs::kAcceptLanguages));
}
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/extensions/api/sessions/sessions_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
#include "chrome/common/pref_names.h"
#include "components/sync_driver/glue/synced_session.h"
#include "components/sync_driver/open_tabs_ui_delegate.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/error_utils.h"
#include "net/base/net_util.h"
#include "ui/base/layout.h"

namespace extensions {
Expand Down Expand Up @@ -93,8 +93,8 @@ scoped_ptr<tabs::Tab> CreateTabModelHelper(
} else {
const std::string languages =
profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
tab_struct->title.reset(new std::string(
base::UTF16ToUTF8(url_formatter::FormatUrl(url, languages))));
tab_struct->title.reset(
new std::string(base::UTF16ToUTF8(net::FormatUrl(url, languages))));
}
tab_struct->index = index;
tab_struct->pinned = pinned;
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/extensions/api/settings_private/prefs_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/url_formatter/url_fixer.h"
#include "components/url_fixer/url_fixer.h"

#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
Expand Down Expand Up @@ -215,7 +215,7 @@ bool PrefsUtil::SetPref(const std::string& pref_name,
return false;

if (IsPrefTypeURL(pref_name)) {
GURL fixed = url_formatter::FixupURL(original, std::string());
GURL fixed = url_fixer::FixupURL(original, std::string());
temp_value.reset(new base::StringValue(fixed.spec()));
value = temp_value.get();
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/extensions/extension_tab_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "chrome/browser/ui/tabs/tab_utils.h"
#include "chrome/common/extensions/api/tabs.h"
#include "chrome/common/url_constants.h"
#include "components/url_formatter/url_fixer.h"
#include "components/url_fixer/url_fixer.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
Expand Down Expand Up @@ -550,7 +550,7 @@ bool ExtensionTabUtil::IsKillURL(const GURL& url) {

// Check a fixed-up URL, to normalize the scheme and parse hosts correctly.
GURL fixed_url =
url_formatter::FixupURL(url.possibly_invalid_spec(), std::string());
url_fixer::FixupURL(url.possibly_invalid_spec(), std::string());
if (!fixed_url.SchemeIs(content::kChromeUIScheme))
return false;

Expand Down
Loading

0 comments on commit 90437dd

Please sign in to comment.