Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Unified Diff: components/ntp_tiles/ios/most_visited_sites_bridge_observer.h

Issue 2791253002: Create an Obj-C bridge for MostVisitedSitesObserver (Closed)
Patch Set: Fix BUILD.gn Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_tiles/ios/BUILD.gn ('k') | components/ntp_tiles/ios/most_visited_sites_bridge_observer.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « components/ntp_tiles/ios/BUILD.gn ('k') | components/ntp_tiles/ios/most_visited_sites_bridge_observer.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698