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 | |
113 // BookmarkNode overrides: | 111 // BookmarkNode overrides: |
114 virtual bool IsVisible() const OVERRIDE; | 112 virtual bool IsVisible() const OVERRIDE; |
115 | 113 |
116 private: | 114 private: |
117 bool visible_; | 115 bool visible_; |
118 | 116 |
119 DISALLOW_COPY_AND_ASSIGN(MobileNode); | 117 DISALLOW_COPY_AND_ASSIGN(MobileNode); |
120 }; | 118 }; |
121 | 119 |
122 MobileNode::MobileNode(int64 id) | 120 MobileNode::MobileNode(int64 id) |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 return; | 539 return; |
542 | 540 |
543 index_->GetBookmarksWithTitlesMatching(text, max_count, matches); | 541 index_->GetBookmarksWithTitlesMatching(text, max_count, matches); |
544 } | 542 } |
545 | 543 |
546 void BookmarkModel::ClearStore() { | 544 void BookmarkModel::ClearStore() { |
547 registrar_.RemoveAll(); | 545 registrar_.RemoveAll(); |
548 store_ = NULL; | 546 store_ = NULL; |
549 } | 547 } |
550 | 548 |
551 void BookmarkModel::SetMobileFolderVisible(bool value) { | |
552 DCHECK(loaded_); | |
553 static_cast<MobileNode*>(mobile_node_)->set_visible(value); | |
554 } | |
555 | |
556 bool BookmarkModel::IsBookmarkedNoLock(const GURL& url) { | 549 bool BookmarkModel::IsBookmarkedNoLock(const GURL& url) { |
557 BookmarkNode tmp_node(url); | 550 BookmarkNode tmp_node(url); |
558 return (nodes_ordered_by_url_set_.find(&tmp_node) != | 551 return (nodes_ordered_by_url_set_.find(&tmp_node) != |
559 nodes_ordered_by_url_set_.end()); | 552 nodes_ordered_by_url_set_.end()); |
560 } | 553 } |
561 | 554 |
562 void BookmarkModel::RemoveNode(BookmarkNode* node, | 555 void BookmarkModel::RemoveNode(BookmarkNode* node, |
563 std::set<GURL>* removed_urls) { | 556 std::set<GURL>* removed_urls) { |
564 if (!loaded_ || !node || is_permanent_node(node)) { | 557 if (!loaded_ || !node || is_permanent_node(node)) { |
565 NOTREACHED(); | 558 NOTREACHED(); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 return next_node_id_++; | 848 return next_node_id_++; |
856 } | 849 } |
857 | 850 |
858 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { | 851 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { |
859 BookmarkNode* bb_node = CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 852 BookmarkNode* bb_node = CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
860 BookmarkNode* other_node = CreatePermanentNode(BookmarkNode::OTHER_NODE); | 853 BookmarkNode* other_node = CreatePermanentNode(BookmarkNode::OTHER_NODE); |
861 BookmarkNode* mobile_node = CreatePermanentNode(BookmarkNode::MOBILE); | 854 BookmarkNode* mobile_node = CreatePermanentNode(BookmarkNode::MOBILE); |
862 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, | 855 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, |
863 new BookmarkIndex(profile_), next_node_id_); | 856 new BookmarkIndex(profile_), next_node_id_); |
864 } | 857 } |
OLD | NEW |