| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ |
| 6 #define CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ | 6 #define CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/jni_helper.h" | 10 #include "base/android/jni_helper.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 public: | 42 public: |
| 43 // Convenience method to retrieve the Tab associated with the passed | 43 // Convenience method to retrieve the Tab associated with the passed |
| 44 // WebContents. Can return NULL. | 44 // WebContents. Can return NULL. |
| 45 static TabAndroid* FromWebContents(content::WebContents* web_contents); | 45 static TabAndroid* FromWebContents(content::WebContents* web_contents); |
| 46 | 46 |
| 47 // Returns the native TabAndroid stored in the Java TabBase represented by | 47 // Returns the native TabAndroid stored in the Java TabBase represented by |
| 48 // |obj|. | 48 // |obj|. |
| 49 static TabAndroid* GetNativeTab(JNIEnv* env, jobject obj); | 49 static TabAndroid* GetNativeTab(JNIEnv* env, jobject obj); |
| 50 | 50 |
| 51 TabAndroid(JNIEnv* env, jobject obj); | 51 TabAndroid(JNIEnv* env, jobject obj); |
| 52 virtual ~TabAndroid(); |
| 52 | 53 |
| 53 // Return the WebContents, if any, currently owned by this TabAndroid. | 54 // Return the WebContents, if any, currently owned by this TabAndroid. |
| 54 content::WebContents* web_contents() const { return web_contents_.get(); } | 55 content::WebContents* web_contents() const { return web_contents_.get(); } |
| 55 | 56 |
| 56 // Return specific id information regarding this TabAndroid. | 57 // Return specific id information regarding this TabAndroid. |
| 57 const SessionID& session_id() const { return session_tab_id_; } | 58 const SessionID& session_id() const { return session_tab_id_; } |
| 58 int GetAndroidId() const; | 59 int GetAndroidId() const; |
| 59 int GetSyncId() const; | 60 int GetSyncId() const; |
| 60 | 61 |
| 61 // Return the tab title. | 62 // Return the tab title. |
| 62 base::string16 GetTitle() const; | 63 base::string16 GetTitle() const; |
| 63 | 64 |
| 64 // Return the tab url. | 65 // Return the tab url. |
| 65 GURL GetURL() const; | 66 GURL GetURL() const; |
| 66 | 67 |
| 67 // Restore the tab if it was unloaded from memory. | 68 // Restore the tab if it was unloaded from memory. |
| 68 bool RestoreIfNeeded(); | 69 bool RestoreIfNeeded(); |
| 69 | 70 |
| 70 // Helper methods to make it easier to access objects from the associated | 71 // Helper methods to make it easier to access objects from the associated |
| 71 // WebContents. Can return NULL. | 72 // WebContents. Can return NULL. |
| 72 content::ContentViewCore* GetContentViewCore() const; | 73 content::ContentViewCore* GetContentViewCore() const; |
| 73 Profile* GetProfile() const; | 74 Profile* GetProfile() const; |
| 74 browser_sync::SyncedTabDelegate* GetSyncedTabDelegate() const; | 75 browser_sync::SyncedTabDelegate* GetSyncedTabDelegate() const; |
| 75 | 76 |
| 76 void SetSyncId(int sync_id); | 77 void SetSyncId(int sync_id); |
| 77 | 78 |
| 78 virtual void HandlePopupNavigation(chrome::NavigateParams* params) = 0; | 79 virtual void HandlePopupNavigation(chrome::NavigateParams* params); |
| 79 | 80 |
| 80 virtual void OnReceivedHttpAuthRequest(jobject auth_handler, | 81 virtual void OnReceivedHttpAuthRequest(jobject auth_handler, |
| 81 const base::string16& host, | 82 const base::string16& host, |
| 82 const base::string16& realm) = 0; | 83 const base::string16& realm); |
| 83 | 84 |
| 84 // Called when context menu option to create the bookmark shortcut on | 85 // Called when context menu option to create the bookmark shortcut on |
| 85 // homescreen is called. | 86 // homescreen is called. |
| 86 virtual void AddShortcutToBookmark( | 87 virtual void AddShortcutToBookmark(const GURL& url, |
| 87 const GURL& url, const base::string16& title, const SkBitmap& skbitmap, | 88 const base::string16& title, |
| 88 int r_value, int g_value, int b_value) = 0; | 89 const SkBitmap& skbitmap, |
| 90 int r_value, |
| 91 int g_value, |
| 92 int b_value); |
| 89 | 93 |
| 90 // Called when a bookmark node should be edited. | 94 // Called when a bookmark node should be edited. |
| 91 virtual void EditBookmark(int64 node_id, | 95 virtual void EditBookmark(int64 node_id, |
| 92 const base::string16& node_title, | 96 const base::string16& node_title, |
| 93 bool is_folder, | 97 bool is_folder, |
| 94 bool is_partner_bookmark) = 0; | 98 bool is_partner_bookmark); |
| 99 |
| 100 // Called to notify that the new tab page has completely rendered. |
| 101 virtual void OnNewTabPageReady(); |
| 95 | 102 |
| 96 // Called to determine if chrome://welcome should contain links to the terms | 103 // Called to determine if chrome://welcome should contain links to the terms |
| 97 // of service and the privacy notice. | 104 // of service and the privacy notice. |
| 98 virtual bool ShouldWelcomePageLinkToTermsOfService() = 0; | 105 virtual bool ShouldWelcomePageLinkToTermsOfService(); |
| 99 | |
| 100 // Called to notify that the new tab page has completely rendered. | |
| 101 virtual void OnNewTabPageReady() = 0; | |
| 102 | 106 |
| 103 static void InitTabHelpers(content::WebContents* web_contents); | 107 static void InitTabHelpers(content::WebContents* web_contents); |
| 104 | 108 |
| 105 // Register the Tab's native methods through JNI. | 109 // Register the Tab's native methods through JNI. |
| 106 static bool RegisterTabAndroid(JNIEnv* env); | 110 static bool RegisterTabAndroid(JNIEnv* env); |
| 107 | 111 |
| 108 // CoreTabHelperDelegate ---------------------------------------------------- | 112 // CoreTabHelperDelegate ---------------------------------------------------- |
| 109 | 113 |
| 110 virtual void SwapTabContents(content::WebContents* old_contents, | 114 virtual void SwapTabContents(content::WebContents* old_contents, |
| 111 content::WebContents* new_contents) OVERRIDE; | 115 content::WebContents* new_contents) OVERRIDE; |
| 112 | 116 |
| 113 // NotificationObserver ----------------------------------------------------- | 117 // NotificationObserver ----------------------------------------------------- |
| 114 virtual void Observe(int type, | 118 virtual void Observe(int type, |
| 115 const content::NotificationSource& source, | 119 const content::NotificationSource& source, |
| 116 const content::NotificationDetails& details) OVERRIDE; | 120 const content::NotificationDetails& details) OVERRIDE; |
| 117 | 121 |
| 118 // Methods called from Java via JNI ----------------------------------------- | 122 // Methods called from Java via JNI ----------------------------------------- |
| 119 | 123 |
| 124 virtual void Destroy(JNIEnv* env, jobject obj); |
| 120 virtual void InitWebContents(JNIEnv* env, | 125 virtual void InitWebContents(JNIEnv* env, |
| 121 jobject obj, | 126 jobject obj, |
| 122 jboolean incognito, | 127 jboolean incognito, |
| 123 jobject jcontent_view_core, | 128 jobject jcontent_view_core, |
| 124 jobject jweb_contents_delegate, | 129 jobject jweb_contents_delegate, |
| 125 jobject jcontext_menu_populator); | 130 jobject jcontext_menu_populator); |
| 126 | |
| 127 virtual void DestroyWebContents(JNIEnv* env, | 131 virtual void DestroyWebContents(JNIEnv* env, |
| 128 jobject obj, | 132 jobject obj, |
| 129 jboolean delete_native); | 133 jboolean delete_native); |
| 130 base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env, | 134 base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env, |
| 131 jobject obj); | 135 jobject obj); |
| 132 ToolbarModel::SecurityLevel GetSecurityLevel(JNIEnv* env, jobject obj); | 136 ToolbarModel::SecurityLevel GetSecurityLevel(JNIEnv* env, jobject obj); |
| 133 void SetActiveNavigationEntryTitleForUrl(JNIEnv* env, | 137 void SetActiveNavigationEntryTitleForUrl(JNIEnv* env, |
| 134 jobject obj, | 138 jobject obj, |
| 135 jstring jurl, | 139 jstring jurl, |
| 136 jstring jtitle); | 140 jstring jtitle); |
| 137 bool Print(JNIEnv* env, jobject obj); | 141 bool Print(JNIEnv* env, jobject obj); |
| 138 | 142 |
| 139 protected: | |
| 140 virtual ~TabAndroid(); | |
| 141 | |
| 142 private: | 143 private: |
| 143 JavaObjectWeakGlobalRef weak_java_tab_; | 144 JavaObjectWeakGlobalRef weak_java_tab_; |
| 144 | 145 |
| 145 SessionID session_tab_id_; | 146 SessionID session_tab_id_; |
| 146 | 147 |
| 147 content::NotificationRegistrar notification_registrar_; | 148 content::NotificationRegistrar notification_registrar_; |
| 148 | 149 |
| 149 scoped_ptr<content::WebContents> web_contents_; | 150 scoped_ptr<content::WebContents> web_contents_; |
| 150 scoped_ptr<chrome::android::ChromeWebContentsDelegateAndroid> | 151 scoped_ptr<chrome::android::ChromeWebContentsDelegateAndroid> |
| 151 web_contents_delegate_; | 152 web_contents_delegate_; |
| 152 | 153 |
| 153 scoped_ptr<browser_sync::SyncedTabDelegateAndroid> synced_tab_delegate_; | 154 scoped_ptr<browser_sync::SyncedTabDelegateAndroid> synced_tab_delegate_; |
| 154 | 155 |
| 155 DISALLOW_COPY_AND_ASSIGN(TabAndroid); | 156 DISALLOW_COPY_AND_ASSIGN(TabAndroid); |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ | 159 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ |
| OLD | NEW |