Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / android / tab_android.h
blobc1ba762e777b9e88efeaf1e07d4a52439a60f82d
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.
5 #ifndef CHROME_BROWSER_ANDROID_TAB_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_TAB_ANDROID_H_
8 #include <jni.h>
10 #include "base/android/jni_helper.h"
11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h"
14 #include "chrome/browser/sessions/session_id.h"
15 #include "chrome/browser/sync/glue/synced_tab_delegate_android.h"
16 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
17 #include "chrome/browser/ui/toolbar/toolbar_model.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
21 class GURL;
22 class Profile;
23 class SkBitmap;
25 namespace chrome {
26 struct NavigateParams;
29 namespace chrome {
30 namespace android {
31 class ChromeWebContentsDelegateAndroid;
35 namespace content {
36 class ContentViewCore;
37 class WebContents;
40 class TabAndroid : public CoreTabHelperDelegate,
41 public content::NotificationObserver {
42 public:
43 // Convenience method to retrieve the Tab associated with the passed
44 // WebContents. Can return NULL.
45 static TabAndroid* FromWebContents(content::WebContents* web_contents);
47 // Returns the native TabAndroid stored in the Java TabBase represented by
48 // |obj|.
49 static TabAndroid* GetNativeTab(JNIEnv* env, jobject obj);
51 TabAndroid(JNIEnv* env, jobject obj);
52 virtual ~TabAndroid();
54 // Return the WebContents, if any, currently owned by this TabAndroid.
55 content::WebContents* web_contents() const { return web_contents_.get(); }
57 // Return specific id information regarding this TabAndroid.
58 const SessionID& session_id() const { return session_tab_id_; }
59 int GetAndroidId() const;
60 int GetSyncId() const;
62 // Return the tab title.
63 base::string16 GetTitle() const;
65 // Return the tab url.
66 GURL GetURL() const;
68 // Restore the tab if it was unloaded from memory.
69 bool RestoreIfNeeded();
71 // Helper methods to make it easier to access objects from the associated
72 // WebContents. Can return NULL.
73 content::ContentViewCore* GetContentViewCore() const;
74 Profile* GetProfile() const;
75 browser_sync::SyncedTabDelegate* GetSyncedTabDelegate() const;
77 void SetSyncId(int sync_id);
79 virtual void HandlePopupNavigation(chrome::NavigateParams* params);
81 virtual void OnReceivedHttpAuthRequest(jobject auth_handler,
82 const base::string16& host,
83 const base::string16& realm);
85 // Called when context menu option to create the bookmark shortcut on
86 // homescreen is called.
87 virtual void AddShortcutToBookmark(const GURL& url,
88 const base::string16& title,
89 const SkBitmap& skbitmap,
90 int r_value,
91 int g_value,
92 int b_value);
94 // Called when a bookmark node should be edited.
95 virtual void EditBookmark(int64 node_id,
96 const base::string16& node_title,
97 bool is_folder,
98 bool is_partner_bookmark);
100 // Called to notify that the new tab page has completely rendered.
101 virtual void OnNewTabPageReady();
103 // Called to determine if chrome://welcome should contain links to the terms
104 // of service and the privacy notice.
105 virtual bool ShouldWelcomePageLinkToTermsOfService();
107 static void InitTabHelpers(content::WebContents* web_contents);
109 // Register the Tab's native methods through JNI.
110 static bool RegisterTabAndroid(JNIEnv* env);
112 // CoreTabHelperDelegate ----------------------------------------------------
114 virtual void SwapTabContents(content::WebContents* old_contents,
115 content::WebContents* new_contents) OVERRIDE;
117 // NotificationObserver -----------------------------------------------------
118 virtual void Observe(int type,
119 const content::NotificationSource& source,
120 const content::NotificationDetails& details) OVERRIDE;
122 // Methods called from Java via JNI -----------------------------------------
124 virtual void Destroy(JNIEnv* env, jobject obj);
125 virtual void InitWebContents(JNIEnv* env,
126 jobject obj,
127 jboolean incognito,
128 jobject jcontent_view_core,
129 jobject jweb_contents_delegate,
130 jobject jcontext_menu_populator);
131 virtual void DestroyWebContents(JNIEnv* env,
132 jobject obj,
133 jboolean delete_native);
134 base::android::ScopedJavaLocalRef<jobject> GetWebContents(JNIEnv* env,
135 jobject obj);
136 base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env,
137 jobject obj);
138 ToolbarModel::SecurityLevel GetSecurityLevel(JNIEnv* env, jobject obj);
139 void SetActiveNavigationEntryTitleForUrl(JNIEnv* env,
140 jobject obj,
141 jstring jurl,
142 jstring jtitle);
143 bool Print(JNIEnv* env, jobject obj);
145 private:
146 JavaObjectWeakGlobalRef weak_java_tab_;
148 SessionID session_tab_id_;
150 content::NotificationRegistrar notification_registrar_;
152 scoped_ptr<content::WebContents> web_contents_;
153 scoped_ptr<chrome::android::ChromeWebContentsDelegateAndroid>
154 web_contents_delegate_;
156 scoped_ptr<browser_sync::SyncedTabDelegateAndroid> synced_tab_delegate_;
158 DISALLOW_COPY_AND_ASSIGN(TabAndroid);
161 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_