OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.webapps; |
| 6 |
| 7 import android.content.Intent; |
| 8 import android.view.View; |
| 9 import android.view.ViewGroup; |
| 10 |
| 11 import com.google.android.apps.chrome.R; |
| 12 |
| 13 import org.chromium.chrome.browser.CompositorChromeActivity; |
| 14 import org.chromium.chrome.browser.compositor.layouts.LayoutManagerDocument; |
| 15 import org.chromium.chrome.browser.tabmodel.SingleTabModelSelector; |
| 16 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; |
| 17 import org.chromium.chrome.browser.widget.ControlContainer; |
| 18 |
| 19 import java.io.File; |
| 20 |
| 21 /** |
| 22 * Base class for task-focused activities that need to display web content in a
nearly UI-less |
| 23 * Chrome (InfoBars still appear). |
| 24 * |
| 25 * This is vaguely analogous to a WebView, but in Chrome. Example applications t
hat might use this |
| 26 * Activity would be webapps and streaming media activities - anything where use
r interaction with |
| 27 * the regular browser's UI is either unnecessary or undesirable. |
| 28 * Subclasses can override {@link #createUI()} if they need something more exoti
c. |
| 29 * |
| 30 * TODO(dfalcantara, andrewhayden): Consider not using a Tab here once all initi
alization is cleaned |
| 31 * up: crbug.com/270973 |
| 32 */ |
| 33 public abstract class FullScreenActivity extends CompositorChromeActivity |
| 34 implements FullScreenActivityTab.TopControlsVisibilityDelegate { |
| 35 private FullScreenActivityTab mTab; |
| 36 |
| 37 @Override |
| 38 protected void onNewIntent(Intent intent) { |
| 39 super.onNewIntent(intent); |
| 40 setIntent(intent); |
| 41 } |
| 42 |
| 43 @Override |
| 44 public void preInflationStartup() { |
| 45 super.preInflationStartup(); |
| 46 setTabModelSelector(new SingleTabModelSelector(this, false, true)); |
| 47 } |
| 48 |
| 49 @Override |
| 50 public void finishNativeInitialization() { |
| 51 mTab = FullScreenActivityTab.create( |
| 52 this, getWindowAndroid(), getActivityDirectory(), getSavedInstan
ceState(), this); |
| 53 getTabModelSelector().setTab(mTab); |
| 54 mTab.show(TabSelectionType.FROM_NEW); |
| 55 |
| 56 ControlContainer controlContainer = (ControlContainer) findViewById(R.id
.control_container); |
| 57 initializeCompositorContent(new LayoutManagerDocument(getCompositorViewH
older()), |
| 58 (View) controlContainer, (ViewGroup) findViewById(android.R.id.c
ontent), |
| 59 controlContainer); |
| 60 |
| 61 getActivityTab().setFullscreenManager(getFullscreenManager()); |
| 62 super.finishNativeInitialization(); |
| 63 } |
| 64 |
| 65 @Override |
| 66 public SingleTabModelSelector getTabModelSelector() { |
| 67 return (SingleTabModelSelector) super.getTabModelSelector(); |
| 68 } |
| 69 |
| 70 @Override |
| 71 public final FullScreenActivityTab getActivityTab() { |
| 72 return mTab; |
| 73 } |
| 74 |
| 75 /** |
| 76 * @return {@link File} pointing at a directory specific for this class. |
| 77 */ |
| 78 protected File getActivityDirectory() { |
| 79 return null; |
| 80 } |
| 81 |
| 82 // Implements {@link FullScreenActivityTab.TopControlsVisibilityDelegate}. |
| 83 @Override |
| 84 public boolean shouldShowTopControls(String url, int securityLevel) { |
| 85 return false; |
| 86 } |
| 87 |
| 88 @Override |
| 89 protected boolean handleBackPressed() { |
| 90 if (mTab == null) return false; |
| 91 if (mTab.canGoBack()) { |
| 92 mTab.goBack(); |
| 93 return true; |
| 94 } |
| 95 return false; |
| 96 } |
| 97 } |
OLD | NEW |