| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.browser.tabmodel; | 5 package org.chromium.chrome.browser.tabmodel; |
| 6 | 6 |
| 7 import android.content.Intent; | 7 import android.content.Intent; |
| 8 import android.os.Handler; |
| 8 import android.text.TextUtils; | 9 import android.text.TextUtils; |
| 9 | 10 |
| 10 import org.chromium.base.SysUtils; | 11 import org.chromium.base.SysUtils; |
| 11 import org.chromium.base.TraceEvent; | 12 import org.chromium.base.TraceEvent; |
| 13 import org.chromium.chrome.R; |
| 12 import org.chromium.chrome.browser.ChromeActivity; | 14 import org.chromium.chrome.browser.ChromeActivity; |
| 13 import org.chromium.chrome.browser.IntentHandler; | 15 import org.chromium.chrome.browser.IntentHandler; |
| 14 import org.chromium.chrome.browser.TabState; | 16 import org.chromium.chrome.browser.TabState; |
| 15 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; | 17 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; |
| 16 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; | 18 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; |
| 17 import org.chromium.chrome.browser.tab.Tab; | 19 import org.chromium.chrome.browser.tab.Tab; |
| 18 import org.chromium.chrome.browser.tab.TabDelegateFactory; | 20 import org.chromium.chrome.browser.tab.TabDelegateFactory; |
| 19 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | 21 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; |
| 20 import org.chromium.chrome.browser.util.IntentUtils; | 22 import org.chromium.chrome.browser.util.IntentUtils; |
| 21 import org.chromium.chrome.browser.util.UrlUtilities; | 23 import org.chromium.chrome.browser.util.UrlUtilities; |
| 22 import org.chromium.components.service_tab_launcher.ServiceTabLauncher; | 24 import org.chromium.components.service_tab_launcher.ServiceTabLauncher; |
| 23 import org.chromium.content_public.browser.LoadUrlParams; | 25 import org.chromium.content_public.browser.LoadUrlParams; |
| 24 import org.chromium.content_public.browser.WebContents; | 26 import org.chromium.content_public.browser.WebContents; |
| 25 import org.chromium.content_public.common.Referrer; | 27 import org.chromium.content_public.common.Referrer; |
| 26 import org.chromium.ui.base.PageTransition; | 28 import org.chromium.ui.base.PageTransition; |
| 27 import org.chromium.ui.base.WindowAndroid; | 29 import org.chromium.ui.base.WindowAndroid; |
| 30 import org.chromium.ui.widget.Toast; |
| 28 | 31 |
| 29 /** | 32 /** |
| 30 * This class creates various kinds of new tabs and adds them to the right {@lin
k TabModel}. | 33 * This class creates various kinds of new tabs and adds them to the right {@lin
k TabModel}. |
| 31 */ | 34 */ |
| 32 public class ChromeTabCreator extends TabCreatorManager.TabCreator { | 35 public class ChromeTabCreator extends TabCreatorManager.TabCreator { |
| 36 private static final int VISIBLE_DURATION_MS = 600; |
| 33 | 37 |
| 34 private final ChromeActivity mActivity; | 38 private final ChromeActivity mActivity; |
| 35 private final WindowAndroid mNativeWindow; | 39 private final WindowAndroid mNativeWindow; |
| 36 private final TabModelOrderController mOrderController; | 40 private final TabModelOrderController mOrderController; |
| 37 private final TabPersistentStore mTabSaver; | 41 private final TabPersistentStore mTabSaver; |
| 38 private final boolean mIncognito; | 42 private final boolean mIncognito; |
| 39 | 43 |
| 40 private TabModel mTabModel; | 44 private TabModel mTabModel; |
| 41 private TabContentManager mTabContentManager; | 45 private TabContentManager mTabContentManager; |
| 42 | 46 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 162 } |
| 159 tab.getTabRedirectHandler().updateIntent(intent); | 163 tab.getTabRedirectHandler().updateIntent(intent); |
| 160 | 164 |
| 161 if (intent != null && intent.hasExtra(ServiceTabLauncher.LAUNCH_REQU
EST_ID_EXTRA)) { | 165 if (intent != null && intent.hasExtra(ServiceTabLauncher.LAUNCH_REQU
EST_ID_EXTRA)) { |
| 162 ServiceTabLauncher.onWebContentsForRequestAvailable( | 166 ServiceTabLauncher.onWebContentsForRequestAvailable( |
| 163 intent.getIntExtra(ServiceTabLauncher.LAUNCH_REQUEST_ID_
EXTRA, 0), | 167 intent.getIntExtra(ServiceTabLauncher.LAUNCH_REQUEST_ID_
EXTRA, 0), |
| 164 tab.getWebContents()); | 168 tab.getWebContents()); |
| 165 } | 169 } |
| 166 | 170 |
| 167 mTabModel.addTab(tab, position, type); | 171 mTabModel.addTab(tab, position, type); |
| 172 |
| 173 if (type == TabLaunchType.FROM_REPARENTING) { |
| 174 TabReparentingParams params = (TabReparentingParams) asyncParams
; |
| 175 if (!params.shouldStayInChrome()) { |
| 176 new Handler().postDelayed(new Runnable() { |
| 177 @Override |
| 178 public void run() { |
| 179 mActivity.moveTaskToBack(true); |
| 180 Toast.makeText(mActivity, R.string.tab_sent_to_backg
round, |
| 181 Toast.LENGTH_LONG).show(); |
| 182 } |
| 183 }, VISIBLE_DURATION_MS); |
| 184 } |
| 185 } |
| 168 return tab; | 186 return tab; |
| 169 } finally { | 187 } finally { |
| 170 TraceEvent.end("ChromeTabCreator.createNewTab"); | 188 TraceEvent.end("ChromeTabCreator.createNewTab"); |
| 171 } | 189 } |
| 172 } | 190 } |
| 173 | 191 |
| 174 @Override | 192 @Override |
| 175 public boolean createTabWithWebContents(Tab parent, WebContents webContents,
int parentId, | 193 public boolean createTabWithWebContents(Tab parent, WebContents webContents,
int parentId, |
| 176 TabLaunchType type, String url) { | 194 TabLaunchType type, String url) { |
| 177 // The parent tab was already closed. Do not open child tabs. | 195 // The parent tab was already closed. Do not open child tabs. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 * Sets the tab model and tab content manager to use. | 341 * Sets the tab model and tab content manager to use. |
| 324 * @param model The new {@link TabModel} to use. | 342 * @param model The new {@link TabModel} to use. |
| 325 * @param manager The new {@link TabContentManager} to use. | 343 * @param manager The new {@link TabContentManager} to use. |
| 326 */ | 344 */ |
| 327 public void setTabModel(TabModel model, TabContentManager manager) { | 345 public void setTabModel(TabModel model, TabContentManager manager) { |
| 328 mTabModel = model; | 346 mTabModel = model; |
| 329 mTabContentManager = manager; | 347 mTabContentManager = manager; |
| 330 } | 348 } |
| 331 | 349 |
| 332 } | 350 } |
| OLD | NEW |