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

Unified Diff: chrome/browser/android/ntp_snippets_bridge.h

Issue 1677073002: Fetch snippets from ChromeReader and show them on the NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 years, 10 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: chrome/browser/android/ntp_snippets_bridge.h
diff --git a/chrome/browser/android/ntp_snippets_bridge.h b/chrome/browser/android/ntp_snippets_bridge.h
new file mode 100644
index 0000000000000000000000000000000000000000..398e0d9f6c5b440c1d2d097c1c3617c3b3d3baed
--- /dev/null
+++ b/chrome/browser/android/ntp_snippets_bridge.h
@@ -0,0 +1,44 @@
+// Copyright 2016 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 CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_
+#define CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_
+
+#include <jni.h>
+
+#include "base/android/scoped_java_ref.h"
+#include "base/scoped_observer.h"
+#include "components/ntp_snippets/ntp_snippets_service.h"
+
+// The C++ counterpart to NTPSnippetsBridge.java. Enables Java code to access
+// the list of snippets to show on the NTP
+class NTPSnippetsBridge : public ntp_snippets::NTPSnippetsServiceObserver {
+ public:
+ explicit NTPSnippetsBridge(JNIEnv* env,
+ jobject j_profile,
+ jobject j_observer);
+ void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
+
+ static bool Register(JNIEnv* env);
+
+ private:
+ ~NTPSnippetsBridge();
+
+ // NTPSnippetsServiceObserver overrides
+ void NTPSnippetsServiceLoaded(
+ ntp_snippets::NTPSnippetsService* service) override;
+ void NTPSnippetsServiceShutdown(
+ ntp_snippets::NTPSnippetsService* service) override;
+
+ ntp_snippets::NTPSnippetsService* ntp_snippets_service_;
+
+ base::android::ScopedJavaGlobalRef<jobject> observer_;
+ ScopedObserver<ntp_snippets::NTPSnippetsService,
+ ntp_snippets::NTPSnippetsServiceObserver>
+ snippet_service_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge);
+};
+
+#endif // CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_

Powered by Google App Engine
This is Rietveld 408576698