content_view_core.h revision 1320f92c476a1ad9d19dba2a48c72b75566198e9
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. 4 5#ifndef CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_ 6#define CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_ 7 8#include <jni.h> 9 10#include "base/android/scoped_java_ref.h" 11#include "base/callback.h" 12#include "content/common/content_export.h" 13#include "content/public/browser/navigation_controller.h" 14#include "third_party/skia/include/core/SkImageInfo.h" 15#include "ui/gfx/rect.h" 16 17class SkBitmap; 18 19namespace cc { 20class Layer; 21} 22 23namespace gfx { 24class Size; 25class SizeF; 26class Vector2dF; 27} 28 29namespace ui { 30class ViewAndroid; 31class WindowAndroid; 32} 33 34namespace content { 35class WebContents; 36 37// Native side of the ContentViewCore.java, which is the primary way of 38// communicating with the native Chromium code on Android. This is a 39// public interface used by native code outside of the content module. 40class CONTENT_EXPORT ContentViewCore { 41 public: 42 // Returns the existing ContentViewCore for |web_contents|, or NULL. 43 static ContentViewCore* FromWebContents(WebContents* web_contents); 44 static ContentViewCore* GetNativeContentViewCore(JNIEnv* env, jobject obj); 45 46 virtual WebContents* GetWebContents() const = 0; 47 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; 48 virtual ui::ViewAndroid* GetViewAndroid() const = 0; 49 virtual ui::WindowAndroid* GetWindowAndroid() const = 0; 50 virtual scoped_refptr<cc::Layer> GetLayer() const = 0; 51 virtual void ShowPastePopup(int x, int y) = 0; 52 53 // Request a scaled content readback. The result is passed through the 54 // callback. The boolean parameter indicates whether the readback was a 55 // success or not. The content is passed through the SkBitmap parameter. 56 virtual void GetScaledContentBitmap( 57 float scale, 58 SkColorType color_type, 59 gfx::Rect src_rect, 60 const base::Callback<void(bool, const SkBitmap&)>& result_callback) = 0; 61 virtual float GetDpiScale() const = 0; 62 virtual void PauseOrResumeGeolocation(bool should_pause) = 0; 63 64 // Observer callback for frame metadata updates. 65 typedef base::Callback<void( 66 const gfx::SizeF& content_size, 67 const gfx::Vector2dF& scroll_offset, 68 float page_scale_factor)> UpdateFrameInfoCallback; 69 70 // Text surrounding selection. 71 virtual void RequestTextSurroundingSelection( 72 int max_length, 73 const base::Callback<void(const base::string16& content, 74 int start_offset, 75 int end_offset)>& callback) = 0; 76 77 protected: 78 virtual ~ContentViewCore() {}; 79}; 80 81}; // namespace content 82 83#endif // CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_ 84