Chromium Code Reviews| 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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.content.Context; | |
| 8 import android.content.Intent; | |
| 9 | |
| 10 import org.chromium.chrome.browser.ShortcutHelper; | |
| 11 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; | 7 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator; |
| 12 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; | 8 import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator; |
| 13 import org.chromium.chrome.browser.tab.Tab; | 9 import org.chromium.chrome.browser.tab.Tab; |
| 14 import org.chromium.chrome.browser.tab.TabContextMenuItemDelegate; | 10 import org.chromium.chrome.browser.tab.TabContextMenuItemDelegate; |
| 15 import org.chromium.chrome.browser.tab.TabDelegateFactory; | 11 import org.chromium.chrome.browser.tab.TabDelegateFactory; |
| 16 import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid; | |
| 17 import org.chromium.chrome.browser.tab.TopControlsVisibilityDelegate; | 12 import org.chromium.chrome.browser.tab.TopControlsVisibilityDelegate; |
| 18 | 13 |
| 19 /** | 14 /** |
| 20 * A {@link TabDelegateFactory} class to be used in all {@link Tab} instances ow ned | 15 * A {@link TabDelegateFactory} class to be used in all {@link Tab} instances ow ned |
| 21 * by a {@link FullScreenActivity}. | 16 * by a {@link FullScreenActivity}. |
| 22 */ | 17 */ |
| 23 public class FullScreenDelegateFactory extends TabDelegateFactory { | 18 public class FullScreenDelegateFactory extends TabDelegateFactory { |
| 24 private static class FullScreenTabWebContentsDelegateAndroid | |
| 25 extends TabWebContentsDelegateAndroid { | |
| 26 | |
| 27 public FullScreenTabWebContentsDelegateAndroid(Tab tab) { | |
| 28 super(tab); | |
| 29 } | |
| 30 | |
| 31 @Override | |
| 32 public void activateContents() { | |
| 33 Context context = mTab.getWindowAndroid().getContext().get(); | |
| 34 if (!(context instanceof WebappActivity)) return; | |
| 35 | |
| 36 WebappInfo webappInfo = ((WebappActivity) context).getWebappInfo(); | |
| 37 String url = webappInfo.uri().toString(); | |
| 38 | |
| 39 // Create an Intent that will be fired toward the WebappLauncherActi vity, which in turn | |
| 40 // will fire an Intent to launch the correct WebappActivity. On L+ this could probably | |
| 41 // be changed to call AppTask.moveToFront(), but for backwards compa tibility we relaunch | |
| 42 // it the hard way. | |
| 43 Intent intent = new Intent(); | |
| 44 intent.setAction(WebappLauncherActivity.ACTION_START_WEBAPP); | |
| 45 intent.setPackage(context.getPackageName()); | |
| 46 webappInfo.setWebappIntentExtras(intent); | |
| 47 | |
| 48 intent.putExtra(ShortcutHelper.EXTRA_MAC, ShortcutHelper.getEncodedM ac(context, url)); | |
| 49 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
| 50 context.getApplicationContext().startActivity(intent); | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 @Override | |
| 55 public FullScreenTabWebContentsDelegateAndroid createWebContentsDelegate(Tab tab) { | |
| 56 return new FullScreenTabWebContentsDelegateAndroid(tab); | |
| 57 } | |
| 58 | |
| 59 @Override | 19 @Override |
| 60 public ContextMenuPopulator createContextMenuPopulator(Tab tab) { | 20 public ContextMenuPopulator createContextMenuPopulator(Tab tab) { |
| 61 return new ChromeContextMenuPopulator(new TabContextMenuItemDelegate(tab ), | 21 return new ChromeContextMenuPopulator(new TabContextMenuItemDelegate(tab ), |
| 62 ChromeContextMenuPopulator.FULLSCREEN_TAB_MODE); | 22 ChromeContextMenuPopulator.FULLSCREEN_TAB_MODE); |
| 63 } | 23 } |
| 64 | 24 |
| 65 @Override | 25 @Override |
| 66 public TopControlsVisibilityDelegate createTopControlsVisibilityDelegate(Tab tab) { | 26 public TopControlsVisibilityDelegate createTopControlsVisibilityDelegate(Tab tab) { |
|
Xi Han
2016/05/30 21:26:55
Do we still need to override this function in Full
pkotwicz
2016/05/31 02:32:01
I think so. The implementation here is different t
Xi Han
2016/05/31 14:18:27
I missed the class EmbedContentViewActivity which
| |
| 67 return new TopControlsVisibilityDelegate(tab) { | 27 return new TopControlsVisibilityDelegate(tab) { |
| 68 @Override | 28 @Override |
| 69 public boolean isHidingTopControlsEnabled() { | 29 public boolean isHidingTopControlsEnabled() { |
| 70 return !isShowingTopControlsEnabled(); | 30 return !isShowingTopControlsEnabled(); |
| 71 } | 31 } |
| 72 }; | 32 }; |
| 73 } | 33 } |
| 74 } | 34 } |
| OLD | NEW |