OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/ui/toolbar/tools_menu_button_observer_bridge.h" |
| 6 |
| 7 #include "components/reading_list/ios/reading_list_model.h" |
| 8 #import "ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.h" |
| 9 |
| 10 ToolsMenuButtonObserverBridge::ToolsMenuButtonObserverBridge( |
| 11 ReadingListModel* readingListModel, |
| 12 ToolbarToolsMenuButton* button) |
| 13 : readingListModel_(readingListModel), button_([button retain]) { |
| 14 readingListModel_->AddObserver(this); |
| 15 }; |
| 16 |
| 17 ToolsMenuButtonObserverBridge::~ToolsMenuButtonObserverBridge() { |
| 18 readingListModel_->RemoveObserver(this); |
| 19 } |
| 20 |
| 21 void ToolsMenuButtonObserverBridge::ReadingListModelLoaded( |
| 22 const ReadingListModel* model) { |
| 23 UpdateButtonWithModel(model); |
| 24 } |
| 25 void ToolsMenuButtonObserverBridge::ReadingListDidApplyChanges( |
| 26 ReadingListModel* model) { |
| 27 UpdateButtonWithModel(model); |
| 28 } |
| 29 |
| 30 void ToolsMenuButtonObserverBridge::UpdateButtonWithModel( |
| 31 const ReadingListModel* model) { |
| 32 bool readingListContainsUnreadItems = model->unread_size() > 0; |
| 33 [button_ setReadingListContainsUnreadItems:readingListContainsUnreadItems]; |
| 34 } |
OLD | NEW |