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

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

Issue 7530024: bookmarks: Simplify is_permanent_node() implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use is_root_node Created 9 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 | « no previous file | chrome/browser/bookmarks/bookmark_model.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 // Returns the 'bookmark bar' node. This is NULL until loaded. 190 // Returns the 'bookmark bar' node. This is NULL until loaded.
191 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; } 191 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; }
192 192
193 // Returns the 'other' node. This is NULL until loaded. 193 // Returns the 'other' node. This is NULL until loaded.
194 const BookmarkNode* other_node() { return other_node_; } 194 const BookmarkNode* other_node() { return other_node_; }
195 195
196 // Returns the 'synced' node. This is NULL until loaded. 196 // Returns the 'synced' node. This is NULL until loaded.
197 const BookmarkNode* synced_node() { return synced_node_; } 197 const BookmarkNode* synced_node() { return synced_node_; }
198 198
199 bool is_root_node(const BookmarkNode* node) const { return node == &root_; }
200
201 // Returns whether the given |node| is one of the permanent nodes - root node,
202 // 'bookmark bar' node, 'other' node or 'synced' node.
203 bool is_permanent_node(const BookmarkNode* node) const {
204 return node == &root_ ||
205 node == bookmark_bar_node_ ||
206 node == other_node_ ||
207 node == synced_node_;
208 }
209
210 Profile* profile() const { return profile_; }
211
199 // Returns the parent the last node was added to. This never returns NULL 212 // Returns the parent the last node was added to. This never returns NULL
200 // (as long as the model is loaded). 213 // (as long as the model is loaded).
201 const BookmarkNode* GetParentForNewNodes(); 214 const BookmarkNode* GetParentForNewNodes();
202 215
203 void AddObserver(BookmarkModelObserver* observer); 216 void AddObserver(BookmarkModelObserver* observer);
204 void RemoveObserver(BookmarkModelObserver* observer); 217 void RemoveObserver(BookmarkModelObserver* observer);
205 218
206 // Notifies the observers that an import is about to happen, so they can delay 219 // Notifies the observers that an import is about to happen, so they can delay
207 // any expensive UI updates until it's finished. 220 // any expensive UI updates until it's finished.
208 void BeginImportMode(); 221 void BeginImportMode();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Resets the 'date modified' time of the node to 0. This is used during 308 // Resets the 'date modified' time of the node to 0. This is used during
296 // importing to exclude the newly created folders from showing up in the 309 // importing to exclude the newly created folders from showing up in the
297 // combobox of most recently modified folders. 310 // combobox of most recently modified folders.
298 void ResetDateFolderModified(const BookmarkNode* node); 311 void ResetDateFolderModified(const BookmarkNode* node);
299 312
300 void GetBookmarksWithTitlesMatching( 313 void GetBookmarksWithTitlesMatching(
301 const string16& text, 314 const string16& text,
302 size_t max_count, 315 size_t max_count,
303 std::vector<bookmark_utils::TitleMatch>* matches); 316 std::vector<bookmark_utils::TitleMatch>* matches);
304 317
305 Profile* profile() const { return profile_; }
306
307 bool is_root(const BookmarkNode* node) const { return node == &root_; }
308 bool is_bookmark_bar_node(const BookmarkNode* node) const {
309 return node == bookmark_bar_node_;
310 }
311 bool is_synced_bookmarks_node(const BookmarkNode* node) const {
312 return node == synced_node_;
313 }
314 bool is_other_bookmarks_node(const BookmarkNode* node) const {
315 return node == other_node_;
316 }
317 // Returns whether the given node is one of the permanent nodes - root node,
318 // bookmark bar node or other bookmarks node.
319 bool is_permanent_node(const BookmarkNode* node) const {
320 return is_root(node) ||
321 is_bookmark_bar_node(node) ||
322 is_other_bookmarks_node(node) ||
323 is_synced_bookmarks_node(node);
324 }
325
326 // Sets the store to NULL, making it so the BookmarkModel does not persist 318 // Sets the store to NULL, making it so the BookmarkModel does not persist
327 // any changes to disk. This is only useful during testing to speed up 319 // any changes to disk. This is only useful during testing to speed up
328 // testing. 320 // testing.
329 void ClearStore(); 321 void ClearStore();
330 322
331 // Returns whether the bookmarks file changed externally. 323 // Returns whether the bookmarks file changed externally.
332 bool file_changed() const { return file_changed_; } 324 bool file_changed() const { return file_changed_; }
333 325
334 // Returns the next node ID. 326 // Returns the next node ID.
335 int64 next_node_id() const { return next_node_id_; } 327 int64 next_node_id() const { return next_node_id_; }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 scoped_ptr<BookmarkIndex> index_; 461 scoped_ptr<BookmarkIndex> index_;
470 462
471 base::WaitableEvent loaded_signal_; 463 base::WaitableEvent loaded_signal_;
472 464
473 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; 465 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_;
474 466
475 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); 467 DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
476 }; 468 };
477 469
478 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ 470 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/bookmarks/bookmark_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698