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 CHROME_ANDROID_TESTSHELL_TESTSHELL_TAB_H_ 6 #define CHROME_ANDROID_TESTSHELL_TESTSHELL_TAB_H_ 7 8 #include <jni.h> 9 10 #include "base/compiler_specific.h" 11 #include "base/memory/scoped_ptr.h" 12 #include "chrome/browser/android/tab_android.h" 13 14 namespace browser_sync { 15 class SyncedTabDelegate; 16 } 17 18 namespace chrome { 19 namespace android { 20 class ChromeWebContentsDelegateAndroid; 21 } 22 } 23 24 namespace content { 25 class WebContents; 26 } 27 28 namespace ui { 29 class WindowAndroid; 30 } 31 32 class TestShellTab : public TabAndroid { 33 public: 34 TestShellTab(JNIEnv* env, 35 jobject obj, 36 content::WebContents* web_contents, 37 ui::WindowAndroid* window_android); 38 void Destroy(JNIEnv* env, jobject obj); 39 40 // -------------------------------------------------------------------------- 41 // TabAndroid Methods 42 // -------------------------------------------------------------------------- 43 virtual content::WebContents* GetWebContents() OVERRIDE; 44 45 virtual browser_sync::SyncedTabDelegate* GetSyncedTabDelegate() OVERRIDE; 46 47 virtual void OnReceivedHttpAuthRequest(jobject auth_handler, 48 const string16& host, 49 const string16& realm) OVERRIDE; 50 virtual void ShowContextMenu( 51 const content::ContextMenuParams& params) OVERRIDE; 52 53 virtual void ShowCustomContextMenu( 54 const content::ContextMenuParams& params, 55 const base::Callback<void(int)>& callback) OVERRIDE; 56 57 virtual void AddShortcutToBookmark(const GURL& url, 58 const string16& title, 59 const SkBitmap& skbitmap, 60 int r_value, 61 int g_value, 62 int b_value) OVERRIDE; 63 virtual void EditBookmark(int64 node_id, bool is_folder) OVERRIDE; 64 65 virtual void ShowSyncSettings() OVERRIDE; 66 virtual void ShowTermsOfService() OVERRIDE; 67 virtual bool ShouldWelcomePageLinkToTermsOfService() OVERRIDE; 68 virtual void OnNewTabPageReady() OVERRIDE; 69 70 virtual void RunExternalProtocolDialog(const GURL& url) OVERRIDE; 71 72 virtual int GetSyncId() const OVERRIDE; 73 virtual void SetSyncId(int sync_id) OVERRIDE; 74 75 // Register the Tab's native methods through JNI. 76 static bool RegisterTestShellTab(JNIEnv* env); 77 78 // -------------------------------------------------------------------------- 79 // Methods called from Java via JNI 80 // -------------------------------------------------------------------------- 81 void InitWebContentsDelegate(JNIEnv* env, 82 jobject obj, 83 jobject web_contents_delegate); 84 85 base::android::ScopedJavaLocalRef<jstring> FixupUrl(JNIEnv* env, 86 jobject obj, 87 jstring url); 88 89 protected: 90 virtual ~TestShellTab(); 91 92 private: 93 scoped_ptr<content::WebContents> web_contents_; 94 scoped_ptr<chrome::android::ChromeWebContentsDelegateAndroid> 95 web_contents_delegate_; 96 97 DISALLOW_COPY_AND_ASSIGN(TestShellTab); 98 }; 99 100 #endif // CHROME_ANDROID_TESTSHELL_TESTSHELL_TAB_H_ 101