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

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: rebased 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 // Returns whether the given |node| is one of the permanent nodes - root node,
200 // 'bookmark bar' node, 'other' node or 'synced' node.
201 bool is_permanent_node(const BookmarkNode* node) const {
202 return node == &root_ ||
203 node == bookmark_bar_node_ ||
204 node == other_node_ ||
205 node == synced_node_;
206 }
207
208 Profile* profile() const { return profile_; }
209
199 // Returns the parent the last node was added to. This never returns NULL 210 // Returns the parent the last node was added to. This never returns NULL
200 // (as long as the model is loaded). 211 // (as long as the model is loaded).
201 const BookmarkNode* GetParentForNewNodes(); 212 const BookmarkNode* GetParentForNewNodes();
202 213
203 void AddObserver(BookmarkModelObserver* observer); 214 void AddObserver(BookmarkModelObserver* observer);
204 void RemoveObserver(BookmarkModelObserver* observer); 215 void RemoveObserver(BookmarkModelObserver* observer);
205 216
206 // Notifies the observers that an import is about to happen, so they can delay 217 // Notifies the observers that an import is about to happen, so they can delay
207 // any expensive UI updates until it's finished. 218 // any expensive UI updates until it's finished.
208 void BeginImportMode(); 219 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 306 // 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 307 // importing to exclude the newly created folders from showing up in the
297 // combobox of most recently modified folders. 308 // combobox of most recently modified folders.
298 void ResetDateFolderModified(const BookmarkNode* node); 309 void ResetDateFolderModified(const BookmarkNode* node);
299 310
300 void GetBookmarksWithTitlesMatching( 311 void GetBookmarksWithTitlesMatching(
301 const string16& text, 312 const string16& text,
302 size_t max_count, 313 size_t max_count,
303 std::vector<bookmark_utils::TitleMatch>* matches); 314 std::vector<bookmark_utils::TitleMatch>* matches);
304 315
305 Profile* profile() const { return profile_; }
306
307 bool is_root(const BookmarkNode* node) const { return node == &root_; }
sky 2011/07/29 18:08:27 Keep is_root. I'm fine with nuking the others.
tfarina 2011/07/29 18:22:54 Done.
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 316 // 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 317 // any changes to disk. This is only useful during testing to speed up
328 // testing. 318 // testing.
329 void ClearStore(); 319 void ClearStore();
330 320
331 // Returns whether the bookmarks file changed externally. 321 // Returns whether the bookmarks file changed externally.
332 bool file_changed() const { return file_changed_; } 322 bool file_changed() const { return file_changed_; }
333 323
334 // Returns the next node ID. 324 // Returns the next node ID.
335 int64 next_node_id() const { return next_node_id_; } 325 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_; 459 scoped_ptr<BookmarkIndex> index_;
470 460
471 base::WaitableEvent loaded_signal_; 461 base::WaitableEvent loaded_signal_;
472 462
473 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; 463 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_;
474 464
475 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); 465 DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
476 }; 466 };
477 467
478 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ 468 #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