content_view_core.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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 15class SkBitmap; 16 17namespace cc { 18class Layer; 19} 20 21namespace gfx { 22class Rect; 23class Size; 24class SizeF; 25class Vector2dF; 26} 27 28namespace ui { 29class ViewAndroid; 30class WindowAndroid; 31} 32 33namespace content { 34class WebContents; 35 36// Native side of the ContentViewCore.java, which is the primary way of 37// communicating with the native Chromium code on Android. This is a 38// public interface used by native code outside of the content module. 39class CONTENT_EXPORT ContentViewCore { 40 public: 41 // Returns the existing ContentViewCore for |web_contents|, or NULL. 42 static ContentViewCore* FromWebContents(WebContents* web_contents); 43 static ContentViewCore* GetNativeContentViewCore(JNIEnv* env, jobject obj); 44 45 virtual WebContents* GetWebContents() const = 0; 46 virtual base::android::ScopedJavaLocalRef<jobject> GetJavaObject() = 0; 47 virtual ui::ViewAndroid* GetViewAndroid() const = 0; 48 virtual ui::WindowAndroid* GetWindowAndroid() const = 0; 49 virtual scoped_refptr<cc::Layer> GetLayer() const = 0; 50 virtual void LoadUrl(NavigationController::LoadURLParams& params) = 0; 51 virtual jint GetCurrentRenderProcessId(JNIEnv* env, jobject obj) = 0; 52 virtual void ShowPastePopup(int x, int y) = 0; 53 54 // Request a scaled content readback. The result is passed through the 55 // callback. The boolean parameter indicates whether the readback was a 56 // success or not. The content is passed through the SkBitmap parameter. 57 // |out_size| is returned with the size of the content. 58 virtual void GetScaledContentBitmap( 59 float scale, 60 gfx::Size* out_size, 61 const base::Callback<void(bool, const SkBitmap&)>& result_callback) = 0; 62 virtual float GetDpiScale() const = 0; 63 virtual void RequestContentClipping(const gfx::Rect& clipping, 64 const gfx::Size& content_size) = 0; 65 virtual void PauseVideo() = 0; 66 virtual void PauseOrResumeGeolocation(bool should_pause) = 0; 67 68 // Observer callback for frame metadata updates. 69 typedef base::Callback<void( 70 const gfx::SizeF& content_size, 71 const gfx::Vector2dF& scroll_offset, 72 float page_scale_factor)> UpdateFrameInfoCallback; 73 74 protected: 75 virtual ~ContentViewCore() {}; 76}; 77 78}; // namespace content 79 80#endif // CONTENT_PUBLIC_BROWSER_ANDROID_CONTENT_VIEW_CORE_H_ 81