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

Side by Side Diff: components/bookmarks/browser/bookmark_utils.cc

Issue 1260033005: Revert of Move net::FormatUrl and friends outside of //net and into //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « components/bookmarks/browser/bookmark_utils.h ('k') | components/components.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/bookmarks/browser/bookmark_utils.h" 5 #include "components/bookmarks/browser/bookmark_utils.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/i18n/case_conversion.h" 13 #include "base/i18n/case_conversion.h"
14 #include "base/i18n/string_search.h" 14 #include "base/i18n/string_search.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/metrics/user_metrics_action.h" 16 #include "base/metrics/user_metrics_action.h"
17 #include "base/prefs/pref_service.h" 17 #include "base/prefs/pref_service.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "components/bookmarks/browser/bookmark_client.h" 22 #include "components/bookmarks/browser/bookmark_client.h"
23 #include "components/bookmarks/browser/bookmark_model.h" 23 #include "components/bookmarks/browser/bookmark_model.h"
24 #include "components/bookmarks/browser/scoped_group_bookmark_actions.h" 24 #include "components/bookmarks/browser/scoped_group_bookmark_actions.h"
25 #include "components/bookmarks/common/bookmark_pref_names.h" 25 #include "components/bookmarks/common/bookmark_pref_names.h"
26 #include "components/pref_registry/pref_registry_syncable.h" 26 #include "components/pref_registry/pref_registry_syncable.h"
27 #include "components/query_parser/query_parser.h" 27 #include "components/query_parser/query_parser.h"
28 #include "components/url_formatter/url_formatter.h" 28 #include "net/base/net_util.h"
29 #include "ui/base/clipboard/clipboard.h" 29 #include "ui/base/clipboard/clipboard.h"
30 #include "ui/base/models/tree_node_iterator.h" 30 #include "ui/base/models/tree_node_iterator.h"
31 #include "url/gurl.h" 31 #include "url/gurl.h"
32 32
33 using base::Time; 33 using base::Time;
34 34
35 namespace bookmarks { 35 namespace bookmarks {
36 36
37 namespace { 37 namespace {
38 38
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 } 90 }
91 return true; 91 return true;
92 } 92 }
93 93
94 // Returns true if |node|s title or url contains the strings in |words|. 94 // Returns true if |node|s title or url contains the strings in |words|.
95 // |languages| argument is user's accept-language setting to decode IDN. 95 // |languages| argument is user's accept-language setting to decode IDN.
96 bool DoesBookmarkContainWords(const BookmarkNode* node, 96 bool DoesBookmarkContainWords(const BookmarkNode* node,
97 const std::vector<base::string16>& words, 97 const std::vector<base::string16>& words,
98 const std::string& languages) { 98 const std::string& languages) {
99 return DoesBookmarkTextContainWords(node->GetTitle(), words) || 99 return
100 DoesBookmarkTextContainWords(base::UTF8ToUTF16(node->url().spec()), 100 DoesBookmarkTextContainWords(node->GetTitle(), words) ||
101 words) || 101 DoesBookmarkTextContainWords(
102 DoesBookmarkTextContainWords( 102 base::UTF8ToUTF16(node->url().spec()), words) ||
103 url_formatter::FormatUrl( 103 DoesBookmarkTextContainWords(net::FormatUrl(
104 node->url(), languages, url_formatter::kFormatUrlOmitNothing, 104 node->url(), languages, net::kFormatUrlOmitNothing,
105 net::UnescapeRule::NORMAL, NULL, NULL, NULL), 105 net::UnescapeRule::NORMAL, NULL, NULL, NULL), words);
106 words);
107 } 106 }
108 107
109 // This is used with a tree iterator to skip subtrees which are not visible. 108 // This is used with a tree iterator to skip subtrees which are not visible.
110 bool PruneInvisibleFolders(const BookmarkNode* node) { 109 bool PruneInvisibleFolders(const BookmarkNode* node) {
111 return !node->IsVisible(); 110 return !node->IsVisible();
112 } 111 }
113 112
114 // This traces parents up to root, determines if node is contained in a 113 // This traces parents up to root, determines if node is contained in a
115 // selected folder. 114 // selected folder.
116 bool HasSelectedAncestor(BookmarkModel* model, 115 bool HasSelectedAncestor(BookmarkModel* model,
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 if (index > -1 && model->client()->CanBeEditedByUser(node)) 509 if (index > -1 && model->client()->CanBeEditedByUser(node))
511 model->Remove(node); 510 model->Remove(node);
512 } 511 }
513 } 512 }
514 513
515 base::string16 CleanUpUrlForMatching( 514 base::string16 CleanUpUrlForMatching(
516 const GURL& gurl, 515 const GURL& gurl,
517 const std::string& languages, 516 const std::string& languages,
518 base::OffsetAdjuster::Adjustments* adjustments) { 517 base::OffsetAdjuster::Adjustments* adjustments) {
519 base::OffsetAdjuster::Adjustments tmp_adjustments; 518 base::OffsetAdjuster::Adjustments tmp_adjustments;
520 return base::i18n::ToLower(url_formatter::FormatUrlWithAdjustments( 519 return base::i18n::ToLower(net::FormatUrlWithAdjustments(
521 GURL(TruncateUrl(gurl.spec())), languages, 520 GURL(TruncateUrl(gurl.spec())), languages,
522 url_formatter::kFormatUrlOmitUsernamePassword, 521 net::kFormatUrlOmitUsernamePassword,
523 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS, NULL, 522 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS,
524 NULL, adjustments ? adjustments : &tmp_adjustments)); 523 NULL, NULL, adjustments ? adjustments : &tmp_adjustments));
525 } 524 }
526 525
527 base::string16 CleanUpTitleForMatching(const base::string16& title) { 526 base::string16 CleanUpTitleForMatching(const base::string16& title) {
528 return base::i18n::ToLower(title.substr(0u, kCleanedUpTitleMaxLength)); 527 return base::i18n::ToLower(title.substr(0u, kCleanedUpTitleMaxLength));
529 } 528 }
530 529
531 bool CanAllBeEditedByUser(BookmarkClient* client, 530 bool CanAllBeEditedByUser(BookmarkClient* client,
532 const std::vector<const BookmarkNode*>& nodes) { 531 const std::vector<const BookmarkNode*>& nodes) {
533 for (size_t i = 0; i < nodes.size(); ++i) { 532 for (size_t i = 0; i < nodes.size(); ++i) {
534 if (!client->CanBeEditedByUser(nodes[i])) 533 if (!client->CanBeEditedByUser(nodes[i]))
(...skipping 25 matching lines...) Expand all
560 bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list, 559 bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list,
561 const BookmarkNode* root) { 560 const BookmarkNode* root) {
562 for (const BookmarkNode* node : list) { 561 for (const BookmarkNode* node : list) {
563 if (IsDescendantOf(node, root)) 562 if (IsDescendantOf(node, root))
564 return true; 563 return true;
565 } 564 }
566 return false; 565 return false;
567 } 566 }
568 567
569 } // namespace bookmarks 568 } // namespace bookmarks
OLDNEW
« no previous file with comments | « components/bookmarks/browser/bookmark_utils.h ('k') | components/components.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698