| 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 #include "components/bookmarks/browser/bookmark_model.h" | 5 #include "components/bookmarks/browser/bookmark_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 int index, | 100 int index, |
| 101 std::unique_ptr<BookmarkNode> node) override {} | 101 std::unique_ptr<BookmarkNode> node) override {} |
| 102 | 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(EmptyUndoDelegate); | 103 DISALLOW_COPY_AND_ASSIGN(EmptyUndoDelegate); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace | 106 } // namespace |
| 107 | 107 |
| 108 // BookmarkModel -------------------------------------------------------------- | 108 // BookmarkModel -------------------------------------------------------------- |
| 109 | 109 |
| 110 BookmarkModel::BookmarkModel(std::unique_ptr<BookmarkClient> client) | 110 BookmarkModel::BookmarkModel( |
| 111 std::unique_ptr<BookmarkClient> client, |
| 112 std::unique_ptr<offline_pages::ExternalListener> offline_page_listener) |
| 111 : client_(std::move(client)), | 113 : client_(std::move(client)), |
| 114 offline_page_listener_(std::move(offline_page_listener)), |
| 112 loaded_(false), | 115 loaded_(false), |
| 113 root_(GURL()), | 116 root_(GURL()), |
| 114 bookmark_bar_node_(NULL), | 117 bookmark_bar_node_(NULL), |
| 115 other_node_(NULL), | 118 other_node_(NULL), |
| 116 mobile_node_(NULL), | 119 mobile_node_(NULL), |
| 117 next_node_id_(1), | 120 next_node_id_(1), |
| 118 observers_( | 121 observers_( |
| 119 base::ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY), | 122 base::ObserverList<BookmarkModelObserver>::NOTIFY_EXISTING_ONLY), |
| 120 loaded_signal_(base::WaitableEvent::ResetPolicy::MANUAL, | 123 loaded_signal_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 121 base::WaitableEvent::InitialState::NOT_SIGNALED), | 124 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 122 extensive_changes_(0), | 125 extensive_changes_(0), |
| 123 undo_delegate_(nullptr), | 126 undo_delegate_(nullptr), |
| 124 empty_undo_delegate_(new EmptyUndoDelegate) { | 127 empty_undo_delegate_(new EmptyUndoDelegate) { |
| 125 DCHECK(client_); | 128 DCHECK(client_); |
| 129 DCHECK(offline_page_listener_); |
| 126 client_->Init(this); | 130 client_->Init(this); |
| 127 } | 131 } |
| 128 | 132 |
| 129 BookmarkModel::~BookmarkModel() { | 133 BookmarkModel::~BookmarkModel() { |
| 130 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, | 134 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, |
| 131 BookmarkModelBeingDeleted(this)); | 135 BookmarkModelBeingDeleted(this)); |
| 132 | 136 |
| 133 if (store_.get()) { | 137 if (store_.get()) { |
| 134 // The store maintains a reference back to us. We need to tell it we're gone | 138 // The store maintains a reference back to us. We need to tell it we're gone |
| 135 // so that it doesn't try and invoke a method back on us again. | 139 // so that it doesn't try and invoke a method back on us again. |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 undo_delegate_ = undo_delegate; | 1109 undo_delegate_ = undo_delegate; |
| 1106 if (undo_delegate_) | 1110 if (undo_delegate_) |
| 1107 undo_delegate_->SetUndoProvider(this); | 1111 undo_delegate_->SetUndoProvider(this); |
| 1108 } | 1112 } |
| 1109 | 1113 |
| 1110 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const { | 1114 BookmarkUndoDelegate* BookmarkModel::undo_delegate() const { |
| 1111 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get(); | 1115 return undo_delegate_ ? undo_delegate_ : empty_undo_delegate_.get(); |
| 1112 } | 1116 } |
| 1113 | 1117 |
| 1114 } // namespace bookmarks | 1118 } // namespace bookmarks |
| OLD | NEW |