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

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

Issue 3181030: bookmarks: Add HasBookmarks() method to BookmarkModel API. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 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
OLDNEW
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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 for (NodesOrderedByURLSet::iterator i = nodes_ordered_by_url_set_.begin(); 341 for (NodesOrderedByURLSet::iterator i = nodes_ordered_by_url_set_.begin();
342 i != nodes_ordered_by_url_set_.end(); ++i) { 342 i != nodes_ordered_by_url_set_.end(); ++i) {
343 const GURL* url = &((*i)->GetURL()); 343 const GURL* url = &((*i)->GetURL());
344 // Only add unique URLs. 344 // Only add unique URLs.
345 if (!last_url || *url != *last_url) 345 if (!last_url || *url != *last_url)
346 urls->push_back(*url); 346 urls->push_back(*url);
347 last_url = url; 347 last_url = url;
348 } 348 }
349 } 349 }
350 350
351 bool BookmarkModel::HasBookmarks() {
352 AutoLock url_lock(url_lock_);
353 return !nodes_ordered_by_url_set_.empty();
354 }
355
351 bool BookmarkModel::IsBookmarked(const GURL& url) { 356 bool BookmarkModel::IsBookmarked(const GURL& url) {
352 AutoLock url_lock(url_lock_); 357 AutoLock url_lock(url_lock_);
353 return IsBookmarkedNoLock(url); 358 return IsBookmarkedNoLock(url);
354 } 359 }
355 360
356 const BookmarkNode* BookmarkModel::GetNodeByID(int64 id) { 361 const BookmarkNode* BookmarkModel::GetNodeByID(int64 id) {
357 // TODO(sky): TreeNode needs a method that visits all nodes using a predicate. 362 // TODO(sky): TreeNode needs a method that visits all nodes using a predicate.
358 return GetNodeByID(&root_, id); 363 return GetNodeByID(&root_, id);
359 } 364 }
360 365
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 void BookmarkModel::SetFileChanged() { 821 void BookmarkModel::SetFileChanged() {
817 file_changed_ = true; 822 file_changed_ = true;
818 } 823 }
819 824
820 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { 825 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() {
821 BookmarkNode* bb_node = CreateBookmarkNode(); 826 BookmarkNode* bb_node = CreateBookmarkNode();
822 BookmarkNode* other_folder_node = CreateOtherBookmarksNode(); 827 BookmarkNode* other_folder_node = CreateOtherBookmarksNode();
823 return new BookmarkLoadDetails( 828 return new BookmarkLoadDetails(
824 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_); 829 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_);
825 } 830 }
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