OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/bookmarks/bookmark_model.h" | 5 #include "chrome/browser/bookmarks/bookmark_model.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/l10n_util_collator.h" | 8 #include "app/l10n_util_collator.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/scoped_vector.h" | 10 #include "base/scoped_vector.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 bool> { | 95 bool> { |
96 public: | 96 public: |
97 explicit SortComparator(icu::Collator* collator) : collator_(collator) { } | 97 explicit SortComparator(icu::Collator* collator) : collator_(collator) { } |
98 | 98 |
99 // Returns true if lhs preceeds rhs. | 99 // Returns true if lhs preceeds rhs. |
100 bool operator() (const BookmarkNode* n1, const BookmarkNode* n2) { | 100 bool operator() (const BookmarkNode* n1, const BookmarkNode* n2) { |
101 if (n1->type() == n2->type()) { | 101 if (n1->type() == n2->type()) { |
102 // Types are the same, compare the names. | 102 // Types are the same, compare the names. |
103 if (!collator_) | 103 if (!collator_) |
104 return n1->GetTitle() < n2->GetTitle(); | 104 return n1->GetTitle() < n2->GetTitle(); |
105 return l10n_util::CompareStringWithCollator(collator_, | 105 return l10n_util::CompareString16WithCollator( |
106 UTF16ToWideHack(n1->GetTitle()), UTF16ToWideHack(n2->GetTitle())) == | 106 collator_, n1->GetTitle(), n2->GetTitle()) == UCOL_LESS; |
107 UCOL_LESS; | |
108 } | 107 } |
109 // Types differ, sort such that folders come first. | 108 // Types differ, sort such that folders come first. |
110 return n1->is_folder(); | 109 return n1->is_folder(); |
111 } | 110 } |
112 | 111 |
113 private: | 112 private: |
114 icu::Collator* collator_; | 113 icu::Collator* collator_; |
115 }; | 114 }; |
116 | 115 |
117 } // namespace | 116 } // namespace |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 void BookmarkModel::SetFileChanged() { | 820 void BookmarkModel::SetFileChanged() { |
822 file_changed_ = true; | 821 file_changed_ = true; |
823 } | 822 } |
824 | 823 |
825 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { | 824 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { |
826 BookmarkNode* bb_node = CreateBookmarkNode(); | 825 BookmarkNode* bb_node = CreateBookmarkNode(); |
827 BookmarkNode* other_folder_node = CreateOtherBookmarksNode(); | 826 BookmarkNode* other_folder_node = CreateOtherBookmarksNode(); |
828 return new BookmarkLoadDetails( | 827 return new BookmarkLoadDetails( |
829 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_); | 828 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_); |
830 } | 829 } |
OLD | NEW |