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 #include "chrome/browser/bookmarks/bookmark_model.h" | 5 #include "chrome/browser/bookmarks/bookmark_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 // MobileNode ------------------------------------------------------------------ | 102 // MobileNode ------------------------------------------------------------------ |
103 | 103 |
104 // The visibility of the mobile node changes based on sync state, requiring a | 104 // The visibility of the mobile node changes based on sync state, requiring a |
105 // special subclass. | 105 // special subclass. |
106 class MobileNode : public BookmarkNode { | 106 class MobileNode : public BookmarkNode { |
107 public: | 107 public: |
108 explicit MobileNode(int64 id); | 108 explicit MobileNode(int64 id); |
109 virtual ~MobileNode(); | 109 virtual ~MobileNode(); |
110 | 110 |
| 111 void set_visible(bool value) { visible_ = value; } |
| 112 |
111 // BookmarkNode overrides: | 113 // BookmarkNode overrides: |
112 virtual bool IsVisible() const OVERRIDE; | 114 virtual bool IsVisible() const OVERRIDE; |
113 | 115 |
114 private: | 116 private: |
115 bool visible_; | 117 bool visible_; |
116 | 118 |
117 DISALLOW_COPY_AND_ASSIGN(MobileNode); | 119 DISALLOW_COPY_AND_ASSIGN(MobileNode); |
118 }; | 120 }; |
119 | 121 |
120 MobileNode::MobileNode(int64 id) | 122 MobileNode::MobileNode(int64 id) |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 return; | 541 return; |
540 | 542 |
541 index_->GetBookmarksWithTitlesMatching(text, max_count, matches); | 543 index_->GetBookmarksWithTitlesMatching(text, max_count, matches); |
542 } | 544 } |
543 | 545 |
544 void BookmarkModel::ClearStore() { | 546 void BookmarkModel::ClearStore() { |
545 registrar_.RemoveAll(); | 547 registrar_.RemoveAll(); |
546 store_ = NULL; | 548 store_ = NULL; |
547 } | 549 } |
548 | 550 |
| 551 void BookmarkModel::SetMobileFolderVisible(bool value) { |
| 552 DCHECK(loaded_); |
| 553 static_cast<MobileNode*>(mobile_node_)->set_visible(value); |
| 554 } |
| 555 |
549 bool BookmarkModel::IsBookmarkedNoLock(const GURL& url) { | 556 bool BookmarkModel::IsBookmarkedNoLock(const GURL& url) { |
550 BookmarkNode tmp_node(url); | 557 BookmarkNode tmp_node(url); |
551 return (nodes_ordered_by_url_set_.find(&tmp_node) != | 558 return (nodes_ordered_by_url_set_.find(&tmp_node) != |
552 nodes_ordered_by_url_set_.end()); | 559 nodes_ordered_by_url_set_.end()); |
553 } | 560 } |
554 | 561 |
555 void BookmarkModel::RemoveNode(BookmarkNode* node, | 562 void BookmarkModel::RemoveNode(BookmarkNode* node, |
556 std::set<GURL>* removed_urls) { | 563 std::set<GURL>* removed_urls) { |
557 if (!loaded_ || !node || is_permanent_node(node)) { | 564 if (!loaded_ || !node || is_permanent_node(node)) { |
558 NOTREACHED(); | 565 NOTREACHED(); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 return next_node_id_++; | 855 return next_node_id_++; |
849 } | 856 } |
850 | 857 |
851 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { | 858 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { |
852 BookmarkNode* bb_node = CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 859 BookmarkNode* bb_node = CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
853 BookmarkNode* other_node = CreatePermanentNode(BookmarkNode::OTHER_NODE); | 860 BookmarkNode* other_node = CreatePermanentNode(BookmarkNode::OTHER_NODE); |
854 BookmarkNode* mobile_node = CreatePermanentNode(BookmarkNode::MOBILE); | 861 BookmarkNode* mobile_node = CreatePermanentNode(BookmarkNode::MOBILE); |
855 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, | 862 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, |
856 new BookmarkIndex(profile_), next_node_id_); | 863 new BookmarkIndex(profile_), next_node_id_); |
857 } | 864 } |
OLD | NEW |