1 // Copyright 2013 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_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_ANDROID_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_ANDROID_H_ 7 8 #include <jni.h> 9 10 #include "base/android/scoped_java_ref.h" 11 #include "base/basictypes.h" 12 #include "base/compiler_specific.h" 13 #include "content/common/content_export.h" 14 15 namespace content { 16 17 class NavigationController; 18 19 // Android wrapper around NavigationController that provides safer passage 20 // from java and back to native and provides java with a means of communicating 21 // with its native counterpart. 22 class CONTENT_EXPORT NavigationControllerAndroid { 23 public: 24 static bool Register(JNIEnv* env); 25 26 explicit NavigationControllerAndroid( 27 NavigationController* navigation_controller); 28 ~NavigationControllerAndroid(); 29 navigation_controller()30 NavigationController* navigation_controller() const { 31 return navigation_controller_; 32 } 33 34 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); 35 36 jboolean CanGoBack(JNIEnv* env, jobject obj); 37 jboolean CanGoForward(JNIEnv* env, jobject obj); 38 jboolean CanGoToOffset(JNIEnv* env, jobject obj, jint offset); 39 void GoBack(JNIEnv* env, jobject obj); 40 void GoForward(JNIEnv* env, jobject obj); 41 void GoToOffset(JNIEnv* env, jobject obj, jint offset); 42 void LoadIfNecessary(JNIEnv* env, jobject obj); 43 void ContinuePendingReload(JNIEnv* env, jobject obj); 44 void Reload(JNIEnv* env, jobject obj, jboolean check_for_repost); 45 void ReloadIgnoringCache(JNIEnv* env, jobject obj, jboolean check_for_repost); 46 void RequestRestoreLoad(JNIEnv* env, jobject obj); 47 void CancelPendingReload(JNIEnv* env, jobject obj); 48 void GoToNavigationIndex(JNIEnv* env, jobject obj, jint index); 49 void LoadUrl(JNIEnv* env, 50 jobject obj, 51 jstring url, 52 jint load_url_type, 53 jint transition_type, 54 jstring j_referrer_url, 55 jint referrer_policy, 56 jint ua_override_option, 57 jstring extra_headers, 58 jbyteArray post_data, 59 jstring base_url_for_data_url, 60 jstring virtual_url_for_data_url, 61 jboolean can_load_local_resources, 62 jboolean is_renderer_initiated); 63 void ClearSslPreferences(JNIEnv* env, jobject /* obj */); 64 bool GetUseDesktopUserAgent(JNIEnv* env, jobject /* obj */); 65 void SetUseDesktopUserAgent(JNIEnv* env, 66 jobject /* obj */, 67 jboolean state, 68 jboolean reload_on_state_change); 69 base::android::ScopedJavaLocalRef<jobject> GetPendingEntry(JNIEnv* env, 70 jobject /* obj */); 71 int GetNavigationHistory(JNIEnv* env, jobject obj, jobject history); 72 void GetDirectedNavigationHistory(JNIEnv* env, 73 jobject obj, 74 jobject history, 75 jboolean is_forward, 76 jint max_entries); 77 base::android::ScopedJavaLocalRef<jstring> 78 GetOriginalUrlForVisibleNavigationEntry(JNIEnv* env, jobject obj); 79 void ClearHistory(JNIEnv* env, jobject obj); 80 81 private: 82 NavigationController* navigation_controller_; 83 base::android::ScopedJavaGlobalRef<jobject> obj_; 84 85 DISALLOW_COPY_AND_ASSIGN(NavigationControllerAndroid); 86 }; 87 88 } // namespace content 89 90 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_CONTROLLER_ANDROID_H_ 91