1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2013 Intel Corporation. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #ifndef XWALK_RUNTIME_BROWSER_ANDROID_XWALK_CONTENT_H_
7 #define XWALK_RUNTIME_BROWSER_ANDROID_XWALK_CONTENT_H_
12 #include "base/android/jni_helper.h"
13 #include "base/android/scoped_java_ref.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "xwalk/runtime/browser/android/renderer_host/xwalk_render_view_host_ext.h"
17 using base::android::ScopedJavaLocalRef;
26 class XWalkWebContentsDelegate;
27 class XWalkContentsClientBridge;
31 XWalkContent(JNIEnv* env, jobject obj, jobject web_contents_delegate,
32 jobject contents_client_bridge);
35 static XWalkContent* FromID(int render_process_id, int render_view_id);
36 static XWalkContent* FromWebContents(content::WebContents* web_contents);
38 jlong GetWebContents(JNIEnv* env, jobject obj, jobject io_thread_client,
40 void ClearCache(JNIEnv* env, jobject obj, jboolean include_disk_files);
41 ScopedJavaLocalRef<jstring> DevToolsAgentId(JNIEnv* env, jobject obj);
42 void Destroy(JNIEnv* env, jobject obj);
43 ScopedJavaLocalRef<jstring> GetVersion(JNIEnv* env, jobject obj);
44 jint GetRoutingID(JNIEnv* env, jobject obj);
45 base::android::ScopedJavaLocalRef<jbyteArray> GetState(JNIEnv* env,
47 jboolean SetState(JNIEnv* env, jobject obj, jbyteArray state);
49 XWalkRenderViewHostExt* render_view_host_ext() {
50 return render_view_host_ext_.get();
53 XWalkContentsClientBridge* GetContentsClientBridge() {
54 return contents_client_bridge_.get();
57 void SetJsOnlineProperty(JNIEnv* env, jobject obj, jboolean network_up);
58 jboolean SetManifest(JNIEnv* env,
63 // Geolocation API support
64 void ShowGeolocationPrompt(const GURL& origin,
65 const base::Callback<void(bool)>& callback); // NOLINT
66 void HideGeolocationPrompt(const GURL& origin);
67 void InvokeGeolocationCallback(JNIEnv* env,
73 content::WebContents* CreateWebContents(JNIEnv* env, jobject io_thread_client,
76 JavaObjectWeakGlobalRef java_ref_;
77 scoped_ptr<content::WebContents> web_contents_;
78 scoped_ptr<XWalkWebContentsDelegate> web_contents_delegate_;
79 scoped_ptr<XWalkRenderViewHostExt> render_view_host_ext_;
80 scoped_ptr<XWalkContentsClientBridge> contents_client_bridge_;
82 // GURL is supplied by the content layer as requesting frame.
83 // Callback is supplied by the content layer, and is invoked with the result
84 // from the permission prompt.
85 typedef std::pair<const GURL, const base::Callback<void(bool)> > /* NOLINT */ \
87 // The first element in the list is always the currently pending request.
88 std::list<OriginCallback> pending_geolocation_prompts_;
91 bool RegisterXWalkContent(JNIEnv* env);
95 #endif // XWALK_RUNTIME_BROWSER_ANDROID_XWALK_CONTENT_H_