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

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

Issue 1303023002: Use third_party/custom_tabs_client as the src for customtabs library (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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.customtabs; 5 package org.chromium.chrome.browser.customtabs;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.content.pm.ResolveInfo; 9 import android.content.pm.ResolveInfo;
10 import android.os.IBinder;
11 import android.os.SystemClock; 10 import android.os.SystemClock;
12 import android.os.TransactionTooLargeException; 11 import android.os.TransactionTooLargeException;
13 import android.support.customtabs.CustomTabsCallback; 12 import android.support.customtabs.CustomTabsCallback;
13 import android.support.customtabs.CustomTabsSessionToken;
14 import android.text.TextUtils; 14 import android.text.TextUtils;
15 import android.view.ContextMenu; 15 import android.view.ContextMenu;
16 import android.view.Menu; 16 import android.view.Menu;
17 17
18 import org.chromium.base.Log; 18 import org.chromium.base.Log;
19 import org.chromium.base.VisibleForTesting; 19 import org.chromium.base.VisibleForTesting;
20 import org.chromium.base.metrics.RecordHistogram; 20 import org.chromium.base.metrics.RecordHistogram;
21 import org.chromium.chrome.R; 21 import org.chromium.chrome.R;
22 import org.chromium.chrome.browser.ChromeActivity; 22 import org.chromium.chrome.browser.ChromeActivity;
23 import org.chromium.chrome.browser.UrlUtilities; 23 import org.chromium.chrome.browser.UrlUtilities;
(...skipping 15 matching lines...) Expand all
39 import org.chromium.ui.base.WindowAndroid; 39 import org.chromium.ui.base.WindowAndroid;
40 40
41 import java.util.concurrent.TimeUnit; 41 import java.util.concurrent.TimeUnit;
42 42
43 /** 43 /**
44 * A chrome tab that is only used as a custom tab. 44 * A chrome tab that is only used as a custom tab.
45 */ 45 */
46 public class CustomTab extends ChromeTab { 46 public class CustomTab extends ChromeTab {
47 private static class CustomTabObserver extends EmptyTabObserver { 47 private static class CustomTabObserver extends EmptyTabObserver {
48 private CustomTabsConnection mCustomTabsConnection; 48 private CustomTabsConnection mCustomTabsConnection;
49 private IBinder mSession; 49 private CustomTabsSessionToken mSession;
50 private long mIntentReceivedTimestamp; 50 private long mIntentReceivedTimestamp;
51 private long mPageLoadStartedTimestamp; 51 private long mPageLoadStartedTimestamp;
52 52
53 private static final int STATE_RESET = 0; 53 private static final int STATE_RESET = 0;
54 private static final int STATE_WAITING_LOAD_START = 1; 54 private static final int STATE_WAITING_LOAD_START = 1;
55 private static final int STATE_WAITING_LOAD_FINISH = 2; 55 private static final int STATE_WAITING_LOAD_FINISH = 2;
56 private int mCurrentState; 56 private int mCurrentState;
57 57
58 public CustomTabObserver(CustomTabsConnection customTabsConnection, IBin der session) { 58 public CustomTabObserver(
59 CustomTabsConnection customTabsConnection, CustomTabsSessionToke n session) {
59 mCustomTabsConnection = customTabsConnection; 60 mCustomTabsConnection = customTabsConnection;
60 mSession = session; 61 mSession = session;
61 resetPageLoadTracking(); 62 resetPageLoadTracking();
62 } 63 }
63 64
64 /** 65 /**
65 * Tracks the next page load, with timestamp as the origin of time. 66 * Tracks the next page load, with timestamp as the origin of time.
66 */ 67 */
67 public void trackNextPageLoadFromTimestamp(long timestamp) { 68 public void trackNextPageLoadFromTimestamp(long timestamp) {
68 mIntentReceivedTimestamp = timestamp; 69 mIntentReceivedTimestamp = timestamp;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 }; 152 };
152 153
153 private CustomTabObserver mTabObserver; 154 private CustomTabObserver mTabObserver;
154 private final boolean mEnableUrlBarHiding; 155 private final boolean mEnableUrlBarHiding;
155 156
156 /** 157 /**
157 * Construct an CustomTab. Note that url and referrer given here is only use d to retrieve a 158 * Construct an CustomTab. Note that url and referrer given here is only use d to retrieve a
158 * prerendered web contents if it exists. It might load a prerendered {@link WebContents} for 159 * prerendered web contents if it exists. It might load a prerendered {@link WebContents} for
159 * the URL, if {@link CustomTabsConnectionService} has successfully warmed u p for the url. 160 * the URL, if {@link CustomTabsConnectionService} has successfully warmed u p for the url.
160 */ 161 */
161 public CustomTab(ChromeActivity activity, WindowAndroid windowAndroid, IBind er session, 162 public CustomTab(ChromeActivity activity, WindowAndroid windowAndroid,
162 String url, String referrer, int parentTabId, boolean enableUrlBarHi ding) { 163 CustomTabsSessionToken session, String url, String referrer,
164 int parentTabId, boolean enableUrlBarHiding) {
163 super(TabIdManager.getInstance().generateValidId(Tab.INVALID_TAB_ID), ac tivity, false, 165 super(TabIdManager.getInstance().generateValidId(Tab.INVALID_TAB_ID), ac tivity, false,
164 windowAndroid, TabLaunchType.FROM_EXTERNAL_APP, parentTabId, nul l, null); 166 windowAndroid, TabLaunchType.FROM_EXTERNAL_APP, parentTabId, nul l, null);
165 mEnableUrlBarHiding = enableUrlBarHiding; 167 mEnableUrlBarHiding = enableUrlBarHiding;
166 CustomTabsConnection customTabsConnection = 168 CustomTabsConnection customTabsConnection =
167 CustomTabsConnection.getInstance(activity.getApplication()); 169 CustomTabsConnection.getInstance(activity.getApplication());
168 WebContents webContents = customTabsConnection.takePrerenderedUrl(sessio n, url, referrer); 170 WebContents webContents = customTabsConnection.takePrerenderedUrl(sessio n, url, referrer);
169 if (webContents == null) { 171 if (webContents == null) {
170 webContents = WebContentsFactory.createWebContents(isIncognito(), fa lse); 172 webContents = WebContentsFactory.createWebContents(isIncognito(), fa lse);
171 } 173 }
172 initialize(webContents, activity.getTabContentManager(), false); 174 initialize(webContents, activity.getTabContentManager(), false);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 // See http://crbug.com/369574. 330 // See http://crbug.com/369574.
329 if (e.getCause() instanceof TransactionTooLargeException) { 331 if (e.getCause() instanceof TransactionTooLargeException) {
330 Log.e(TAG, "Could not resolve Activity for intent " + intent.toS tring(), e); 332 Log.e(TAG, "Could not resolve Activity for intent " + intent.toS tring(), e);
331 } else { 333 } else {
332 throw e; 334 throw e;
333 } 335 }
334 } 336 }
335 } 337 }
336 338
337 } 339 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698