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

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

Issue 27082: Adds ability to sort the children of a node in the bookmark model. I... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
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 "base/gfx/png_decoder.h" 7 #include "base/gfx/png_decoder.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "chrome/browser/bookmarks/bookmark_utils.h" 9 #include "chrome/browser/bookmarks/bookmark_utils.h"
10 #include "chrome/browser/bookmarks/bookmark_storage.h" 10 #include "chrome/browser/bookmarks/bookmark_storage.h"
11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/profile.h" 12 #include "chrome/browser/profile.h"
12 #include "chrome/common/l10n_util.h" 13 #include "chrome/common/l10n_util.h"
13 #include "chrome/common/notification_service.h" 14 #include "chrome/common/notification_service.h"
14 #include "chrome/common/scoped_vector.h" 15 #include "chrome/common/scoped_vector.h"
15 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
16 17
17 using base::Time; 18 using base::Time;
18 19
19 // BookmarkNode --------------------------------------------------------------- 20 // BookmarkNode ---------------------------------------------------------------
20 21
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 292
292 { 293 {
293 // Only hold the lock for the duration of the insert. 294 // Only hold the lock for the duration of the insert.
294 AutoLock url_lock(url_lock_); 295 AutoLock url_lock(url_lock_);
295 nodes_ordered_by_url_set_.insert(new_node); 296 nodes_ordered_by_url_set_.insert(new_node);
296 } 297 }
297 298
298 return AddNode(parent, index, new_node, was_bookmarked); 299 return AddNode(parent, index, new_node, was_bookmarked);
299 } 300 }
300 301
302 void BookmarkModel::SortChildren(BookmarkNode* parent) {
303 if (!parent || !parent->is_folder() || parent == root_node() ||
304 parent->GetChildCount() <= 1) {
305 return;
306 }
307
308 l10n_util::SortStringsUsingMethod(g_browser_process->GetApplicationLocale(),
309 &(parent->children()),
310 &BookmarkNode::GetTitle);
311
312 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_,
313 BookmarkNodeChildrenReordered(this, parent));
314 }
315
301 void BookmarkModel::SetURLStarred(const GURL& url, 316 void BookmarkModel::SetURLStarred(const GURL& url,
302 const std::wstring& title, 317 const std::wstring& title,
303 bool is_starred) { 318 bool is_starred) {
304 std::vector<BookmarkNode*> bookmarks; 319 std::vector<BookmarkNode*> bookmarks;
305 GetNodesByURL(url, &bookmarks); 320 GetNodesByURL(url, &bookmarks);
306 bool bookmarks_exist = !bookmarks.empty(); 321 bool bookmarks_exist = !bookmarks.empty();
307 if (is_starred == bookmarks_exist) 322 if (is_starred == bookmarks_exist)
308 return; // Nothing to do, state already matches. 323 return; // Nothing to do, state already matches.
309 324
310 if (is_starred) { 325 if (is_starred) {
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 698 }
684 699
685 void BookmarkModel::PopulateNodesByURL(BookmarkNode* node) { 700 void BookmarkModel::PopulateNodesByURL(BookmarkNode* node) {
686 // NOTE: this is called with url_lock_ already held. As such, this doesn't 701 // NOTE: this is called with url_lock_ already held. As such, this doesn't
687 // explicitly grab the lock. 702 // explicitly grab the lock.
688 if (node->is_url()) 703 if (node->is_url())
689 nodes_ordered_by_url_set_.insert(node); 704 nodes_ordered_by_url_set_.insert(node);
690 for (int i = 0; i < node->GetChildCount(); ++i) 705 for (int i = 0; i < node->GetChildCount(); ++i)
691 PopulateNodesByURL(node->GetChild(i)); 706 PopulateNodesByURL(node->GetChild(i));
692 } 707 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.h ('k') | chrome/browser/bookmarks/bookmark_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698