summaryrefslogtreecommitdiffstats
path: root/content/browser/android/content_settings.h
blob: 3a9128e50344e1296197a45d57f1cef70e7f8dd5 (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
// Copyright (c) 2012 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 CONTENT_BROWSER_ANDROID_CONTENT_SETTINGS_H_
#define CONTENT_BROWSER_ANDROID_CONTENT_SETTINGS_H_

#include <jni.h>

#include "base/android/jni_helper.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/web_contents_observer.h"

namespace content {

class ContentSettings : public WebContentsObserver {
 public:
  ContentSettings(JNIEnv* env, jobject obj,
                  WebContents* contents,
                  bool is_master_mode);

  static bool RegisterContentSettings(JNIEnv* env);

  // Synchronizes the Java settings from native settings.
  void SyncFromNative(JNIEnv* env, jobject obj);
  // Synchronizes the native settings from Java settings.
  void SyncToNative(JNIEnv* env, jobject obj);

 private:
  struct FieldIds;
  // Self-deletes when the underlying WebContents is destroyed.
  virtual ~ContentSettings();

  void SyncFromNativeImpl();
  void SyncToNativeImpl();

  // WebContentsObserver overrides:
  virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
  virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;

  // Determines whether a sync to native should be triggered when a new render
  // view is created.
  bool is_master_mode_;

  // Java field references for accessing the values in the Java object.
  scoped_ptr<FieldIds> field_ids_;

  // The Java counterpart to this class.
  JavaObjectWeakGlobalRef content_settings_;
};

}  // namespace content

#endif  // CONTENT_BROWSER_ANDROID_CONTENT_SETTINGS_H_