| OLD | NEW |
| 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 Loading... |
| 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 { |
| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 Loading... |
| 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_ |
| OLD | NEW |