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

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

Issue 12550006: Mac: Add a shortcut to open the Apps page from the bookmark bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed failing sync-related tests. Created 7 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // BookmarkNode contains information about a starred entry: title, URL, favicon, 46 // BookmarkNode contains information about a starred entry: title, URL, favicon,
47 // id and type. BookmarkNodes are returned from BookmarkModel. 47 // id and type. BookmarkNodes are returned from BookmarkModel.
48 class BookmarkNode : public ui::TreeNode<BookmarkNode> { 48 class BookmarkNode : public ui::TreeNode<BookmarkNode> {
49 public: 49 public:
50 enum Type { 50 enum Type {
51 URL, 51 URL,
52 FOLDER, 52 FOLDER,
53 BOOKMARK_BAR, 53 BOOKMARK_BAR,
54 OTHER_NODE, 54 OTHER_NODE,
55 MOBILE 55 MOBILE,
56 APPS_NODE
56 }; 57 };
57 58
58 enum FaviconState { 59 enum FaviconState {
59 INVALID_FAVICON, 60 INVALID_FAVICON,
60 LOADING_FAVICON, 61 LOADING_FAVICON,
61 LOADED_FAVICON, 62 LOADED_FAVICON,
62 }; 63 };
63 64
64 // Creates a new node with an id of 0 and |url|. 65 // Creates a new node with an id of 0 and |url|.
65 explicit BookmarkNode(const GURL& url); 66 explicit BookmarkNode(const GURL& url);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // for folders (including the bookmark bar and other folder). 98 // for folders (including the bookmark bar and other folder).
98 const base::Time& date_folder_modified() const { 99 const base::Time& date_folder_modified() const {
99 return date_folder_modified_; 100 return date_folder_modified_;
100 } 101 }
101 void set_date_folder_modified(const base::Time& date) { 102 void set_date_folder_modified(const base::Time& date) {
102 date_folder_modified_ = date; 103 date_folder_modified_ = date;
103 } 104 }
104 105
105 // Convenience for testing if this node represents a folder. A folder is a 106 // Convenience for testing if this node represents a folder. A folder is a
106 // node whose type is not URL. 107 // node whose type is not URL.
107 bool is_folder() const { return type_ != URL; } 108 bool is_folder() const { return type_ != URL && type_ != APPS_NODE; }
108 bool is_url() const { return type_ == URL; } 109 bool is_url() const { return type_ == URL; }
109 110
110 bool is_favicon_loaded() const { return favicon_state_ == LOADED_FAVICON; } 111 bool is_favicon_loaded() const { return favicon_state_ == LOADED_FAVICON; }
111 112
112 // Accessor method for controlling the visibility of a bookmark node/sub-tree. 113 // Accessor method for controlling the visibility of a bookmark node/sub-tree.
113 // Note that visibility is not propagated down the tree hierarchy so if a 114 // Note that visibility is not propagated down the tree hierarchy so if a
114 // parent node is marked as invisible, a child node may return "Visible". This 115 // parent node is marked as invisible, a child node may return "Visible". This
115 // function is primarily useful when traversing the model to generate a UI 116 // function is primarily useful when traversing the model to generate a UI
116 // representation but we may want to suppress some nodes. 117 // representation but we may want to suppress some nodes.
117 virtual bool IsVisible() const; 118 virtual bool IsVisible() const;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 249
249 // Returns the 'bookmark bar' node. This is NULL until loaded. 250 // Returns the 'bookmark bar' node. This is NULL until loaded.
250 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; } 251 const BookmarkNode* bookmark_bar_node() { return bookmark_bar_node_; }
251 252
252 // Returns the 'other' node. This is NULL until loaded. 253 // Returns the 'other' node. This is NULL until loaded.
253 const BookmarkNode* other_node() { return other_node_; } 254 const BookmarkNode* other_node() { return other_node_; }
254 255
255 // Returns the 'mobile' node. This is NULL until loaded. 256 // Returns the 'mobile' node. This is NULL until loaded.
256 const BookmarkNode* mobile_node() { return mobile_node_; } 257 const BookmarkNode* mobile_node() { return mobile_node_; }
257 258
259 // Returns the 'apps' node. This is NULL until loaded or if there is no apps
260 // node.
261 const BookmarkNode* apps_node() { return apps_node_.get(); }
262
258 bool is_root_node(const BookmarkNode* node) const { return node == &root_; } 263 bool is_root_node(const BookmarkNode* node) const { return node == &root_; }
259 264
260 // Returns whether the given |node| is one of the permanent nodes - root node, 265 // Returns whether the given |node| is one of the permanent nodes - root node,
261 // 'bookmark bar' node, 'other' node or 'mobile' node. 266 // 'bookmark bar' node, 'other' node, 'mobile' node or 'apps' node.
262 bool is_permanent_node(const BookmarkNode* node) const { 267 bool is_permanent_node(const BookmarkNode* node) const {
263 return node == &root_ || 268 return node == &root_ ||
264 node == bookmark_bar_node_ || 269 node == bookmark_bar_node_ ||
265 node == other_node_ || 270 node == other_node_ ||
266 node == mobile_node_; 271 node == mobile_node_ ||
272 node == apps_node_.get();
267 } 273 }
268 274
269 Profile* profile() { return profile_; } 275 Profile* profile() { return profile_; }
270 276
271 // Returns the parent the last node was added to. This never returns NULL 277 // Returns the parent the last node was added to. This never returns NULL
272 // (as long as the model is loaded). 278 // (as long as the model is loaded).
273 const BookmarkNode* GetParentForNewNodes(); 279 const BookmarkNode* GetParentForNewNodes();
274 280
275 void AddObserver(BookmarkModelObserver* observer); 281 void AddObserver(BookmarkModelObserver* observer);
276 void RemoveObserver(BookmarkModelObserver* observer); 282 void RemoveObserver(BookmarkModelObserver* observer);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 bool loaded_; 498 bool loaded_;
493 499
494 // The root node. This contains the bookmark bar node and the 'other' node as 500 // The root node. This contains the bookmark bar node and the 'other' node as
495 // children. 501 // children.
496 BookmarkNode root_; 502 BookmarkNode root_;
497 503
498 BookmarkPermanentNode* bookmark_bar_node_; 504 BookmarkPermanentNode* bookmark_bar_node_;
499 BookmarkPermanentNode* other_node_; 505 BookmarkPermanentNode* other_node_;
500 BookmarkPermanentNode* mobile_node_; 506 BookmarkPermanentNode* mobile_node_;
501 507
508 // A special node used to render the bookmark menu but that is not kept under
509 // |root_|, so we have to release it by itself.
510 scoped_ptr<BookmarkPermanentNode> apps_node_;
511
502 // The maximum ID assigned to the bookmark nodes in the model. 512 // The maximum ID assigned to the bookmark nodes in the model.
503 int64 next_node_id_; 513 int64 next_node_id_;
504 514
505 // The observers. 515 // The observers.
506 ObserverList<BookmarkModelObserver> observers_; 516 ObserverList<BookmarkModelObserver> observers_;
507 517
508 // Set of nodes ordered by URL. This is not a map to avoid copying the 518 // Set of nodes ordered by URL. This is not a map to avoid copying the
509 // urls. 519 // urls.
510 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As 520 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As
511 // such, be sure and wrap all usage of it around |url_lock_|. 521 // such, be sure and wrap all usage of it around |url_lock_|.
(...skipping 13 matching lines...) Expand all
525 535
526 // See description of IsDoingExtensiveChanges above. 536 // See description of IsDoingExtensiveChanges above.
527 int extensive_changes_; 537 int extensive_changes_;
528 538
529 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; 539 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_;
530 540
531 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); 541 DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
532 }; 542 };
533 543
534 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ 544 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698