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

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

Issue 1203713002: Limit access to ChromeBookmarkClient to bookmarks code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_bookmark_client
Patch Set: Rebase Created 5 years, 6 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
OLDNEW
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>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, 83 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
84 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner); 84 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner);
85 85
86 // Returns true if the model finished loading. 86 // Returns true if the model finished loading.
87 bool loaded() const { return loaded_; } 87 bool loaded() const { return loaded_; }
88 88
89 // Returns the root node. The 'bookmark bar' node and 'other' node are 89 // Returns the root node. The 'bookmark bar' node and 'other' node are
90 // children of the root node. 90 // children of the root node.
91 const BookmarkNode* root_node() const { return &root_; } 91 const BookmarkNode* root_node() const { return &root_; }
92 92
93 // Returns the 'bookmark bar' node. This is NULL until loaded. 93 // Returns the 'bookmark bar' node. This is null until loaded.
94 const BookmarkNode* bookmark_bar_node() const { return bookmark_bar_node_; } 94 const BookmarkNode* bookmark_bar_node() const { return bookmark_bar_node_; }
95 95
96 // Returns the 'other' node. This is NULL until loaded. 96 // Returns the 'other' node. This is null until loaded.
97 const BookmarkNode* other_node() const { return other_node_; } 97 const BookmarkNode* other_node() const { return other_node_; }
98 98
99 // Returns the 'mobile' node. This is NULL until loaded. 99 // Returns the 'mobile' node. This is null until loaded.
100 const BookmarkNode* mobile_node() const { return mobile_node_; } 100 const BookmarkNode* mobile_node() const { return mobile_node_; }
101 101
102 // The top-level managed bookmarks foled defined by an enterprise policy. This
sky 2015/06/23 22:03:53 I don't think these should be here. These are load
sdefresne 2015/06/23 22:13:05 Were would you recommend putting them? Should I cr
103 // is null until loaded.
104 const BookmarkNode* managed_node() const { return managed_node_; }
105
106 // The top-level supervised bookmarks folder, defined by the custodian of a
107 // supervised user. This is null until loaded.
108 const BookmarkNode* supervised_node() const { return supervised_node_; }
109
102 bool is_root_node(const BookmarkNode* node) const { return node == &root_; } 110 bool is_root_node(const BookmarkNode* node) const { return node == &root_; }
103 111
104 // Returns whether the given |node| is one of the permanent nodes - root node, 112 // Returns whether the given |node| is one of the permanent nodes - root node,
105 // 'bookmark bar' node, 'other' node or 'mobile' node, or one of the root 113 // 'bookmark bar' node, 'other' node or 'mobile' node, or one of the root
106 // nodes supplied by the |client_|. 114 // nodes supplied by the |client_|.
107 bool is_permanent_node(const BookmarkNode* node) const { 115 bool is_permanent_node(const BookmarkNode* node) const {
108 return node && (node == &root_ || node->parent() == &root_); 116 return node && (node == &root_ || node->parent() == &root_);
109 } 117 }
110 118
111 // 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
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 301 }
294 302
295 // Sets the sync transaction version of |node|. 303 // Sets the sync transaction version of |node|.
296 void SetNodeSyncTransactionVersion(const BookmarkNode* node, 304 void SetNodeSyncTransactionVersion(const BookmarkNode* node,
297 int64 sync_transaction_version); 305 int64 sync_transaction_version);
298 306
299 // Notify BookmarkModel that the favicons for |urls| have changed and have to 307 // Notify BookmarkModel that the favicons for |urls| have changed and have to
300 // be refetched. This notification is sent by BookmarkClient. 308 // be refetched. This notification is sent by BookmarkClient.
301 void OnFaviconChanged(const std::set<GURL>& urls); 309 void OnFaviconChanged(const std::set<GURL>& urls);
302 310
303 // Returns the client used by this BookmarkModel. 311 // Returns true if |node| should sync.
sky 2015/06/23 22:03:53 Same comment for all of these. They are policy dec
304 BookmarkClient* client() const { return client_; } 312 bool CanSyncNode(const BookmarkNode* node);
313
314 // Returns true if this node can be edited by the user.
315 // TODO(joaodasilva): the model should check this more aggressively, and
316 // should give the client a means to temporarily disable those checks.
317 // http://crbug.com/49598
318 bool CanBeEditedByUser(const BookmarkNode* node);
319
320 // Returns true if the permanent node |node| should always be visible.
321 bool IsPermanentNodeVisible(const BookmarkPermanentNode* node);
322
323 // Forward the |action| to |client_| to record it. See
324 // BookmarkClient::RecordAction for more information.
325 void RecordAction(const base::UserMetricsAction& action);
305 326
306 private: 327 private:
307 friend class BookmarkCodecTest; 328 friend class BookmarkCodecTest;
308 friend class BookmarkStorage; 329 friend class BookmarkStorage;
309 friend class ScopedGroupBookmarkActions; 330 friend class ScopedGroupBookmarkActions;
310 friend class TestBookmarkClient; 331 friend class TestBookmarkClient;
311 332
312 // Used to order BookmarkNodes by URL. 333 // Used to order BookmarkNodes by URL.
313 class NodeURLComparator { 334 class NodeURLComparator {
314 public: 335 public:
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // Sets the maximum node ID to the given value. 413 // Sets the maximum node ID to the given value.
393 // This is used by BookmarkCodec to report the maximum ID after it's done 414 // This is used by BookmarkCodec to report the maximum ID after it's done
394 // decoding since during decoding codec assigns node IDs. 415 // decoding since during decoding codec assigns node IDs.
395 void set_next_node_id(int64 id) { next_node_id_ = id; } 416 void set_next_node_id(int64 id) { next_node_id_ = id; }
396 417
397 // Creates and returns a new BookmarkLoadDetails. It's up to the caller to 418 // Creates and returns a new BookmarkLoadDetails. It's up to the caller to
398 // delete the returned object. 419 // delete the returned object.
399 scoped_ptr<BookmarkLoadDetails> CreateLoadDetails( 420 scoped_ptr<BookmarkLoadDetails> CreateLoadDetails(
400 const std::string& accept_languages); 421 const std::string& accept_languages);
401 422
423 // Called upon completion of extra nodes initialization.
424 void OnExtraNodeLoaded(BookmarkPermanentNode* managed_node,
425 BookmarkPermanentNode* supervised_node);
426
427 // Returns whether the permanent node is a top-level permanent node.
428 bool IsTopLevelPermanentNode(const BookmarkPermanentNode* node);
429
430 // Returns true if the permanent node can have its title updated.
431 bool CanSetPermanentNodeTitle(const BookmarkNode* node);
432
433 // Returns true if touch icons are preferred over favicons.
434 bool PreferTouchIcon();
435
402 BookmarkClient* const client_; 436 BookmarkClient* const client_;
403 437
404 // Whether the initial set of data has been loaded. 438 // Whether the initial set of data has been loaded.
405 bool loaded_; 439 bool loaded_;
406 440
407 // The root node. This contains the bookmark bar node, the 'other' node and 441 // The root node. This contains the bookmark bar node, the 'other' node and
408 // the mobile node as children. 442 // the mobile node as children.
409 BookmarkNode root_; 443 BookmarkNode root_;
410 444
411 BookmarkPermanentNode* bookmark_bar_node_; 445 BookmarkPermanentNode* bookmark_bar_node_;
412 BookmarkPermanentNode* other_node_; 446 BookmarkPermanentNode* other_node_;
413 BookmarkPermanentNode* mobile_node_; 447 BookmarkPermanentNode* mobile_node_;
448 BookmarkPermanentNode* managed_node_;
449 BookmarkPermanentNode* supervised_node_;
414 450
415 // The maximum ID assigned to the bookmark nodes in the model. 451 // The maximum ID assigned to the bookmark nodes in the model.
416 int64 next_node_id_; 452 int64 next_node_id_;
417 453
418 // The observers. 454 // The observers.
419 base::ObserverList<BookmarkModelObserver> observers_; 455 base::ObserverList<BookmarkModelObserver> observers_;
420 456
421 // Set of nodes ordered by URL. This is not a map to avoid copying the 457 // Set of nodes ordered by URL. This is not a map to avoid copying the
422 // urls. 458 // urls.
423 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As 459 // WARNING: |nodes_ordered_by_url_set_| is accessed on multiple threads. As
(...skipping 18 matching lines...) Expand all
442 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; 478 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_;
443 479
444 std::set<std::string> non_cloned_keys_; 480 std::set<std::string> non_cloned_keys_;
445 481
446 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); 482 DISALLOW_COPY_AND_ASSIGN(BookmarkModel);
447 }; 483 };
448 484
449 } // namespace bookmarks 485 } // namespace bookmarks
450 486
451 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ 487 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698