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

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

Issue 171012: Use 'icu::' namespace explicitly (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « base/time_format.cc ('k') | chrome/browser/history/snippet.cc » ('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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/gfx/png_decoder.h" 8 #include "base/gfx/png_decoder.h"
9 #include "base/scoped_vector.h" 9 #include "base/scoped_vector.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // BookmarkModel -------------------------------------------------------------- 76 // BookmarkModel --------------------------------------------------------------
77 77
78 namespace { 78 namespace {
79 79
80 // Comparator used when sorting bookmarks. Folders are sorted first, then 80 // Comparator used when sorting bookmarks. Folders are sorted first, then
81 // bookmarks. 81 // bookmarks.
82 class SortComparator : public std::binary_function<const BookmarkNode*, 82 class SortComparator : public std::binary_function<const BookmarkNode*,
83 const BookmarkNode*, 83 const BookmarkNode*,
84 bool> { 84 bool> {
85 public: 85 public:
86 explicit SortComparator(Collator* collator) : collator_(collator) { } 86 explicit SortComparator(icu::Collator* collator) : collator_(collator) { }
87 87
88 // Returns true if lhs preceeds rhs. 88 // Returns true if lhs preceeds rhs.
89 bool operator() (const BookmarkNode* n1, const BookmarkNode* n2) { 89 bool operator() (const BookmarkNode* n1, const BookmarkNode* n2) {
90 if (n1->GetType() == n2->GetType()) { 90 if (n1->GetType() == n2->GetType()) {
91 // Types are the same, compare the names. 91 // Types are the same, compare the names.
92 if (!collator_) 92 if (!collator_)
93 return n1->GetTitle() < n2->GetTitle(); 93 return n1->GetTitle() < n2->GetTitle();
94 return l10n_util::CompareStringWithCollator(collator_, n1->GetTitle(), 94 return l10n_util::CompareStringWithCollator(collator_, n1->GetTitle(),
95 n2->GetTitle()) == UCOL_LESS; 95 n2->GetTitle()) == UCOL_LESS;
96 } 96 }
97 // Types differ, sort such that folders come first. 97 // Types differ, sort such that folders come first.
98 return n1->is_folder(); 98 return n1->is_folder();
99 } 99 }
100 100
101 private: 101 private:
102 Collator* collator_; 102 icu::Collator* collator_;
103 }; 103 };
104 104
105 } // namespace 105 } // namespace
106 106
107 BookmarkModel::BookmarkModel(Profile* profile) 107 BookmarkModel::BookmarkModel(Profile* profile)
108 : profile_(profile), 108 : profile_(profile),
109 loaded_(false), 109 loaded_(false),
110 file_changed_(false), 110 file_changed_(false),
111 root_(GURL()), 111 root_(GURL()),
112 bookmark_bar_node_(NULL), 112 bookmark_bar_node_(NULL),
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return AddNode(AsMutable(parent), index, new_node, was_bookmarked); 336 return AddNode(AsMutable(parent), index, new_node, was_bookmarked);
337 } 337 }
338 338
339 void BookmarkModel::SortChildren(const BookmarkNode* parent) { 339 void BookmarkModel::SortChildren(const BookmarkNode* parent) {
340 if (!parent || !parent->is_folder() || is_root(parent) || 340 if (!parent || !parent->is_folder() || is_root(parent) ||
341 parent->GetChildCount() <= 1) { 341 parent->GetChildCount() <= 1) {
342 return; 342 return;
343 } 343 }
344 344
345 UErrorCode error = U_ZERO_ERROR; 345 UErrorCode error = U_ZERO_ERROR;
346 scoped_ptr<Collator> collator( 346 scoped_ptr<icu::Collator> collator(
347 Collator::createInstance( 347 icu::Collator::createInstance(
348 Locale(g_browser_process->GetApplicationLocale().c_str()), 348 icu::Locale(g_browser_process->GetApplicationLocale().c_str()),
349 error)); 349 error));
350 if (U_FAILURE(error)) 350 if (U_FAILURE(error))
351 collator.reset(NULL); 351 collator.reset(NULL);
352 BookmarkNode* mutable_parent = AsMutable(parent); 352 BookmarkNode* mutable_parent = AsMutable(parent);
353 std::sort(mutable_parent->children().begin(), 353 std::sort(mutable_parent->children().begin(),
354 mutable_parent->children().end(), 354 mutable_parent->children().end(),
355 SortComparator(collator.get())); 355 SortComparator(collator.get()));
356 356
357 if (store_.get()) 357 if (store_.get())
358 store_->ScheduleSave(); 358 store_->ScheduleSave();
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 void BookmarkModel::SetFileChanged() { 722 void BookmarkModel::SetFileChanged() {
723 file_changed_ = true; 723 file_changed_ = true;
724 } 724 }
725 725
726 BookmarkStorage::LoadDetails* BookmarkModel::CreateLoadDetails() { 726 BookmarkStorage::LoadDetails* BookmarkModel::CreateLoadDetails() {
727 BookmarkNode* bb_node = CreateBookmarkNode(); 727 BookmarkNode* bb_node = CreateBookmarkNode();
728 BookmarkNode* other_folder_node = CreateOtherBookmarksNode(); 728 BookmarkNode* other_folder_node = CreateOtherBookmarksNode();
729 return new BookmarkStorage::LoadDetails( 729 return new BookmarkStorage::LoadDetails(
730 bb_node, other_folder_node, new BookmarkIndex(), next_node_id_); 730 bb_node, other_folder_node, new BookmarkIndex(), next_node_id_);
731 } 731 }
OLDNEW
« no previous file with comments | « base/time_format.cc ('k') | chrome/browser/history/snippet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698