Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: chrome/browser/android/tab_android.h

Issue 23020009: TabBase: Add ContentView/NativePage ownership (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase! Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/android/shortcut_helper.cc ('k') | chrome/browser/android/tab_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
13 #include "chrome/browser/sessions/session_id.h" 14 #include "chrome/browser/sessions/session_id.h"
15 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
14 #include "chrome/browser/ui/toolbar/toolbar_model.h" 16 #include "chrome/browser/ui/toolbar/toolbar_model.h"
15 17
16 class GURL; 18 class GURL;
19 class Profile;
17 class SkBitmap; 20 class SkBitmap;
18 21
19 namespace browser_sync { 22 namespace browser_sync {
20 class SyncedTabDelegate; 23 class SyncedTabDelegate;
21 } 24 }
22 25
23 namespace chrome { 26 namespace chrome {
24 struct NavigateParams; 27 struct NavigateParams;
25 } 28 }
26 29
30 namespace chrome {
31 namespace android {
32 class ChromeWebContentsDelegateAndroid;
33 }
34 }
35
27 namespace content { 36 namespace content {
37 class ContentViewCore;
28 struct ContextMenuParams; 38 struct ContextMenuParams;
29 class WebContents; 39 class WebContents;
30 } 40 }
31 41
32 class TabAndroid { 42 class TabAndroid : public CoreTabHelperDelegate {
33 public: 43 public:
34 TabAndroid(JNIEnv* env, jobject obj);
35
36 // Convenience method to retrieve the Tab associated with the passed 44 // Convenience method to retrieve the Tab associated with the passed
37 // WebContents. Can return NULL. 45 // WebContents. Can return NULL.
38 static TabAndroid* FromWebContents(content::WebContents* web_contents); 46 static TabAndroid* FromWebContents(content::WebContents* web_contents);
39 47
48 // Returns the native TabAndroid stored in the Java TabBase represented by
49 // |obj|.
40 static TabAndroid* GetNativeTab(JNIEnv* env, jobject obj); 50 static TabAndroid* GetNativeTab(JNIEnv* env, jobject obj);
41 51
42 // TODO(tedchoc): Make pure virtual once all derived classes can be updated. 52 TabAndroid(JNIEnv* env, jobject obj);
43 virtual content::WebContents* GetWebContents(); 53
54 // Return the WebContents, if any, currently owned by this TabAndroid.
55 content::WebContents* web_contents() const { return web_contents_.get(); }
56
57 // Return specific id information regarding this TabAndroid.
58 const SessionID& session_id() const { return session_tab_id_; }
59 int android_id() const { return android_tab_id_; }
60
61 // Helper methods to make it easier to access objects from the associated
62 // WebContents. Can return NULL.
63 content::ContentViewCore* GetContentViewCore() const;
64 Profile* GetProfile() const;
65
66 virtual ToolbarModel::SecurityLevel GetSecurityLevel();
44 67
45 virtual browser_sync::SyncedTabDelegate* GetSyncedTabDelegate() = 0; 68 virtual browser_sync::SyncedTabDelegate* GetSyncedTabDelegate() = 0;
46 69
47 virtual ToolbarModel::SecurityLevel GetSecurityLevel();
48
49 const SessionID& id() const { return tab_id_; }
50
51 virtual void HandlePopupNavigation(chrome::NavigateParams* params) = 0; 70 virtual void HandlePopupNavigation(chrome::NavigateParams* params) = 0;
52 71
53 virtual void OnReceivedHttpAuthRequest(jobject auth_handler, 72 virtual void OnReceivedHttpAuthRequest(jobject auth_handler,
54 const string16& host, 73 const string16& host,
55 const string16& realm) = 0; 74 const string16& realm) = 0;
56 75
57 // Called to show the regular context menu that is triggered by a long press. 76 // Called to show the regular context menu that is triggered by a long press.
58 virtual void ShowContextMenu(const content::ContextMenuParams& params) = 0; 77 virtual void ShowContextMenu(const content::ContextMenuParams& params) = 0;
59 78
60 // Called to show a custom context menu. Used by the NTP. 79 // Called to show a custom context menu. Used by the NTP.
(...skipping 26 matching lines...) Expand all
87 // Called when the common ExternalProtocolHandler wants to 106 // Called when the common ExternalProtocolHandler wants to
88 // run the external protocol dialog. 107 // run the external protocol dialog.
89 // TODO(jknotten): Remove this method. Making it non-abstract, so that 108 // TODO(jknotten): Remove this method. Making it non-abstract, so that
90 // derived classes may remove their implementation first. 109 // derived classes may remove their implementation first.
91 virtual void RunExternalProtocolDialog(const GURL& url); 110 virtual void RunExternalProtocolDialog(const GURL& url);
92 111
93 // Used by sync to get/set the sync id of tab. 112 // Used by sync to get/set the sync id of tab.
94 virtual int GetSyncId() const = 0; 113 virtual int GetSyncId() const = 0;
95 virtual void SetSyncId(int sync_id) = 0; 114 virtual void SetSyncId(int sync_id) = 0;
96 115
116 static void InitTabHelpers(content::WebContents* web_contents);
117
118 // Register the Tab's native methods through JNI.
97 static bool RegisterTabAndroid(JNIEnv* env); 119 static bool RegisterTabAndroid(JNIEnv* env);
98 120
99 static void InitTabHelpers(content::WebContents* web_contents); 121 // CoreTabHelperDelegate ----------------------------------------------------
122
123 virtual void SwapTabContents(content::WebContents* old_contents,
124 content::WebContents* new_contents) OVERRIDE;
125
126 // Methods called from Java via JNI -----------------------------------------
127
128 virtual void InitWebContents(JNIEnv* env,
129 jobject obj,
130 jint tab_id,
131 jboolean incognito,
132 jobject jcontent_view_core,
133 jobject jweb_contents_delegate);
134 virtual void DestroyWebContents(JNIEnv* env,
135 jobject obj,
136 jboolean delete_native);
137 base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env,
138 jobject obj);
100 139
101 protected: 140 protected:
102 virtual ~TabAndroid(); 141 virtual ~TabAndroid();
103 142
104 content::WebContents* InitWebContentsFromView(JNIEnv* env,
105 jobject content_view);
106
107 SessionID tab_id_;
108
109 private: 143 private:
110 JavaObjectWeakGlobalRef weak_java_tab_; 144 JavaObjectWeakGlobalRef weak_java_tab_;
145
146 SessionID session_tab_id_;
147 int android_tab_id_;
148
149 scoped_ptr<content::WebContents> web_contents_;
150 scoped_ptr<chrome::android::ChromeWebContentsDelegateAndroid>
151 web_contents_delegate_;
152
153 DISALLOW_COPY_AND_ASSIGN(TabAndroid);
111 }; 154 };
112 155
113 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_ 156 #endif // CHROME_BROWSER_ANDROID_TAB_ANDROID_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/shortcut_helper.cc ('k') | chrome/browser/android/tab_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698