Chromium Code Reviews| Index: components/ntp_tiles/ios/most_visited_sites_bridge_observer.h |
| diff --git a/components/ntp_tiles/ios/most_visited_sites_bridge_observer.h b/components/ntp_tiles/ios/most_visited_sites_bridge_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c896e401900d62af2621380f6947205066716a3e |
| --- /dev/null |
| +++ b/components/ntp_tiles/ios/most_visited_sites_bridge_observer.h |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
|
sdefresne
2017/04/03 14:25:49
I think this file should be named after the main c
gambard
2017/04/03 15:17:36
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_NTP_TILES_IOS_MOST_VISITED_SITES_BRIDGE_OBSERVER_H_ |
| +#define COMPONENTS_NTP_TILES_IOS_MOST_VISITED_SITES_BRIDGE_OBSERVER_H_ |
| + |
| +#import <Foundation/Foundation.h> |
| + |
| +#include "components/ntp_tiles/most_visited_sites.h" |
| + |
| +// Observes MostVisitedSites events from Objective-C. To use as a |
| +// ntp_tiles::MostVisitedSites::Observer, wrap in a MostVisitedSitesBridge. |
| +@protocol MostVisitedSitesObserver |
|
sdefresne
2017/04/03 14:25:49
marq & rohitrao recommendation regarding Objective
gambard
2017/04/03 15:17:36
Done.
|
| + |
| +// Invoked by ntp_tiles::MostVisitedSites::Observer::OnMostVisitedURLsAvailable. |
| +- (void)onMostVisitedURLsAvailable: |
| + (const ntp_tiles::NTPTilesVector&)mostVisited; |
| + |
| +// Invoked by ntp_tiles::MostVisitedSites::Observer::OnIconMadeAvailable. |
| +- (void)onIconMadeAvailable:(const GURL&)siteURL; |
| + |
| +@end |
| + |
| +namespace ntp_tiles { |
| + |
| +// Observer for the MostVisitedSites that translates all the callbacks to |
| +// Objective-C calls. |
| +class MostVisitedSitesBridge : public MostVisitedSites::Observer { |
|
sdefresne
2017/04/03 14:25:49
I would call this MostVisitedSitesObserverBridge.
gambard
2017/04/03 15:17:37
Done.
|
| + public: |
| + MostVisitedSitesBridge(id<MostVisitedSitesObserver> observer); |
| + |
| + void OnMostVisitedURLsAvailable(const NTPTilesVector& most_visited) override; |
| + void OnIconMadeAvailable(const GURL& site_url) override; |
| + |
| + private: |
| + __unsafe_unretained id<MostVisitedSitesObserver> observer_; |
|
sdefresne
2017/04/03 14:25:49
I think we should avoid using __unsafe_unretained
gambard
2017/04/03 15:17:36
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(MostVisitedSitesBridge); |
| +}; |
| + |
| +} // namespace ntp_tiles |
| + |
| +#endif // COMPONENTS_NTP_TILES_IOS_MOST_VISITED_SITES_BRIDGE_OBSERVER_H_ |