OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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. | |
4 | |
5 package org.chromium.chrome.browser.browseractions; | |
6 | |
7 import org.chromium.chrome.browser.TabState; | |
8 import org.chromium.chrome.browser.tab.Tab; | |
9 import org.chromium.chrome.browser.tab.TabDelegateFactory; | |
10 import org.chromium.chrome.browser.tabmodel.TabCreatorManager; | |
11 import org.chromium.chrome.browser.tabmodel.TabModel; | |
12 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; | |
13 import org.chromium.content_public.browser.LoadUrlParams; | |
14 import org.chromium.content_public.browser.WebContents; | |
15 | |
16 /** | |
17 * The mananger returns a {@link BrowserActionsTabCreator} to create Tabs for Br owser Actions. | |
Yusuf
2017/07/18 22:59:47
manager typo
ltian
2017/08/07 23:24:11
Ops, sorry for that!
| |
18 */ | |
19 public class BrowserActionsTabCreatorManager implements TabCreatorManager { | |
20 private final BrowserActionsTabCreator mTabCreator; | |
21 | |
22 public BrowserActionsTabCreatorManager() { | |
23 mTabCreator = new BrowserActionsTabCreator(); | |
24 } | |
25 | |
26 /** | |
27 * This class creates various kinds of new tabs specific for Browser Actions . | |
28 * The created tabs are not bound with {@link ChromeActivity}. | |
29 */ | |
30 public class BrowserActionsTabCreator extends TabCreator { | |
31 private TabModel mTabModel; | |
32 | |
33 @Override | |
34 public boolean createsTabsAsynchronously() { | |
35 return true; | |
36 } | |
37 | |
38 @Override | |
39 public Tab createNewTab(LoadUrlParams loadUrlParams, TabLaunchType type, Tab parent) { | |
40 Tab tab = Tab.createDetached(new TabDelegateFactory(), true); | |
41 tab.loadUrl(loadUrlParams); | |
42 mTabModel.addTab(tab, -1, TabLaunchType.FROM_BROWSER_ACTIONS); | |
Yusuf
2017/07/18 22:59:47
if we are using FROM_BROWSER_ACTIONS for this, whe
ltian
2017/08/07 23:24:11
New plan will opens all the tabs in lazy load mode
| |
43 return tab; | |
44 } | |
45 | |
46 @Override | |
47 public Tab createFrozenTab(TabState state, int id, int index) { | |
48 Tab tab = | |
49 Tab.createFrozenTabFromState(id, null, false, null, Tab.INVA LID_TAB_ID, state); | |
50 mTabModel.addTab(tab, index, TabLaunchType.FROM_RESTORE); | |
51 return tab; | |
52 } | |
53 | |
54 @Override | |
55 public Tab launchUrl(String url, TabLaunchType type) { | |
56 return createNewTab(new LoadUrlParams(url), type, null); | |
57 } | |
58 | |
59 @Override | |
60 public boolean createTabWithWebContents( | |
61 Tab parent, WebContents webContents, int parentId, TabLaunchType type, String url) { | |
62 createNewTab(new LoadUrlParams(url), type, null); | |
63 return true; | |
64 } | |
65 | |
66 /** | |
67 * Sets the tab model and tab content manager to use. | |
68 * @param model The new {@link TabModel} to use. | |
69 */ | |
70 public void setTabModel(TabModel model) { | |
71 mTabModel = model; | |
72 } | |
73 } | |
74 | |
75 @Override | |
76 public TabCreator getTabCreator(boolean incognito) { | |
77 return mTabCreator; | |
78 } | |
79 } | |
OLD | NEW |