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

Unified Diff: ios/chrome/browser/ntp_tiles/most_visited_sites_observer_bridge.h

Issue 2791253002: Create an Obj-C bridge for MostVisitedSitesObserver (Closed)
Patch Set: Move files to ios/ 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
Index: ios/chrome/browser/ntp_tiles/most_visited_sites_observer_bridge.h
diff --git a/ios/chrome/browser/ntp_tiles/most_visited_sites_observer_bridge.h b/ios/chrome/browser/ntp_tiles/most_visited_sites_observer_bridge.h
new file mode 100644
index 0000000000000000000000000000000000000000..8d4df0f0ec3a737fa73731f3212bfc4de2283b75
--- /dev/null
+++ b/ios/chrome/browser/ntp_tiles/most_visited_sites_observer_bridge.h
@@ -0,0 +1,47 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_NTP_TILES_MOST_VISITED_SITES_OBSERVER_BRIDGE_H_
+#define IOS_CHROME_BROWSER_NTP_TILES_MOST_VISITED_SITES_OBSERVER_BRIDGE_H_
+
+#import <Foundation/Foundation.h>
+
+#include "base/ios/weak_nsobject.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
+// MostVisitedSitesObserverBridge.
+@protocol MostVisitedSitesObserving<NSObject>
+
+// 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 MostVisitedSitesObserverBridge : public MostVisitedSites::Observer {
+ public:
+ MostVisitedSitesObserverBridge(id<MostVisitedSitesObserving> observer);
+ ~MostVisitedSitesObserverBridge() override;
+
+ void OnMostVisitedURLsAvailable(const NTPTilesVector& most_visited) override;
+ void OnIconMadeAvailable(const GURL& site_url) override;
+
+ private:
+ base::WeakNSProtocol<id<MostVisitedSitesObserving>> observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(MostVisitedSitesObserverBridge);
+};
+
+} // namespace ntp_tiles
+
+#endif // IOS_CHROME_BROWSER_NTP_TILES_MOST_VISITED_SITES_OBSERVER_BRIDGE_H_
« no previous file with comments | « ios/chrome/browser/ntp_tiles/BUILD.gn ('k') | ios/chrome/browser/ntp_tiles/most_visited_sites_observer_bridge.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698