summaryrefslogtreecommitdiffstats
path: root/android_webview/native/aw_settings.h
blob: de21024765c6e8598b80b12bc7084192c1897414 (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
// Copyright (c) 2013 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 ANDROID_WEBVIEW_NATIVE_AW_SETTINGS_H_
#define ANDROID_WEBVIEW_NATIVE_AW_SETTINGS_H_

#include <jni.h>

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

namespace android_webview {

class AwRenderViewHostExt;

class AwSettings : public content::WebContentsObserver {
 public:
  AwSettings(JNIEnv* env, jobject obj);
  virtual ~AwSettings();

  // Called from Java.
  void Destroy(JNIEnv* env, jobject obj);
  void ResetScrollAndScaleState(JNIEnv* env, jobject obj);
  void SetEnableFixedLayoutMode(JNIEnv* env, jobject obj, jboolean enabled);
  void SetInitialPageScale(JNIEnv* env, jobject obj, jfloat page_scale_percent);
  void SetTextZoom(JNIEnv* env, jobject obj, jint text_zoom_percent);
  void SetWebContents(JNIEnv* env, jobject obj, jint web_contents);

 private:
  AwRenderViewHostExt* GetAwRenderViewHostExt();
  void UpdateEnableFixedLayoutMode();
  void UpdateInitialPageScale();
  void UpdateTextZoom();

  // WebContentsObserver overrides:
  virtual void RenderViewCreated(
      content::RenderViewHost* render_view_host) OVERRIDE;

  JavaObjectWeakGlobalRef java_ref_;
  bool enable_fixed_layout_;
  float initial_page_scale_percent_;
  int text_zoom_percent_;
};

bool RegisterAwSettings(JNIEnv* env);

}  // namespace android_webview

#endif  // ANDROID_WEBVIEW_NATIVE_AW_SETTINGS_H_