OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ |
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ | 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
20 #include "components/bookmarks/browser/bookmark_client.h" | 20 #include "components/bookmarks/browser/bookmark_client.h" |
21 #include "components/bookmarks/browser/bookmark_node.h" | 21 #include "components/bookmarks/browser/bookmark_node.h" |
22 #include "components/bookmarks/browser/bookmark_service.h" | 22 #include "components/bookmarks/browser/bookmark_service.h" |
23 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 class BookmarkExpandedStateTracker; | 26 class BookmarkExpandedStateTracker; |
27 class BookmarkIndex; | 27 class BookmarkIndex; |
28 class BookmarkModelObserver; | 28 class BookmarkModelObserver; |
29 struct BookmarkMatch; | 29 struct BookmarkMatch; |
30 class ManagedBookmarksTracker; | |
30 class PrefService; | 31 class PrefService; |
31 class ScopedGroupBookmarkActions; | 32 class ScopedGroupBookmarkActions; |
32 | 33 |
33 namespace base { | 34 namespace base { |
34 class FilePath; | 35 class FilePath; |
35 class SequencedTaskRunner; | 36 class SequencedTaskRunner; |
36 } | 37 } |
37 | 38 |
38 namespace bookmarks { | 39 namespace bookmarks { |
39 class BookmarkLoadDetails; | 40 class BookmarkLoadDetails; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 | 89 |
89 // Returns the 'bookmark bar' node. This is NULL until loaded. | 90 // Returns the 'bookmark bar' node. This is NULL until loaded. |
90 const BookmarkNode* bookmark_bar_node() const { return bookmark_bar_node_; } | 91 const BookmarkNode* bookmark_bar_node() const { return bookmark_bar_node_; } |
91 | 92 |
92 // Returns the 'other' node. This is NULL until loaded. | 93 // Returns the 'other' node. This is NULL until loaded. |
93 const BookmarkNode* other_node() const { return other_node_; } | 94 const BookmarkNode* other_node() const { return other_node_; } |
94 | 95 |
95 // Returns the 'mobile' node. This is NULL until loaded. | 96 // Returns the 'mobile' node. This is NULL until loaded. |
96 const BookmarkNode* mobile_node() const { return mobile_node_; } | 97 const BookmarkNode* mobile_node() const { return mobile_node_; } |
97 | 98 |
99 // Returns the 'managed' node. This is NULL until loaded. | |
100 const BookmarkNode* managed_node() const { return managed_node_; } | |
101 | |
98 bool is_root_node(const BookmarkNode* node) const { return node == &root_; } | 102 bool is_root_node(const BookmarkNode* node) const { return node == &root_; } |
99 | 103 |
100 // Returns whether the given |node| is one of the permanent nodes - root node, | 104 // Returns whether the given |node| is one of the permanent nodes - root node, |
101 // 'bookmark bar' node, 'other' node or 'mobile' node. | 105 // 'bookmark bar' node, 'other' node,'mobile' node or 'managed' node. |
102 bool is_permanent_node(const BookmarkNode* node) const { | 106 bool is_permanent_node(const BookmarkNode* node) const { |
103 return node == &root_ || | 107 return node == &root_ || |
104 node == bookmark_bar_node_ || | 108 node == bookmark_bar_node_ || |
105 node == other_node_ || | 109 node == other_node_ || |
106 node == mobile_node_; | 110 node == mobile_node_ || |
111 node == managed_node_; | |
107 } | 112 } |
108 | 113 |
114 // Returns true if |node| belongs to the |managed_node_| tree. Managed nodes | |
115 // are never editable, and managed folders can't get bookmarks added, removed | |
sky
2014/05/30 22:31:37
Do we not allow applying policy changes during run
Joao da Silva
2014/06/01 13:32:07
We do, and the managed bookmarks will update when
| |
116 // or moved. | |
117 bool IsManaged(const BookmarkNode* node) const; | |
sky
2014/05/30 22:31:37
This name is mildly confusing. It sort of implies
Joao da Silva
2014/06/01 13:32:07
Right, naming is hard :-) How about "IsInManagedTr
| |
118 | |
109 // Returns the parent the last node was added to. This never returns NULL | 119 // Returns the parent the last node was added to. This never returns NULL |
110 // (as long as the model is loaded). | 120 // (as long as the model is loaded). |
111 const BookmarkNode* GetParentForNewNodes(); | 121 const BookmarkNode* GetParentForNewNodes(); |
112 | 122 |
113 void AddObserver(BookmarkModelObserver* observer); | 123 void AddObserver(BookmarkModelObserver* observer); |
114 void RemoveObserver(BookmarkModelObserver* observer); | 124 void RemoveObserver(BookmarkModelObserver* observer); |
115 | 125 |
116 // Notifies the observers that an extensive set of changes is about to happen, | 126 // Notifies the observers that an extensive set of changes is about to happen, |
117 // such as during import or sync, so they can delay any expensive UI updates | 127 // such as during import or sync, so they can delay any expensive UI updates |
118 // until it's finished. | 128 // until it's finished. |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 // Whether the initial set of data has been loaded. | 391 // Whether the initial set of data has been loaded. |
382 bool loaded_; | 392 bool loaded_; |
383 | 393 |
384 // The root node. This contains the bookmark bar node, the 'other' node and | 394 // The root node. This contains the bookmark bar node, the 'other' node and |
385 // the mobile node as children. | 395 // the mobile node as children. |
386 BookmarkNode root_; | 396 BookmarkNode root_; |
387 | 397 |
388 BookmarkPermanentNode* bookmark_bar_node_; | 398 BookmarkPermanentNode* bookmark_bar_node_; |
389 BookmarkPermanentNode* other_node_; | 399 BookmarkPermanentNode* other_node_; |
390 BookmarkPermanentNode* mobile_node_; | 400 BookmarkPermanentNode* mobile_node_; |
401 BookmarkPermanentNode* managed_node_; | |
391 | 402 |
392 // The maximum ID assigned to the bookmark nodes in the model. | 403 // The maximum ID assigned to the bookmark nodes in the model. |
393 int64 next_node_id_; | 404 int64 next_node_id_; |
394 | 405 |
395 // The observers. | 406 // The observers. |
396 ObserverList<BookmarkModelObserver> observers_; | 407 ObserverList<BookmarkModelObserver> observers_; |
397 | 408 |
398 // Set of nodes ordered by URL. This is not a map to avoid copying the | 409 // Set of nodes ordered by URL. This is not a map to avoid copying the |
399 // urls. | 410 // urls. |
400 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As | 411 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As |
(...skipping 13 matching lines...) Expand all Loading... | |
414 // True if URLs are stored in the BookmarkIndex in addition to bookmark | 425 // True if URLs are stored in the BookmarkIndex in addition to bookmark |
415 // titles. | 426 // titles. |
416 const bool index_urls_; | 427 const bool index_urls_; |
417 | 428 |
418 base::WaitableEvent loaded_signal_; | 429 base::WaitableEvent loaded_signal_; |
419 | 430 |
420 // See description of IsDoingExtensiveChanges above. | 431 // See description of IsDoingExtensiveChanges above. |
421 int extensive_changes_; | 432 int extensive_changes_; |
422 | 433 |
423 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; | 434 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; |
435 scoped_ptr<ManagedBookmarksTracker> managed_bookmarks_tracker_; | |
424 | 436 |
425 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 437 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
426 }; | 438 }; |
427 | 439 |
428 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ | 440 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ |
OLD | NEW |