| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 #ifndef IOS_CHROME_BROWSER_NTP_TILES_MOST_VISITED_SITES_OBSERVER_BRIDGE_H_ |
| 6 #define IOS_CHROME_BROWSER_NTP_TILES_MOST_VISITED_SITES_OBSERVER_BRIDGE_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 |
| 10 #include "base/ios/weak_nsobject.h" |
| 11 #include "components/ntp_tiles/most_visited_sites.h" |
| 12 |
| 13 // Observes MostVisitedSites events from Objective-C. To use as a |
| 14 // ntp_tiles::MostVisitedSites::Observer, wrap in a |
| 15 // MostVisitedSitesObserverBridge. |
| 16 @protocol MostVisitedSitesObserving<NSObject> |
| 17 |
| 18 // Invoked by ntp_tiles::MostVisitedSites::Observer::OnMostVisitedURLsAvailable. |
| 19 - (void)onMostVisitedURLsAvailable: |
| 20 (const ntp_tiles::NTPTilesVector&)mostVisited; |
| 21 |
| 22 // Invoked by ntp_tiles::MostVisitedSites::Observer::OnIconMadeAvailable. |
| 23 - (void)onIconMadeAvailable:(const GURL&)siteURL; |
| 24 |
| 25 @end |
| 26 |
| 27 namespace ntp_tiles { |
| 28 |
| 29 // Observer for the MostVisitedSites that translates all the callbacks to |
| 30 // Objective-C calls. |
| 31 class MostVisitedSitesObserverBridge : public MostVisitedSites::Observer { |
| 32 public: |
| 33 MostVisitedSitesObserverBridge(id<MostVisitedSitesObserving> observer); |
| 34 ~MostVisitedSitesObserverBridge() override; |
| 35 |
| 36 void OnMostVisitedURLsAvailable(const NTPTilesVector& most_visited) override; |
| 37 void OnIconMadeAvailable(const GURL& site_url) override; |
| 38 |
| 39 private: |
| 40 base::WeakNSProtocol<id<MostVisitedSitesObserving>> observer_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(MostVisitedSitesObserverBridge); |
| 43 }; |
| 44 |
| 45 } // namespace ntp_tiles |
| 46 |
| 47 #endif // IOS_CHROME_BROWSER_NTP_TILES_MOST_VISITED_SITES_OBSERVER_BRIDGE_H_ |
| OLD | NEW |