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

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

Issue 1171333003: Move net::FormatUrl and friends outside of //net and into //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again now that CQ is fixed 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 "net/base/net_util.h" 28 #include "components/url_formatter/url_formatter.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 99 return DoesBookmarkTextContainWords(node->GetTitle(), words) ||
100 DoesBookmarkTextContainWords(node->GetTitle(), words) || 100 DoesBookmarkTextContainWords(base::UTF8ToUTF16(node->url().spec()),
101 DoesBookmarkTextContainWords( 101 words) ||
102 base::UTF8ToUTF16(node->url().spec()), words) || 102 DoesBookmarkTextContainWords(
103 DoesBookmarkTextContainWords(net::FormatUrl( 103 url_formatter::FormatUrl(
104 node->url(), languages, net::kFormatUrlOmitNothing, 104 node->url(), languages, url_formatter::kFormatUrlOmitNothing,
105 net::UnescapeRule::NORMAL, NULL, NULL, NULL), words); 105 net::UnescapeRule::NORMAL, NULL, NULL, NULL),
106 words);
106 } 107 }
107 108
108 // This is used with a tree iterator to skip subtrees which are not visible. 109 // This is used with a tree iterator to skip subtrees which are not visible.
109 bool PruneInvisibleFolders(const BookmarkNode* node) { 110 bool PruneInvisibleFolders(const BookmarkNode* node) {
110 return !node->IsVisible(); 111 return !node->IsVisible();
111 } 112 }
112 113
113 // This traces parents up to root, determines if node is contained in a 114 // This traces parents up to root, determines if node is contained in a
114 // selected folder. 115 // selected folder.
115 bool HasSelectedAncestor(BookmarkModel* model, 116 bool HasSelectedAncestor(BookmarkModel* model,
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 if (index > -1 && model->client()->CanBeEditedByUser(node)) 510 if (index > -1 && model->client()->CanBeEditedByUser(node))
510 model->Remove(node); 511 model->Remove(node);
511 } 512 }
512 } 513 }
513 514
514 base::string16 CleanUpUrlForMatching( 515 base::string16 CleanUpUrlForMatching(
515 const GURL& gurl, 516 const GURL& gurl,
516 const std::string& languages, 517 const std::string& languages,
517 base::OffsetAdjuster::Adjustments* adjustments) { 518 base::OffsetAdjuster::Adjustments* adjustments) {
518 base::OffsetAdjuster::Adjustments tmp_adjustments; 519 base::OffsetAdjuster::Adjustments tmp_adjustments;
519 return base::i18n::ToLower(net::FormatUrlWithAdjustments( 520 return base::i18n::ToLower(url_formatter::FormatUrlWithAdjustments(
520 GURL(TruncateUrl(gurl.spec())), languages, 521 GURL(TruncateUrl(gurl.spec())), languages,
521 net::kFormatUrlOmitUsernamePassword, 522 url_formatter::kFormatUrlOmitUsernamePassword,
522 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS, 523 net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS, NULL,
523 NULL, NULL, adjustments ? adjustments : &tmp_adjustments)); 524 NULL, adjustments ? adjustments : &tmp_adjustments));
524 } 525 }
525 526
526 base::string16 CleanUpTitleForMatching(const base::string16& title) { 527 base::string16 CleanUpTitleForMatching(const base::string16& title) {
527 return base::i18n::ToLower(title.substr(0u, kCleanedUpTitleMaxLength)); 528 return base::i18n::ToLower(title.substr(0u, kCleanedUpTitleMaxLength));
528 } 529 }
529 530
530 bool CanAllBeEditedByUser(BookmarkClient* client, 531 bool CanAllBeEditedByUser(BookmarkClient* client,
531 const std::vector<const BookmarkNode*>& nodes) { 532 const std::vector<const BookmarkNode*>& nodes) {
532 for (size_t i = 0; i < nodes.size(); ++i) { 533 for (size_t i = 0; i < nodes.size(); ++i) {
533 if (!client->CanBeEditedByUser(nodes[i])) 534 if (!client->CanBeEditedByUser(nodes[i]))
(...skipping 25 matching lines...) Expand all
559 bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list, 560 bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list,
560 const BookmarkNode* root) { 561 const BookmarkNode* root) {
561 for (const BookmarkNode* node : list) { 562 for (const BookmarkNode* node : list) {
562 if (IsDescendantOf(node, root)) 563 if (IsDescendantOf(node, root))
563 return true; 564 return true;
564 } 565 }
565 return false; 566 return false;
566 } 567 }
567 568
568 } // namespace bookmarks 569 } // 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