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

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

Issue 1420333006: Remove uses of std::unary_function and std::binary_function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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_model.h" 5 #include "components/bookmarks/browser/bookmark_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 29 matching lines...) Expand all
40 return const_cast<BookmarkNode*>(node); 40 return const_cast<BookmarkNode*>(node);
41 } 41 }
42 42
43 // Helper to get a mutable permanent bookmark node. 43 // Helper to get a mutable permanent bookmark node.
44 BookmarkPermanentNode* AsMutable(const BookmarkPermanentNode* node) { 44 BookmarkPermanentNode* AsMutable(const BookmarkPermanentNode* node) {
45 return const_cast<BookmarkPermanentNode*>(node); 45 return const_cast<BookmarkPermanentNode*>(node);
46 } 46 }
47 47
48 // Comparator used when sorting permanent nodes. Nodes that are initially 48 // Comparator used when sorting permanent nodes. Nodes that are initially
49 // visible are sorted before nodes that are initially hidden. 49 // visible are sorted before nodes that are initially hidden.
50 class VisibilityComparator 50 class VisibilityComparator {
51 : public std::binary_function<const BookmarkPermanentNode*,
52 const BookmarkPermanentNode*,
53 bool> {
54 public: 51 public:
55 explicit VisibilityComparator(BookmarkClient* client) : client_(client) {} 52 explicit VisibilityComparator(BookmarkClient* client) : client_(client) {}
56 53
57 // Returns true if |n1| preceeds |n2|. 54 // Returns true if |n1| preceeds |n2|.
58 bool operator()(const BookmarkPermanentNode* n1, 55 bool operator()(const BookmarkPermanentNode* n1,
59 const BookmarkPermanentNode* n2) { 56 const BookmarkPermanentNode* n2) {
60 bool n1_visible = client_->IsPermanentNodeVisible(n1); 57 bool n1_visible = client_->IsPermanentNodeVisible(n1);
61 bool n2_visible = client_->IsPermanentNodeVisible(n2); 58 bool n2_visible = client_->IsPermanentNodeVisible(n2);
62 return n1_visible != n2_visible && n1_visible; 59 return n1_visible != n2_visible && n1_visible;
63 } 60 }
64 61
65 private: 62 private:
66 BookmarkClient* client_; 63 BookmarkClient* client_;
67 }; 64 };
68 65
69 // Comparator used when sorting bookmarks. Folders are sorted first, then 66 // Comparator used when sorting bookmarks. Folders are sorted first, then
70 // bookmarks. 67 // bookmarks.
71 class SortComparator : public std::binary_function<const BookmarkNode*, 68 class SortComparator {
72 const BookmarkNode*,
73 bool> {
74 public: 69 public:
75 explicit SortComparator(icu::Collator* collator) : collator_(collator) {} 70 explicit SortComparator(icu::Collator* collator) : collator_(collator) {}
76 71
77 // Returns true if |n1| preceeds |n2|. 72 // Returns true if |n1| preceeds |n2|.
78 bool operator()(const BookmarkNode* n1, const BookmarkNode* n2) { 73 bool operator()(const BookmarkNode* n1, const BookmarkNode* n2) {
79 if (n1->type() == n2->type()) { 74 if (n1->type() == n2->type()) {
80 // Types are the same, compare the names. 75 // Types are the same, compare the names.
81 if (!collator_) 76 if (!collator_)
82 return n1->GetTitle() < n2->GetTitle(); 77 return n1->GetTitle() < n2->GetTitle();
83 return base::i18n::CompareString16WithCollator( 78 return base::i18n::CompareString16WithCollator(
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 undo_delegate_ = undo_delegate; 1111 undo_delegate_ = undo_delegate;
1117 if (undo_delegate_) 1112 if (undo_delegate_)
1118 undo_delegate_->SetUndoProvider(this); 1113 undo_delegate_->SetUndoProvider(this);
1119 } 1114 }
1120 1115
1121 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const { 1116 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const {
1122 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get(); 1117 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get();
1123 } 1118 }
1124 1119
1125 } // namespace bookmarks 1120 } // namespace bookmarks
OLDNEW
« no previous file with comments | « components/bookmarks/browser/bookmark_index.cc ('k') | components/omnibox/browser/history_quick_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698