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

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

Issue 8828006: Makes all permanent nodes share the same node class so that visibility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More tweaks Created 9 years 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // Whether the favicon has been loaded. 151 // Whether the favicon has been loaded.
152 bool is_favicon_loaded_; 152 bool is_favicon_loaded_;
153 153
154 // If non-zero, it indicates we're loading the favicon and this is the handle 154 // If non-zero, it indicates we're loading the favicon and this is the handle
155 // from the HistoryService. 155 // from the HistoryService.
156 HistoryService::Handle favicon_load_handle_; 156 HistoryService::Handle favicon_load_handle_;
157 157
158 DISALLOW_COPY_AND_ASSIGN(BookmarkNode); 158 DISALLOW_COPY_AND_ASSIGN(BookmarkNode);
159 }; 159 };
160 160
161 // BookmarkPermanentNode -------------------------------------------------------
162
163 // Node used for the permanent folders (excluding the root).
164 class BookmarkPermanentNode : public BookmarkNode {
noyau (Ping after 24h) 2011/12/09 15:54:35 BookmarkPermanentNode doesn't need to be defined h
sky 2011/12/09 17:57:04 That's problematic because bookmark_bar_node_ is n
165 public:
166 explicit BookmarkPermanentNode(int64 id);
167 virtual ~BookmarkPermanentNode();
168
169 // WARNING: this code is used for other projects. Contact noyau@ for details.
170 void set_visible(bool value) { visible_ = value; }
171
172 // BookmarkNode overrides:
173 virtual bool IsVisible() const OVERRIDE;
174
175 private:
176 bool visible_;
177
178 DISALLOW_COPY_AND_ASSIGN(BookmarkPermanentNode);
179 };
180
161 // BookmarkModel -------------------------------------------------------------- 181 // BookmarkModel --------------------------------------------------------------
162 182
163 // BookmarkModel provides a directed acyclic graph of URLs and folders. 183 // BookmarkModel provides a directed acyclic graph of URLs and folders.
164 // Three graphs are provided for the three entry points: those on the 'bookmarks 184 // Three graphs are provided for the three entry points: those on the 'bookmarks
165 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder. 185 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder.
166 // 186 //
167 // An observer may be attached to observe relevant events. 187 // An observer may be attached to observe relevant events.
168 // 188 //
169 // You should NOT directly create a BookmarkModel, instead go through the 189 // You should NOT directly create a BookmarkModel, instead go through the
170 // Profile. 190 // Profile.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 342
323 // Returns the next node ID. 343 // Returns the next node ID.
324 int64 next_node_id() const { return next_node_id_; } 344 int64 next_node_id() const { return next_node_id_; }
325 345
326 // Returns the object responsible for tracking the set of expanded nodes in 346 // Returns the object responsible for tracking the set of expanded nodes in
327 // the bookmark editor. 347 // the bookmark editor.
328 BookmarkExpandedStateTracker* expanded_state_tracker() { 348 BookmarkExpandedStateTracker* expanded_state_tracker() {
329 return expanded_state_tracker_.get(); 349 return expanded_state_tracker_.get();
330 } 350 }
331 351
332 // Sets whether the mobile folder is visible. This is set by sync. 352 // Sets the visibility of one of the permanent nodes. This is set by sync.
333 void SetMobileFolderVisible(bool value); 353 void SetPermanentNodeVisible(BookmarkNode::Type type, bool value);
334 354
335 private: 355 private:
336 friend class BookmarkCodecTest; 356 friend class BookmarkCodecTest;
337 friend class BookmarkModelTest; 357 friend class BookmarkModelTest;
338 friend class BookmarkStorage; 358 friend class BookmarkStorage;
339 359
340 // Used to order BookmarkNodes by URL. 360 // Used to order BookmarkNodes by URL.
341 class NodeURLComparator { 361 class NodeURLComparator {
342 public: 362 public:
343 bool operator()(const BookmarkNode* n1, const BookmarkNode* n2) const { 363 bool operator()(const BookmarkNode* n1, const BookmarkNode* n2) const {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 bool was_bookmarked); 395 bool was_bookmarked);
376 396
377 // Implementation of GetNodeByID. 397 // Implementation of GetNodeByID.
378 const BookmarkNode* GetNodeByID(const BookmarkNode* node, int64 id) const; 398 const BookmarkNode* GetNodeByID(const BookmarkNode* node, int64 id) const;
379 399
380 // Returns true if the parent and index are valid. 400 // Returns true if the parent and index are valid.
381 bool IsValidIndex(const BookmarkNode* parent, int index, bool allow_end); 401 bool IsValidIndex(const BookmarkNode* parent, int index, bool allow_end);
382 402
383 // Creates one of the possible permanent nodes (bookmark bar node, other node 403 // Creates one of the possible permanent nodes (bookmark bar node, other node
384 // and mobile node) from |type|. 404 // and mobile node) from |type|.
385 BookmarkNode* CreatePermanentNode(BookmarkNode::Type type); 405 BookmarkPermanentNode* CreatePermanentNode(BookmarkNode::Type type);
386 406
387 // Notification that a favicon has finished loading. If we can decode the 407 // Notification that a favicon has finished loading. If we can decode the
388 // favicon, FaviconLoaded is invoked. 408 // favicon, FaviconLoaded is invoked.
389 void OnFaviconDataAvailable(FaviconService::Handle handle, 409 void OnFaviconDataAvailable(FaviconService::Handle handle,
390 history::FaviconData favicon); 410 history::FaviconData favicon);
391 411
392 // Invoked from the node to load the favicon. Requests the favicon from the 412 // Invoked from the node to load the favicon. Requests the favicon from the
393 // favicon service. 413 // favicon service.
394 void LoadFavicon(BookmarkNode* node); 414 void LoadFavicon(BookmarkNode* node);
395 415
(...skipping 28 matching lines...) Expand all
424 bool loaded_; 444 bool loaded_;
425 445
426 // Whether the bookmarks file was changed externally. This is set after 446 // Whether the bookmarks file was changed externally. This is set after
427 // loading is complete and once set the value never changes. 447 // loading is complete and once set the value never changes.
428 bool file_changed_; 448 bool file_changed_;
429 449
430 // The root node. This contains the bookmark bar node and the 'other' node as 450 // The root node. This contains the bookmark bar node and the 'other' node as
431 // children. 451 // children.
432 BookmarkNode root_; 452 BookmarkNode root_;
433 453
434 BookmarkNode* bookmark_bar_node_; 454 BookmarkPermanentNode* bookmark_bar_node_;
435 BookmarkNode* other_node_; 455 BookmarkPermanentNode* other_node_;
436 BookmarkNode* mobile_node_; 456 BookmarkPermanentNode* mobile_node_;
437 457
438 // The maximum ID assigned to the bookmark nodes in the model. 458 // The maximum ID assigned to the bookmark nodes in the model.
439 int64 next_node_id_; 459 int64 next_node_id_;
440 460
441 // The observers. 461 // The observers.
442 ObserverList<BookmarkModelObserver> observers_; 462 ObserverList<BookmarkModelObserver> observers_;
443 463
444 // Set of nodes ordered by URL. This is not a map to avoid copying the 464 // Set of nodes ordered by URL. This is not a map to avoid copying the
445 // urls. 465 // urls.
446 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As 466 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As
(...skipping 11 matching lines...) Expand all
458 scoped_ptr<BookmarkIndex> index_; 478 scoped_ptr<BookmarkIndex> index_;
459 479
460 base::WaitableEvent loaded_signal_; 480 base::WaitableEvent loaded_signal_;
461 481
462 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; 482 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_;
463 483
464 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); 484 DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
465 }; 485 };
466 486
467 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ 487 #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