summaryrefslogtreecommitdiffstats
path: root/chrome/browser/supervised_user/supervised_user_content_provider_android.h
blob: d1b6431a52b328f39c6aa7ea98fd3851c13fef33 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2015 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_SUPERVISED_USER_SUPERVISED_USER_CONTENT_PROVIDER_ANDROID_H_
#define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_CONTENT_PROVIDER_ANDROID_H_

#include <jni.h>
#include "base/android/scoped_java_ref.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/supervised_user/supervised_user_url_filter.h"

class SupervisedUserService;

class SupervisedUserContentProvider {
 public:
  SupervisedUserContentProvider(
      JNIEnv* env,
      const base::android::JavaParamRef<jobject>& caller);
  virtual ~SupervisedUserContentProvider();

  void ShouldProceed(
      JNIEnv* env,
      const base::android::JavaParamRef<jobject>& caller,
      const base::android::JavaParamRef<jobject>& query_result_jobj,
      const base::android::JavaParamRef<jstring>& url);
  void RequestInsert(
      JNIEnv* env,
      const base::android::JavaParamRef<jobject>& caller,
      const base::android::JavaParamRef<jobject>& insert_result_jobj,
      const base::android::JavaParamRef<jstring>& url);

  void SetFilterForTesting(JNIEnv* env, jobject caller);

  static bool Register(JNIEnv* env);

 private:
  void OnQueryComplete(
      base::android::ScopedJavaGlobalRef<jobject> query_reply_jobj,
      SupervisedUserURLFilter::FilteringBehavior behavior,
      SupervisedUserURLFilter::FilteringBehaviorReason reason,
      bool /* uncertain */);
  void OnInsertRequestSendComplete(
      base::android::ScopedJavaGlobalRef<jobject> insert_reply_jobj,
      bool sent_ok);
  Profile* profile_;
  base::android::ScopedJavaGlobalRef<jobject> java_content_provider_;

  base::WeakPtrFactory<SupervisedUserContentProvider> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(SupervisedUserContentProvider);
};

#endif  // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_CONTENT_PROVIDER_ANDROID_H_