Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/FullscreenWebContentsActivity.java

Issue 2807663002: 📺 Move fullscreen web content to a new Activity. (Closed)
Patch Set: Got code into committable state. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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;
6
7 import android.app.Activity;
8 import android.content.ComponentName;
9 import android.content.Intent;
10 import android.provider.Browser;
11
12 import org.chromium.base.Log;
13 import org.chromium.chrome.R;
14 import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
15 import org.chromium.chrome.browser.tab.Tab;
16 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
17 import org.chromium.chrome.browser.tabmodel.TabReparentingParams;
18 import org.chromium.chrome.browser.util.IntentUtils;
19 import org.chromium.chrome.browser.webapps.FullScreenActivity;
20
21 /**
22 * An Activity used to display fullscreen WebContents.
23 */
24 public class FullscreenWebContentsActivity extends FullScreenActivity {
25 private static final String TAG = "FullWebConActivity";
26
27 @Override
28 protected Tab createTab() {
29 assert getIntent().hasExtra(IntentHandler.EXTRA_TAB_ID);
30
31 int tabId = IntentUtils.safeGetIntExtra(
32 getIntent(), IntentHandler.EXTRA_TAB_ID, Tab.INVALID_TAB_ID);
33 TabReparentingParams params = (TabReparentingParams) AsyncTabParamsManag er.remove(tabId);
34
35 Tab tab = params.getTabToReparent();
36 tab.attachAndFinishReparenting(this, createTabDelegateFactory(), params) ;
37 return tab;
38 }
39
40 @Override
41 protected int getControlContainerLayoutId() {
42 // TODO(peconn): Determine if there's something more suitable to use her e.
43 return R.layout.webapp_control_container;
44 }
45
46 @Override
47 protected ChromeFullscreenManager createFullscreenManager() {
48 // Create a Fullscreen manager that won't change the Tab's fullscreen st ate when the
49 // Activity ends - we handle leaving fullscreen ourselves.
50 return new ChromeFullscreenManager(this, false, false);
51 }
52
53 @Override
54 public boolean supportsFullscreenActivity() {
55 return true;
56 }
57
58 public static void toggleFullscreenMode(final boolean enableFullscreen, fina l Tab tab) {
59 if (tab.getFullscreenManager() == null) {
60 Log.w(TAG, "Cannot toggle fullscreen, manager is null.");
61 return;
62 }
63
64 if (tab.getFullscreenManager().getTab() == tab) {
65 tab.getFullscreenManager().setTab(null);
66 }
67
68 Runnable setFullscreen = new Runnable() {
69 @Override
70 public void run() {
71 // The Tab's FullscreenManager changes when it is moved.
72 tab.getFullscreenManager().setTab(tab);
73 tab.toggleFullscreenMode(enableFullscreen);
74 }
75 };
76
77 Intent intent = new Intent();
78 Activity activity = tab.getActivity();
79
80 if (enableFullscreen) {
81 // Send to the FullscreenWebContentsActivity.
82 intent.setClass(tab.getActivity(), FullscreenWebContentsActivity.cla ss);
83
84 intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getCo mponentName());
85 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
86 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Theresa 2017/04/26 18:32:11 Why do we need multiple task? Can there be multipl
PEConn 2017/04/27 08:53:11 I was thinking of the multiwindow case - we want t
Theresa 2017/04/27 15:32:25 I think that this flag will allow an unlimited num
87 } else {
88 // Send back to the Activity it came from.
89 ComponentName parent = IntentUtils.safeGetParcelableExtra(
90 activity.getIntent(), IntentHandler.EXTRA_PARENT_COMPONENT);
91 if (parent != null) {
92 intent.setComponent(parent);
93 } else {
94 Log.d(TAG, "Cannot return fullscreen tab to parent Activity.");
95 intent.setClass(activity, ChromeTabbedActivity.class);
Theresa 2017/04/26 18:32:11 We should probably send this back through ChromeLa
PEConn 2017/04/27 08:53:11 Done.
96 }
97
98 // TODO(peconn): Deal with tricky multiwindow scenarios.
99 }
100 intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName()) ;
101
102 tab.detachAndStartReparenting(intent, null, setFullscreen);
103 }
104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698