summaryrefslogtreecommitdiffstats
path: root/components/bookmarks
diff options
context:
space:
mode:
authorrsleevi <rsleevi@chromium.org>2015-08-03 13:47:03 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-03 20:47:42 +0000
commit1659865c3eb47166c82378bb840801135b057a09 (patch)
tree7cd31e008e6097a080a0c6d2f879fc880c3a475b /components/bookmarks
parent16f99512ca431c0d2f21cf94f3a7997bbd64d8c0 (diff)
downloadchromium_src-1659865c3eb47166c82378bb840801135b057a09.zip
chromium_src-1659865c3eb47166c82378bb840801135b057a09.tar.gz
chromium_src-1659865c3eb47166c82378bb840801135b057a09.tar.bz2
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 Review URL: https://codereview.chromium.org/1171333003 Cr-Commit-Position: refs/heads/master@{#341605}
Diffstat (limited to 'components/bookmarks')
-rw-r--r--components/bookmarks/DEPS1
-rw-r--r--components/bookmarks/browser/BUILD.gn1
-rw-r--r--components/bookmarks/browser/bookmark_utils.cc25
-rw-r--r--components/bookmarks/browser/bookmark_utils.h12
4 files changed, 21 insertions, 18 deletions
diff --git a/components/bookmarks/DEPS b/components/bookmarks/DEPS
index bc82e28..75997b1 100644
--- a/components/bookmarks/DEPS
+++ b/components/bookmarks/DEPS
@@ -4,6 +4,7 @@ include_rules = [
"+components/pref_registry",
"+components/query_parser",
"+components/startup_metric_utils",
+ "+components/url_formatter",
"+grit/components_strings.h",
"+jni",
"+net/base",
diff --git a/components/bookmarks/browser/BUILD.gn b/components/bookmarks/browser/BUILD.gn
index 14ed172..03aaee9 100644
--- a/components/bookmarks/browser/BUILD.gn
+++ b/components/bookmarks/browser/BUILD.gn
@@ -50,6 +50,7 @@ source_set("browser") {
"//components/query_parser",
"//components/startup_metric_utils",
"//components/strings",
+ "//components/url_formatter",
"//net",
"//third_party/icu",
"//ui/base",
diff --git a/components/bookmarks/browser/bookmark_utils.cc b/components/bookmarks/browser/bookmark_utils.cc
index a815d1c..6d60a4f 100644
--- a/components/bookmarks/browser/bookmark_utils.cc
+++ b/components/bookmarks/browser/bookmark_utils.cc
@@ -25,7 +25,7 @@
#include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/query_parser/query_parser.h"
-#include "net/base/net_util.h"
+#include "components/url_formatter/url_formatter.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/models/tree_node_iterator.h"
#include "url/gurl.h"
@@ -96,13 +96,14 @@ bool DoesBookmarkTextContainWords(const base::string16& text,
bool DoesBookmarkContainWords(const BookmarkNode* node,
const std::vector<base::string16>& words,
const std::string& languages) {
- return
- DoesBookmarkTextContainWords(node->GetTitle(), words) ||
- DoesBookmarkTextContainWords(
- base::UTF8ToUTF16(node->url().spec()), words) ||
- DoesBookmarkTextContainWords(net::FormatUrl(
- node->url(), languages, net::kFormatUrlOmitNothing,
- net::UnescapeRule::NORMAL, NULL, NULL, NULL), words);
+ return DoesBookmarkTextContainWords(node->GetTitle(), words) ||
+ DoesBookmarkTextContainWords(base::UTF8ToUTF16(node->url().spec()),
+ words) ||
+ DoesBookmarkTextContainWords(
+ url_formatter::FormatUrl(
+ node->url(), languages, url_formatter::kFormatUrlOmitNothing,
+ net::UnescapeRule::NORMAL, NULL, NULL, NULL),
+ words);
}
// This is used with a tree iterator to skip subtrees which are not visible.
@@ -516,11 +517,11 @@ base::string16 CleanUpUrlForMatching(
const std::string& languages,
base::OffsetAdjuster::Adjustments* adjustments) {
base::OffsetAdjuster::Adjustments tmp_adjustments;
- return base::i18n::ToLower(net::FormatUrlWithAdjustments(
+ return base::i18n::ToLower(url_formatter::FormatUrlWithAdjustments(
GURL(TruncateUrl(gurl.spec())), languages,
- net::kFormatUrlOmitUsernamePassword,
- net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS,
- NULL, NULL, adjustments ? adjustments : &tmp_adjustments));
+ url_formatter::kFormatUrlOmitUsernamePassword,
+ net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS, NULL,
+ NULL, adjustments ? adjustments : &tmp_adjustments));
}
base::string16 CleanUpTitleForMatching(const base::string16& title) {
diff --git a/components/bookmarks/browser/bookmark_utils.h b/components/bookmarks/browser/bookmark_utils.h
index 57bd4bb..32e72d2 100644
--- a/components/bookmarks/browser/bookmark_utils.h
+++ b/components/bookmarks/browser/bookmark_utils.h
@@ -112,12 +112,12 @@ void AddIfNotBookmarked(BookmarkModel* model,
void RemoveAllBookmarks(BookmarkModel* model, const GURL& url);
// Truncates an overly-long URL, unescapes it and interprets the characters
-// as UTF-8 (both via net::FormatUrl()), and lower-cases it, returning the
-// result. |languages| is passed to net::FormatUrl(). |adjustments|, if
-// non-NULL, is set to reflect the transformations the URL spec underwent to
-// become the return value. If a caller computes offsets (e.g., for the
-// position of matched text) in this cleaned-up string, it can use
-// |adjustments| to calculate the location of these offsets in the original
+// as UTF-8 (both via url_formatter::FormatUrl()), and lower-cases it, returning
+// the result. |languages| is passed to url_formatter::FormatUrl().
+// |adjustments|, if non-NULL, is set to reflect the transformations the URL
+// spec underwent to become the return value. If a caller computes offsets
+// (e.g., for the position of matched text) in this cleaned-up string, it can
+// use |adjustments| to calculate the location of these offsets in the original
// string (via base::OffsetAdjuster::UnadjustOffsets()). This is useful if
// later the original string gets formatted in a different way for displaying.
// In this case, knowing the offsets in the original string will allow them to