summaryrefslogtreecommitdiffstats
path: root/chrome/browser/android/ntp/ntp_snippets_controller.cc
blob: 496ec56c7c7697bc9dbacc11b00bfdee35f49fe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 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.

#include "chrome/browser/android/ntp/ntp_snippets_controller.h"

#include <jni.h>

#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "chrome/browser/ntp_snippets/ntp_snippets_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_android.h"
#include "components/ntp_snippets/ntp_snippets_service.h"
#include "jni/SnippetsController_jni.h"

using base::android::JavaParamRef;

static void FetchSnippets(JNIEnv* env,
                          const JavaParamRef<jobject>& obj,
                          const JavaParamRef<jobject>& jprofile) {
  Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile);
  if (profile) {
    ntp_snippets::NTPSnippetsService* ntp_snippets_service =
        NTPSnippetsServiceFactory::GetForProfile(profile);
    ntp_snippets_service->FetchSnippets();
  }
}

// static
bool NTPSnippetsController::Register(JNIEnv* env) {
  return RegisterNativesImpl(env);
}