OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 package org.chromium.chrome.shell; | 5 package org.chromium.chrome.shell; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
9 | 9 |
10 import org.chromium.chrome.browser.Tab; | 10 import org.chromium.chrome.browser.Tab; |
11 import org.chromium.chrome.browser.UrlUtilities; | 11 import org.chromium.chrome.browser.UrlUtilities; |
12 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; | 12 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; |
13 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; | 13 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
14 import org.chromium.chrome.browser.infobar.AutoLoginProcessor; | 14 import org.chromium.chrome.browser.infobar.AutoLoginProcessor; |
| 15 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
15 import org.chromium.content.browser.ContentViewClient; | 16 import org.chromium.content.browser.ContentViewClient; |
16 import org.chromium.content_public.browser.LoadUrlParams; | 17 import org.chromium.content_public.browser.LoadUrlParams; |
17 import org.chromium.content_public.browser.NavigationController; | 18 import org.chromium.content_public.browser.NavigationController; |
18 import org.chromium.content_public.browser.WebContents; | 19 import org.chromium.content_public.browser.WebContents; |
19 import org.chromium.content_public.common.Referrer; | 20 import org.chromium.content_public.common.Referrer; |
20 import org.chromium.ui.base.WindowAndroid; | 21 import org.chromium.ui.base.WindowAndroid; |
21 | 22 |
22 /** | 23 /** |
23 * ChromeShell's implementation of a tab. This mirrors how Chrome for Android su
bclasses | 24 * ChromeShell's implementation of a tab. This mirrors how Chrome for Android su
bclasses |
24 * and extends {@link Tab}. | 25 * and extends {@link Tab}. |
25 */ | 26 */ |
26 public class ChromeShellTab extends Tab { | 27 public class ChromeShellTab extends Tab { |
27 // Tab state | 28 // Tab state |
28 private boolean mIsLoading; | 29 private boolean mIsLoading; |
29 private boolean mIsFullscreen = false; | 30 private boolean mIsFullscreen = false; |
| 31 private TabManager mTabManager; |
30 | 32 |
31 /** | 33 /** |
32 * @param context The Context the view is running in. | 34 * @param context The Context the view is running in. |
33 * @param url The URL to start this tab with. | 35 * @param url The URL to start this tab with. |
34 * @param window The WindowAndroid should represent this tab. | 36 * @param window The WindowAndroid should represent this tab. |
35 * @param contentViewClient The client for the {@link ContentViewCore}s of t
his Tab. | 37 * @param contentViewClient The client for the {@link ContentViewCore}s of t
his Tab. |
36 */ | 38 */ |
37 public ChromeShellTab(Context context, String url, WindowAndroid window, | 39 public ChromeShellTab(Context context, String url, WindowAndroid window, |
38 ContentViewClient contentViewClient) { | 40 ContentViewClient contentViewClient, TabManager tabManager) { |
39 super(false, context, window); | 41 super(false, context, window); |
40 initialize(); | 42 initialize(); |
41 initContentViewCore(); | 43 initContentViewCore(); |
42 setContentViewClient(contentViewClient); | 44 setContentViewClient(contentViewClient); |
43 loadUrlWithSanitization(url); | 45 loadUrlWithSanitization(url); |
| 46 mTabManager = tabManager; |
44 } | 47 } |
45 | 48 |
46 /** | 49 /** |
47 * @return Whether or not the tab is currently loading. | 50 * @return Whether or not the tab is currently loading. |
48 */ | 51 */ |
49 public boolean isLoading() { | 52 public boolean isLoading() { |
50 return mIsLoading; | 53 return mIsLoading; |
51 } | 54 } |
52 | 55 |
53 /** | 56 /** |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 }; | 105 }; |
103 } | 106 } |
104 | 107 |
105 @Override | 108 @Override |
106 protected ContextMenuPopulator createContextMenuPopulator() { | 109 protected ContextMenuPopulator createContextMenuPopulator() { |
107 return new ChromeContextMenuPopulator(new TabChromeContextMenuItemDelega
te() { | 110 return new ChromeContextMenuPopulator(new TabChromeContextMenuItemDelega
te() { |
108 @Override | 111 @Override |
109 public void onOpenImageUrl(String url, Referrer referrer) { | 112 public void onOpenImageUrl(String url, Referrer referrer) { |
110 loadUrlWithSanitization(url); | 113 loadUrlWithSanitization(url); |
111 } | 114 } |
| 115 |
| 116 @Override |
| 117 public void onOpenInNewTab(String url, Referrer referrer) { |
| 118 mTabManager.createTab(url, TabLaunchType.FROM_LINK); |
| 119 } |
112 }); | 120 }); |
113 } | 121 } |
114 | 122 |
115 private class ChromeShellTabChromeWebContentsDelegateAndroid | 123 private class ChromeShellTabChromeWebContentsDelegateAndroid |
116 extends TabChromeWebContentsDelegateAndroid { | 124 extends TabChromeWebContentsDelegateAndroid { |
117 @Override | 125 @Override |
118 public void onLoadStarted() { | 126 public void onLoadStarted() { |
119 mIsLoading = true; | 127 mIsLoading = true; |
120 } | 128 } |
121 | 129 |
122 @Override | 130 @Override |
123 public void onLoadStopped() { | 131 public void onLoadStopped() { |
124 mIsLoading = false; | 132 mIsLoading = false; |
125 } | 133 } |
126 | 134 |
127 @Override | 135 @Override |
128 public void toggleFullscreenModeForTab(boolean enterFullscreen) { | 136 public void toggleFullscreenModeForTab(boolean enterFullscreen) { |
129 mIsFullscreen = enterFullscreen; | 137 mIsFullscreen = enterFullscreen; |
130 super.toggleFullscreenModeForTab(enterFullscreen); | 138 super.toggleFullscreenModeForTab(enterFullscreen); |
131 } | 139 } |
132 | 140 |
133 @Override | 141 @Override |
134 public boolean isFullscreenForTabOrPending() { | 142 public boolean isFullscreenForTabOrPending() { |
135 return mIsFullscreen; | 143 return mIsFullscreen; |
136 } | 144 } |
137 } | 145 } |
138 } | 146 } |
OLD | NEW |