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

Unified Diff: chrome/browser/android/download/items/offline_content_aggregator_factory_android.cc

Issue 2729983002: Attaches OfflineContentAggregator to Profile (Closed)
Patch Set: Created 3 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/download/items/offline_content_aggregator_factory_android.cc
diff --git a/chrome/browser/android/download/items/offline_content_aggregator_factory_android.cc b/chrome/browser/android/download/items/offline_content_aggregator_factory_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..50ef4dd001d901fe68059fa663584bf64ea18539
--- /dev/null
+++ b/chrome/browser/android/download/items/offline_content_aggregator_factory_android.cc
@@ -0,0 +1,38 @@
+// 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.
+
+#include "chrome/browser/android/download/items/offline_content_aggregator_factory_android.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/scoped_java_ref.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_android.h"
+#include "components/offline_items_collection/content/offline_content_aggregator_factory.h"
+#include "components/offline_items_collection/core/android/offline_content_aggregator_bridge.h"
+#include "components/offline_items_collection/core/offline_content_aggregator.h"
+#include "jni/OfflineContentAggregatorFactory_jni.h"
+
+using base::android::JavaParamRef;
+
+namespace content {
+class BrowserContext;
+} // namespace content
+
+// Takes a Java Profile and returns a Java OfflineContentAggregatorBridge.
+static base::android::ScopedJavaLocalRef<jobject>
+GetOfflineContentAggregatorForProfile(JNIEnv* env,
+ const JavaParamRef<jclass>& clazz,
+ const JavaParamRef<jobject>& jprofile) {
+ Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
+ DCHECK(profile);
+ offline_items_collection::OfflineContentAggregator* aggregator =
+ offline_items_collection::OfflineContentAggregatorFactory::GetInstance()
+ ->GetForBrowserContext(profile);
+ return offline_items_collection::android::OfflineContentAggregatorBridge::
+ GetBridgeForOfflineContentAggregator(aggregator);
+}
+
+bool RegisterOfflineContentAggregatorFactoryJni(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}

Powered by Google App Engine
This is Rietveld 408576698