Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / android / tab_android.h
blob9435eca2c2079bbf7aebb0e40190fb98ccaa4d3c
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_weak_ref.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 namespace prerender {
41 class PrerenderManager;
44 class TabAndroid : public CoreTabHelperDelegate,
45 public content::NotificationObserver {
46 public:
47 enum TabLoadStatus {
48 #define DEFINE_TAB_LOAD_STATUS(name, value) name = value,
49 #include "chrome/browser/android/tab_load_status.h"
50 #undef DEFINE_TAB_LOAD_STATUS
53 // Convenience method to retrieve the Tab associated with the passed
54 // WebContents. Can return NULL.
55 static TabAndroid* FromWebContents(content::WebContents* web_contents);
57 // Returns the native TabAndroid stored in the Java Tab represented by
58 // |obj|.
59 static TabAndroid* GetNativeTab(JNIEnv* env, jobject obj);
61 // Function to attach helpers to the contentView.
62 static void AttachTabHelpers(content::WebContents* web_contents);
64 TabAndroid(JNIEnv* env, jobject obj);
65 virtual ~TabAndroid();
67 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
69 // Return the WebContents, if any, currently owned by this TabAndroid.
70 content::WebContents* web_contents() const { return web_contents_.get(); }
72 // Return specific id information regarding this TabAndroid.
73 const SessionID& session_id() const { return session_tab_id_; }
74 int GetAndroidId() const;
75 int GetSyncId() const;
77 // Return the tab title.
78 base::string16 GetTitle() const;
80 // Return the tab url.
81 GURL GetURL() const;
83 // Load the tab if it was unloaded from memory.
84 bool LoadIfNeeded();
86 // Helper methods to make it easier to access objects from the associated
87 // WebContents. Can return NULL.
88 content::ContentViewCore* GetContentViewCore() const;
89 Profile* GetProfile() const;
90 browser_sync::SyncedTabDelegate* GetSyncedTabDelegate() const;
92 void SetWindowSessionID(SessionID::id_type window_id);
93 void SetSyncId(int sync_id);
95 virtual void HandlePopupNavigation(chrome::NavigateParams* params);
97 virtual void OnReceivedHttpAuthRequest(jobject auth_handler,
98 const base::string16& host,
99 const base::string16& realm);
101 // Called to determine if chrome://welcome should contain links to the terms
102 // of service and the privacy notice.
103 virtual bool ShouldWelcomePageLinkToTermsOfService();
105 bool HasPrerenderedUrl(GURL gurl);
107 // CoreTabHelperDelegate ----------------------------------------------------
109 virtual void SwapTabContents(content::WebContents* old_contents,
110 content::WebContents* new_contents,
111 bool did_start_load,
112 bool did_finish_load) OVERRIDE;
114 // NotificationObserver -----------------------------------------------------
115 virtual void Observe(int type,
116 const content::NotificationSource& source,
117 const content::NotificationDetails& details) OVERRIDE;
119 // Methods called from Java via JNI -----------------------------------------
121 virtual void Destroy(JNIEnv* env, jobject obj);
122 virtual void InitWebContents(JNIEnv* env,
123 jobject obj,
124 jboolean incognito,
125 jobject jcontent_view_core,
126 jobject jweb_contents_delegate,
127 jobject jcontext_menu_populator);
128 virtual void DestroyWebContents(JNIEnv* env,
129 jobject obj,
130 jboolean delete_native);
131 base::android::ScopedJavaLocalRef<jobject> GetWebContents(JNIEnv* env,
132 jobject obj);
133 base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env,
134 jobject obj);
135 virtual TabLoadStatus LoadUrl(JNIEnv* env,
136 jobject obj,
137 jstring url,
138 jstring j_extra_headers,
139 jbyteArray j_post_data,
140 jint page_transition,
141 jstring j_referrer_url,
142 jint referrer_policy);
143 ToolbarModel::SecurityLevel GetSecurityLevel(JNIEnv* env, jobject obj);
144 void SetActiveNavigationEntryTitleForUrl(JNIEnv* env,
145 jobject obj,
146 jstring jurl,
147 jstring jtitle);
148 bool Print(JNIEnv* env, jobject obj);
150 // Register the Tab's native methods through JNI.
151 static bool RegisterTabAndroid(JNIEnv* env);
153 private:
154 prerender::PrerenderManager* GetPrerenderManager() const;
156 JavaObjectWeakGlobalRef weak_java_tab_;
158 // The identifier used by session restore for this tab.
159 SessionID session_tab_id_;
161 // Identifier of the window the tab is in.
162 SessionID session_window_id_;
164 content::NotificationRegistrar notification_registrar_;
166 scoped_ptr<content::WebContents> web_contents_;
167 scoped_ptr<chrome::android::ChromeWebContentsDelegateAndroid>
168 web_contents_delegate_;
170 scoped_ptr<browser_sync::SyncedTabDelegateAndroid> synced_tab_delegate_;
172 DISALLOW_COPY_AND_ASSIGN(TabAndroid);
175 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_