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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/FullScreenActivityTab.java

Issue 1416093004: Remove CustomTab and have all CustomTabActivity using Tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed clang build error Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/FullScreenActivityTab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/FullScreenActivityTab.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/FullScreenActivityTab.java
index edfddbd181bfad7bfeeb301993c4d5ef5e4cdbf4..3c3f1415c0b052095698371be0b36b6730148a74 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/FullScreenActivityTab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/FullScreenActivityTab.java
@@ -4,36 +4,22 @@
package org.chromium.chrome.browser.webapps;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
import android.os.Bundle;
import android.os.StrictMode;
-import android.text.TextUtils;
import android.util.Log;
-import android.view.ContextMenu;
-import android.view.Menu;
import org.chromium.base.StreamUtil;
import org.chromium.base.annotations.SuppressFBWarnings;
-import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
-import org.chromium.chrome.browser.IntentHandler;
-import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.TabState;
-import org.chromium.chrome.browser.UrlUtilities;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
-import org.chromium.chrome.browser.contextmenu.ContextMenuHelper;
-import org.chromium.chrome.browser.contextmenu.ContextMenuParams;
-import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator;
import org.chromium.chrome.browser.tab.Tab;
+import org.chromium.chrome.browser.tab.TabDelegateFactory;
import org.chromium.chrome.browser.tab.TabUma.TabCreationState;
-import org.chromium.chrome.browser.tab.TabWebContentsDelegateAndroid;
import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsObserver;
-import org.chromium.ui.base.Clipboard;
import org.chromium.ui.base.PageTransition;
import org.chromium.ui.base.WindowAndroid;
@@ -42,7 +28,6 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.net.URI;
/**
* A tab that will be used for FullScreenActivity. See {@link FullScreenActivity} for more.
@@ -89,7 +74,7 @@ public class FullScreenActivityTab extends Tab {
private void initializeFullScreenActivityTab(TabContentManager tabContentManager,
boolean unfreeze, TopControlsVisibilityDelegate topControlsVisibilityDelegate) {
- initialize(null, tabContentManager, false);
+ initialize(null, tabContentManager, new TabDelegateFactory(), false);
if (unfreeze) unfreezeContents();
mObserver = createWebContentsObserver();
mTopControlsVisibilityDelegate = topControlsVisibilityDelegate;
@@ -214,84 +199,6 @@ public class FullScreenActivityTab extends Tab {
}
@Override
- protected ContextMenuPopulator createContextMenuPopulator() {
- return new ContextMenuPopulator() {
- private final Clipboard mClipboard;
-
- // public ContextMenuPopulator()
- {
- mClipboard = new Clipboard(getApplicationContext());
- }
-
- @Override
- public boolean shouldShowContextMenu(ContextMenuParams params) {
- return params != null && params.isAnchor();
- }
-
- @Override
- public boolean onItemSelected(ContextMenuHelper helper, ContextMenuParams params,
- int itemId) {
- if (itemId == org.chromium.chrome.R.id.contextmenu_copy_link_address) {
- String url = params.getUnfilteredLinkUrl();
- mClipboard.setText(url, url);
- return true;
- } else if (itemId == org.chromium.chrome.R.id.contextmenu_copy_link_text) {
- String text = params.getLinkText();
- mClipboard.setText(text, text);
- return true;
- } else if (itemId == R.id.menu_id_open_in_chrome) {
- // TODO(dfalcantara): Merge into the TabDelegate. (https://crbug.com/451453)
- Intent chromeIntent =
- new Intent(Intent.ACTION_VIEW, Uri.parse(params.getLinkUrl()));
- chromeIntent.setPackage(getApplicationContext().getPackageName());
- chromeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- boolean activityStarted = false;
- if (params.getPageUrl() != null) {
- try {
- URI pageUri = URI.create(params.getPageUrl());
- if (UrlUtilities.isInternalScheme(pageUri)) {
- IntentHandler.startChromeLauncherActivityForTrustedIntent(
- chromeIntent, getApplicationContext());
- activityStarted = true;
- }
- } catch (IllegalArgumentException ex) {
- // Ignore the exception for creating the URI and launch the intent
- // without the trusted intent extras.
- }
- }
-
- if (!activityStarted) {
- getApplicationContext().startActivity(chromeIntent);
- activityStarted = true;
- }
- return true;
- }
-
- return false;
- }
-
- @Override
- public void buildContextMenu(ContextMenu menu, Context context,
- ContextMenuParams params) {
- menu.add(Menu.NONE, org.chromium.chrome.R.id.contextmenu_copy_link_address,
- Menu.NONE, org.chromium.chrome.R.string.contextmenu_copy_link_address);
-
- String linkText = params.getLinkText();
- if (linkText != null) linkText = linkText.trim();
-
- if (!TextUtils.isEmpty(linkText)) {
- menu.add(Menu.NONE, org.chromium.chrome.R.id.contextmenu_copy_link_text,
- Menu.NONE, org.chromium.chrome.R.string.contextmenu_copy_link_text);
- }
-
- menu.add(Menu.NONE, R.id.menu_id_open_in_chrome, Menu.NONE,
- R.string.menu_open_in_chrome);
- }
- };
- }
-
- @Override
protected boolean isHidingTopControlsEnabled() {
if (getFullscreenManager() == null) return true;
if (getFullscreenManager().getPersistentFullscreenMode()) return true;
@@ -305,36 +212,4 @@ public class FullScreenActivityTab extends Tab {
// Users cannot change the visibility state by sliding it in or out.
return !isHidingTopControlsEnabled();
}
-
- @Override
- protected FullScreenTabWebContentsDelegateAndroid createWebContentsDelegate() {
- return new FullScreenTabWebContentsDelegateAndroid(this, mActivity);
- }
-
- private class FullScreenTabWebContentsDelegateAndroid extends TabWebContentsDelegateAndroid {
- public FullScreenTabWebContentsDelegateAndroid(Tab tab, ChromeActivity activity) {
- super(tab, activity);
- }
-
- @Override
- public void activateContents() {
- if (!(mActivity instanceof WebappActivity)) return;
-
- WebappInfo webappInfo = ((WebappActivity) mActivity).getWebappInfo();
- String url = webappInfo.uri().toString();
-
- // Create an Intent that will be fired toward the WebappLauncherActivity, which in turn
- // will fire an Intent to launch the correct WebappActivity. On L+ this could probably
- // be changed to call AppTask.moveToFront(), but for backwards compatibility we relaunch
- // it the hard way.
- Intent intent = new Intent();
- intent.setAction(WebappLauncherActivity.ACTION_START_WEBAPP);
- intent.setPackage(mActivity.getPackageName());
- webappInfo.setWebappIntentExtras(intent);
-
- intent.putExtra(ShortcutHelper.EXTRA_MAC, ShortcutHelper.getEncodedMac(mActivity, url));
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getApplicationContext().startActivity(intent);
- }
- }
}

Powered by Google App Engine
This is Rietveld 408576698