Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / public / browser / android / content_view_core.h
blob1d0a90e7b7258187c30bed3e17a6acac893fd2a4
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_
6 #define CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_
8 #include <jni.h>
10 #include "base/android/scoped_java_ref.h"
11 #include "base/callback.h"
12 #include "base/strings/string16.h"
13 #include "content/common/content_export.h"
14 #include "content/public/browser/readback_types.h"
15 #include "third_party/skia/include/core/SkImageInfo.h"
16 #include "ui/gfx/geometry/rect.h"
18 namespace cc {
19 class Layer;
22 namespace gfx {
23 class Rect;
26 namespace ui {
27 class ViewAndroid;
28 class WindowAndroid;
31 namespace content {
32 class WebContents;
34 // Native side of the ContentViewCore.java, which is the primary way of
35 // communicating with the native Chromium code on Android. This is a
36 // public interface used by native code outside of the content module.
37 class CONTENT_EXPORT ContentViewCore {
38 public:
39 // Returns the existing ContentViewCore for |web_contents|, or nullptr.
40 static ContentViewCore* FromWebContents(WebContents* web_contents);
41 static ContentViewCore* GetNativeContentViewCore(JNIEnv* env, jobject obj);
43 virtual WebContents* GetWebContents() const = 0;
45 // May return null reference.
46 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0;
47 virtual ui::ViewAndroid* GetViewAndroid() const = 0;
48 virtual ui::WindowAndroid* GetWindowAndroid() const = 0;
49 virtual const scoped_refptr<cc::Layer>& GetLayer() const = 0;
50 virtual void ShowPastePopup(int x, int y) = 0;
52 // Request a scaled content readback. The result is passed through the
53 // callback. The boolean parameter indicates whether the readback was a
54 // success or not. The content is passed through the SkBitmap parameter.
55 virtual void GetScaledContentBitmap(
56 float scale,
57 SkColorType color_type,
58 const gfx::Rect& src_rect,
59 ReadbackRequestCallback& result_callback) = 0;
60 virtual float GetDpiScale() const = 0;
61 virtual void PauseOrResumeGeolocation(bool should_pause) = 0;
63 // Text surrounding selection.
64 virtual void RequestTextSurroundingSelection(
65 int max_length,
66 const base::Callback<void(const base::string16& content,
67 int start_offset,
68 int end_offset)>& callback) = 0;
70 protected:
71 virtual ~ContentViewCore() {};
74 }; // namespace content
76 #endif // CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_