Commit 390a089d authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Commit Bot

PageInfoController: signatures changed from Tab to WebContents

Why:
Currently, PageInfo shows the page-info dialog for Tab only. Since we
would like the dialog works for WebContents in general. We want to
refactor PageInfoController to depend on WebContents rather than Tab.
This patch is part of the effort.

Change:
* getOfflinePage() depends on Tab -> WebContents
* isShowingTrustedOfflinePage() depends on Tab -> WebContents
* TabImpl.getProfile() -> Profile.fromWebContents()
* Activity -> ChromeActivity, because ConnectionInfoPopup.show()
depends on ChromeActivity.

Bug: 999196
Change-Id: Idb432edbbdb839d1b3cae2bfced6a4343861e7d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1960565Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#723536}
parent e571337e
...@@ -330,7 +330,7 @@ public class OfflinePageTabObserver ...@@ -330,7 +330,7 @@ public class OfflinePageTabObserver
RecordUserAction.record("OfflinePages.ReloadButtonClicked"); RecordUserAction.record("OfflinePages.ReloadButtonClicked");
Tab foundTab = tabModelSelector.getTabById(tabId); Tab foundTab = tabModelSelector.getTabById(tabId);
if (foundTab == null) return; if (foundTab == null) return;
if (!OfflinePageUtils.isShowingTrustedOfflinePage(foundTab)) { if (!OfflinePageUtils.isShowingTrustedOfflinePage(foundTab.getWebContents())) {
RecordUserAction.record("OfflinePages.ReloadButtonClickedViewingUntrustedPage"); RecordUserAction.record("OfflinePages.ReloadButtonClickedViewingUntrustedPage");
} }
// Delegates to Tab to reload the page. Tab will send the correct header in order to // Delegates to Tab to reload the page. Tab will send the correct header in order to
......
...@@ -118,7 +118,7 @@ public class OfflinePageUtils { ...@@ -118,7 +118,7 @@ public class OfflinePageUtils {
* @param tab The current tab. * @param tab The current tab.
* @return True if a trusted offline page is shown in the tab. * @return True if a trusted offline page is shown in the tab.
*/ */
boolean isShowingTrustedOfflinePage(Tab tab); boolean isShowingTrustedOfflinePage(WebContents webContents);
/** /**
* Returns whether the tab is showing offline preview. * Returns whether the tab is showing offline preview.
...@@ -187,16 +187,13 @@ public class OfflinePageUtils { ...@@ -187,16 +187,13 @@ public class OfflinePageUtils {
} }
@Override @Override
public boolean isShowingTrustedOfflinePage(Tab tab) { public boolean isShowingTrustedOfflinePage(WebContents webContents) {
if (tab == null) return false;
WebContents webContents = tab.getWebContents();
if (webContents == null) return false; if (webContents == null) return false;
OfflinePageBridge offlinePageBridge = OfflinePageBridge offlinePageBridge =
getOfflinePageBridge(((TabImpl) tab).getProfile()); getOfflinePageBridge(Profile.fromWebContents(webContents));
if (offlinePageBridge == null) return false; if (offlinePageBridge == null) return false;
return offlinePageBridge.isShowingTrustedOfflinePage(tab.getWebContents()); return offlinePageBridge.isShowingTrustedOfflinePage(webContents);
} }
} }
...@@ -619,14 +616,14 @@ public class OfflinePageUtils { ...@@ -619,14 +616,14 @@ public class OfflinePageUtils {
/** /**
* Retrieves the extra request header to reload the offline page. * Retrieves the extra request header to reload the offline page.
* @param tab The current tab. * @param webContents The current WebContents.
* @return The extra request header string. * @return The extra request header string.
*/ */
public static String getOfflinePageHeaderForReload(Tab tab) { public static String getOfflinePageHeaderForReload(WebContents webContents) {
OfflinePageBridge offlinePageBridge = OfflinePageBridge offlinePageBridge =
getInstance().getOfflinePageBridge(((TabImpl) tab).getProfile()); getInstance().getOfflinePageBridge(Profile.fromWebContents(webContents));
if (offlinePageBridge == null) return ""; if (offlinePageBridge == null) return "";
return offlinePageBridge.getOfflinePageHeaderForReload(tab.getWebContents()); return offlinePageBridge.getOfflinePageHeaderForReload(webContents);
} }
/** /**
...@@ -689,26 +686,25 @@ public class OfflinePageUtils { ...@@ -689,26 +686,25 @@ public class OfflinePageUtils {
} }
/** /**
* Retrieves the offline page that is shown for the tab. * Retrieves the offline page that is shown for the web-content.
* @param tab The tab to be reloaded. * @param webContents The WebContents to be reloaded.
* @return The offline page if tab currently displays it, null otherwise. * @return The offline page if tab currently displays it, null otherwise.
*/ */
public static OfflinePageItem getOfflinePage(Tab tab) { public static OfflinePageItem getOfflinePage(WebContents webContents) {
WebContents webContents = tab.getWebContents();
if (webContents == null) return null; if (webContents == null) return null;
OfflinePageBridge offlinePageBridge = OfflinePageBridge offlinePageBridge =
getInstance().getOfflinePageBridge(((TabImpl) tab).getProfile()); getInstance().getOfflinePageBridge(Profile.fromWebContents(webContents));
if (offlinePageBridge == null) return null; if (offlinePageBridge == null) return null;
return offlinePageBridge.getOfflinePage(webContents); return offlinePageBridge.getOfflinePage(webContents);
} }
/** /**
* Returns whether the tab is showing a trusted offline page. * Returns whether the WebContents is showing trusted offline page.
* @param tab The current tab. * @param webContents The current WebContents.
* @return True if the tab is showing a trusted offline page. * @return True if a trusted offline page is shown in the webContents.
*/ */
public static boolean isShowingTrustedOfflinePage(Tab tab) { public static boolean isShowingTrustedOfflinePage(WebContents webContents) {
return getInstance().isShowingTrustedOfflinePage(tab); return getInstance().isShowingTrustedOfflinePage(webContents);
} }
/** /**
...@@ -716,19 +712,20 @@ public class OfflinePageUtils { ...@@ -716,19 +712,20 @@ public class OfflinePageUtils {
* @param tab The tab to be reloaded. * @param tab The tab to be reloaded.
*/ */
public static void reload(Tab tab) { public static void reload(Tab tab) {
WebContents webContents = tab.getWebContents();
// Only the transition type with both RELOAD and FROM_ADDRESS_BAR set will force the // Only the transition type with both RELOAD and FROM_ADDRESS_BAR set will force the
// navigation to be treated as reload (see ShouldTreatNavigationAsReload()). Without this, // navigation to be treated as reload (see ShouldTreatNavigationAsReload()). Without this,
// reloading an URL containing a hash will be treated as same document load and thus // reloading an URL containing a hash will be treated as same document load and thus
// no loading is triggered. // no loading is triggered.
int transitionTypeForReload = PageTransition.RELOAD | PageTransition.FROM_ADDRESS_BAR; int transitionTypeForReload = PageTransition.RELOAD | PageTransition.FROM_ADDRESS_BAR;
OfflinePageItem offlinePage = getOfflinePage(tab); OfflinePageItem offlinePage = getOfflinePage(webContents);
if (isShowingTrustedOfflinePage(tab) || offlinePage == null) { if (isShowingTrustedOfflinePage(tab.getWebContents()) || offlinePage == null) {
// If current page is an offline page, reload it with custom behavior defined in extra // If current page is an offline page, reload it with custom behavior defined in extra
// header respected. // header respected.
LoadUrlParams params = LoadUrlParams params =
new LoadUrlParams(((TabImpl) tab).getOriginalUrl(), transitionTypeForReload); new LoadUrlParams(((TabImpl) tab).getOriginalUrl(), transitionTypeForReload);
params.setVerbatimHeaders(getOfflinePageHeaderForReload(tab)); params.setVerbatimHeaders(getOfflinePageHeaderForReload(webContents));
tab.loadUrl(params); tab.loadUrl(params);
return; return;
} }
...@@ -832,7 +829,7 @@ public class OfflinePageUtils { ...@@ -832,7 +829,7 @@ public class OfflinePageUtils {
// We first compute the bitwise tab restore context. // We first compute the bitwise tab restore context.
int tabRestoreContext = 0; int tabRestoreContext = 0;
if (isConnected()) tabRestoreContext |= BIT_ONLINE; if (isConnected()) tabRestoreContext |= BIT_ONLINE;
OfflinePageItem page = getOfflinePage(tab); OfflinePageItem page = getOfflinePage(tab.getWebContents());
if (page != null) { if (page != null) {
tabRestoreContext |= BIT_OFFLINE_PAGE; tabRestoreContext |= BIT_OFFLINE_PAGE;
if (page.getClientId().getNamespace().equals(OfflinePageBridge.LAST_N_NAMESPACE)) { if (page.getClientId().getNamespace().equals(OfflinePageBridge.LAST_N_NAMESPACE)) {
......
...@@ -23,9 +23,8 @@ import org.chromium.base.Log; ...@@ -23,9 +23,8 @@ import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods; import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ResourceId; import org.chromium.chrome.browser.ResourceId;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.chrome.browser.vr.UiUnsupportedMode; import org.chromium.chrome.browser.vr.UiUnsupportedMode;
import org.chromium.chrome.browser.vr.VrModuleProvider; import org.chromium.chrome.browser.vr.VrModuleProvider;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
...@@ -62,10 +61,11 @@ public class ConnectionInfoPopup implements OnClickListener, ModalDialogProperti ...@@ -62,10 +61,11 @@ public class ConnectionInfoPopup implements OnClickListener, ModalDialogProperti
private Button mResetCertDecisionsButton; private Button mResetCertDecisionsButton;
private String mLinkUrl; private String mLinkUrl;
private ConnectionInfoPopup(Context context, Tab tab) { private ConnectionInfoPopup(
Context context, ModalDialogManager modalDialogManager, WebContents webContents) {
mContext = context; mContext = context;
mModalDialogManager = ((TabImpl) tab).getActivity().getModalDialogManager(); mModalDialogManager = modalDialogManager;
mWebContents = tab.getWebContents(); mWebContents = webContents;
mCertificateViewer = new CertificateViewer(mContext); mCertificateViewer = new CertificateViewer(mContext);
...@@ -259,11 +259,10 @@ public class ConnectionInfoPopup implements OnClickListener, ModalDialogProperti ...@@ -259,11 +259,10 @@ public class ConnectionInfoPopup implements OnClickListener, ModalDialogProperti
* visible. * visible.
* *
* @param context Context which is used for launching a dialog. * @param context Context which is used for launching a dialog.
* @param tab The tab hosting the web contents for which to show website information. This * @param webContents The WebContents for which to show website information
* information is retrieved for the visible entry.
*/ */
public static void show(Context context, Tab tab) { public static void show(ChromeActivity context, WebContents webContents) {
new ConnectionInfoPopup(context, tab); new ConnectionInfoPopup(context, context.getModalDialogManager(), webContents);
} }
@NativeMethods @NativeMethods
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
package org.chromium.chrome.browser.page_info; package org.chromium.chrome.browser.page_info;
import android.app.Activity;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -28,6 +27,7 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -28,6 +27,7 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods; import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.instantapps.InstantAppsHandler; import org.chromium.chrome.browser.instantapps.InstantAppsHandler;
import org.chromium.chrome.browser.offlinepages.OfflinePageItem; import org.chromium.chrome.browser.offlinepages.OfflinePageItem;
...@@ -155,7 +155,7 @@ public class PageInfoController ...@@ -155,7 +155,7 @@ public class PageInfoController
* @param previewPageState State of the tab showing the preview. * @param previewPageState State of the tab showing the preview.
* @param publisher The name of the content publisher, if any. * @param publisher The name of the content publisher, if any.
*/ */
protected PageInfoController(Activity activity, Tab tab, int securityLevel, protected PageInfoController(ChromeActivity activity, Tab tab, int securityLevel,
String offlinePageUrl, String offlinePageCreationDate, String offlinePageUrl, String offlinePageCreationDate,
@OfflinePageState int offlinePageState, @PreviewPageState int previewPageState, @OfflinePageState int offlinePageState, @PreviewPageState int previewPageState,
String publisher) { String publisher) {
...@@ -372,7 +372,7 @@ public class PageInfoController ...@@ -372,7 +372,7 @@ public class PageInfoController
// Display the appropriate connection message. // Display the appropriate connection message.
SpannableStringBuilder messageBuilder = new SpannableStringBuilder(); SpannableStringBuilder messageBuilder = new SpannableStringBuilder();
Context context = mWindowAndroid.getActivity().get(); ChromeActivity context = (ChromeActivity) mWindowAndroid.getActivity().get();
assert context != null; assert context != null;
if (mContentPublisher != null) { if (mContentPublisher != null) {
messageBuilder.append( messageBuilder.append(
...@@ -424,7 +424,7 @@ public class PageInfoController ...@@ -424,7 +424,7 @@ public class PageInfoController
runAfterDismiss(() -> { runAfterDismiss(() -> {
if (!mTab.getWebContents().isDestroyed()) { if (!mTab.getWebContents().isDestroyed()) {
recordAction(PageInfoAction.PAGE_INFO_SECURITY_DETAILS_OPENED); recordAction(PageInfoAction.PAGE_INFO_SECURITY_DETAILS_OPENED);
ConnectionInfoPopup.show(context, mTab); ConnectionInfoPopup.show(context, mTab.getWebContents());
} }
}); });
}; };
...@@ -513,8 +513,8 @@ public class PageInfoController ...@@ -513,8 +513,8 @@ public class PageInfoController
* @param contentPublisher The name of the publisher of the content. * @param contentPublisher The name of the publisher of the content.
* @param source Determines the source that triggered the popup. * @param source Determines the source that triggered the popup.
*/ */
public static void show(final Activity activity, final Tab tab, final String contentPublisher, public static void show(final ChromeActivity activity, final Tab tab,
@OpenedFromSource int source) { final String contentPublisher, @OpenedFromSource int source) {
// If the activity's decor view is not attached to window, we don't show the dialog because // If the activity's decor view is not attached to window, we don't show the dialog because
// the window manager might have revoked the window token for this activity. See // the window manager might have revoked the window token for this activity. See
// https://crbug.com/921450. // https://crbug.com/921450.
...@@ -531,18 +531,18 @@ public class PageInfoController ...@@ -531,18 +531,18 @@ public class PageInfoController
assert false : "Invalid source passed"; assert false : "Invalid source passed";
} }
final int securityLevel = WebContents webContents = tab.getWebContents();
SecurityStateModel.getSecurityLevelForWebContents(tab.getWebContents()); final int securityLevel = SecurityStateModel.getSecurityLevelForWebContents(webContents);
@PreviewPageState @PreviewPageState
int previewPageState = PreviewPageState.NOT_PREVIEW; int previewPageState = PreviewPageState.NOT_PREVIEW;
final PreviewsAndroidBridge bridge = PreviewsAndroidBridge.getInstance(); final PreviewsAndroidBridge bridge = PreviewsAndroidBridge.getInstance();
if (bridge.shouldShowPreviewUI(tab.getWebContents())) { if (bridge.shouldShowPreviewUI(webContents)) {
previewPageState = securityLevel == ConnectionSecurityLevel.SECURE previewPageState = securityLevel == ConnectionSecurityLevel.SECURE
? PreviewPageState.SECURE_PAGE_PREVIEW ? PreviewPageState.SECURE_PAGE_PREVIEW
: PreviewPageState.INSECURE_PAGE_PREVIEW; : PreviewPageState.INSECURE_PAGE_PREVIEW;
PreviewsUma.recordPageInfoOpened(bridge.getPreviewsType(tab.getWebContents())); PreviewsUma.recordPageInfoOpened(bridge.getPreviewsType(webContents));
Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile()); Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile());
tracker.notifyEvent(EventConstants.PREVIEWS_VERBOSE_STATUS_OPENED); tracker.notifyEvent(EventConstants.PREVIEWS_VERBOSE_STATUS_OPENED);
} }
...@@ -552,10 +552,10 @@ public class PageInfoController ...@@ -552,10 +552,10 @@ public class PageInfoController
@OfflinePageState @OfflinePageState
int offlinePageState = OfflinePageState.NOT_OFFLINE_PAGE; int offlinePageState = OfflinePageState.NOT_OFFLINE_PAGE;
OfflinePageItem offlinePage = OfflinePageUtils.getOfflinePage(tab); OfflinePageItem offlinePage = OfflinePageUtils.getOfflinePage(webContents);
if (offlinePage != null) { if (offlinePage != null) {
offlinePageUrl = offlinePage.getUrl(); offlinePageUrl = offlinePage.getUrl();
if (OfflinePageUtils.isShowingTrustedOfflinePage(tab)) { if (OfflinePageUtils.isShowingTrustedOfflinePage(webContents)) {
offlinePageState = OfflinePageState.TRUSTED_OFFLINE_PAGE; offlinePageState = OfflinePageState.TRUSTED_OFFLINE_PAGE;
} else { } else {
offlinePageState = OfflinePageState.UNTRUSTED_OFFLINE_PAGE; offlinePageState = OfflinePageState.UNTRUSTED_OFFLINE_PAGE;
......
...@@ -15,6 +15,7 @@ import org.chromium.chrome.browser.settings.website.SingleWebsitePreferences; ...@@ -15,6 +15,7 @@ import org.chromium.chrome.browser.settings.website.SingleWebsitePreferences;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabImpl; import org.chromium.chrome.browser.tab.TabImpl;
import org.chromium.chrome.browser.util.UrlConstants; import org.chromium.chrome.browser.util.UrlConstants;
import org.chromium.content_public.browser.WebContents;
import org.chromium.net.GURLUtils; import org.chromium.net.GURLUtils;
/** /**
...@@ -26,9 +27,10 @@ public class SiteSettingsHelper { ...@@ -26,9 +27,10 @@ public class SiteSettingsHelper {
* Whether site settings is available for a given {@link Tab}. * Whether site settings is available for a given {@link Tab}.
*/ */
public static boolean isSiteSettingsAvailable(Tab tab) { public static boolean isSiteSettingsAvailable(Tab tab) {
boolean isOfflinePage = OfflinePageUtils.getOfflinePage(tab) != null; WebContents webContents = tab.getWebContents();
boolean isOfflinePage = OfflinePageUtils.getOfflinePage(webContents) != null;
boolean isPreviewPage = boolean isPreviewPage =
PreviewsAndroidBridge.getInstance().shouldShowPreviewUI(tab.getWebContents()); PreviewsAndroidBridge.getInstance().shouldShowPreviewUI(webContents);
String scheme = GURLUtils.getScheme(((TabImpl) tab).getOriginalUrl()); String scheme = GURLUtils.getScheme(((TabImpl) tab).getOriginalUrl());
return !isOfflinePage && !isPreviewPage return !isOfflinePage && !isPreviewPage
&& (UrlConstants.HTTP_SCHEME.equals(scheme) && (UrlConstants.HTTP_SCHEME.equals(scheme)
......
...@@ -184,7 +184,7 @@ public class LocationBarModel implements ToolbarDataProvider, ToolbarCommonPrope ...@@ -184,7 +184,7 @@ public class LocationBarModel implements ToolbarDataProvider, ToolbarCommonPrope
DomDistillerTabUtils.getFormattedUrlFromOriginalDistillerUrl(originalUrl)); DomDistillerTabUtils.getFormattedUrlFromOriginalDistillerUrl(originalUrl));
// Clear the editing text for untrusted offline pages. // Clear the editing text for untrusted offline pages.
if (!OfflinePageUtils.isShowingTrustedOfflinePage(mTab)) { if (!OfflinePageUtils.isShowingTrustedOfflinePage(mTab.getWebContents())) {
return buildUrlBarData(url, formattedUrl, ""); return buildUrlBarData(url, formattedUrl, "");
} }
......
...@@ -45,6 +45,7 @@ import org.chromium.base.metrics.RecordUserAction; ...@@ -45,6 +45,7 @@ import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.task.PostTask; import org.chromium.base.task.PostTask;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.WindowDelegate; import org.chromium.chrome.browser.WindowDelegate;
import org.chromium.chrome.browser.native_page.NativePage; import org.chromium.chrome.browser.native_page.NativePage;
import org.chromium.chrome.browser.native_page.NativePageFactory; import org.chromium.chrome.browser.native_page.NativePageFactory;
...@@ -594,8 +595,8 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL ...@@ -594,8 +595,8 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL
if (currentTab == null || currentTab.getWebContents() == null) return; if (currentTab == null || currentTab.getWebContents() == null) return;
Activity activity = currentTab.getWindowAndroid().getActivity().get(); Activity activity = currentTab.getWindowAndroid().getActivity().get();
if (activity == null) return; if (activity == null) return;
PageInfoController.show(activity, currentTab, getContentPublisher(), PageInfoController.show((ChromeActivity) activity, currentTab,
PageInfoController.OpenedFromSource.TOOLBAR); getContentPublisher(), PageInfoController.OpenedFromSource.TOOLBAR);
}); });
} }
......
...@@ -383,7 +383,7 @@ public class OfflinePageUtilsTest { ...@@ -383,7 +383,7 @@ public class OfflinePageUtilsTest {
final AtomicReference<OfflinePageItem> offlinePageItem = new AtomicReference<>(); final AtomicReference<OfflinePageItem> offlinePageItem = new AtomicReference<>();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
offlinePageItem.set(OfflinePageUtils.getOfflinePage( offlinePageItem.set(OfflinePageUtils.getOfflinePage(
mActivityTestRule.getActivity().getActivityTab())); mActivityTestRule.getActivity().getActivityTab().getWebContents()));
}); });
Assert.assertEquals("http://www.example.com/", offlinePageItem.get().getUrl()); Assert.assertEquals("http://www.example.com/", offlinePageItem.get().getUrl());
...@@ -424,7 +424,7 @@ public class OfflinePageUtilsTest { ...@@ -424,7 +424,7 @@ public class OfflinePageUtilsTest {
final AtomicReference<OfflinePageItem> offlinePageItem = new AtomicReference<>(); final AtomicReference<OfflinePageItem> offlinePageItem = new AtomicReference<>();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
offlinePageItem.set(OfflinePageUtils.getOfflinePage( offlinePageItem.set(OfflinePageUtils.getOfflinePage(
mActivityTestRule.getActivity().getActivityTab())); mActivityTestRule.getActivity().getActivityTab().getWebContents()));
}); });
// The Offline Page Item will be empty because no data can be extracted from the renderer. // The Offline Page Item will be empty because no data can be extracted from the renderer.
...@@ -448,7 +448,7 @@ public class OfflinePageUtilsTest { ...@@ -448,7 +448,7 @@ public class OfflinePageUtilsTest {
final AtomicReference<OfflinePageItem> offlinePageItem = new AtomicReference<>(); final AtomicReference<OfflinePageItem> offlinePageItem = new AtomicReference<>();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
offlinePageItem.set(OfflinePageUtils.getOfflinePage( offlinePageItem.set(OfflinePageUtils.getOfflinePage(
mActivityTestRule.getActivity().getActivityTab())); mActivityTestRule.getActivity().getActivityTab().getWebContents()));
}); });
Assert.assertEquals(testUrl, offlinePageItem.get().getUrl()); Assert.assertEquals(testUrl, offlinePageItem.get().getUrl());
...@@ -470,7 +470,7 @@ public class OfflinePageUtilsTest { ...@@ -470,7 +470,7 @@ public class OfflinePageUtilsTest {
final AtomicReference<OfflinePageItem> offlinePageItem = new AtomicReference<>(); final AtomicReference<OfflinePageItem> offlinePageItem = new AtomicReference<>();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
offlinePageItem.set(OfflinePageUtils.getOfflinePage( offlinePageItem.set(OfflinePageUtils.getOfflinePage(
mActivityTestRule.getActivity().getActivityTab())); mActivityTestRule.getActivity().getActivityTab().getWebContents()));
}); });
Assert.assertEquals(testUrl, offlinePageItem.get().getUrl()); Assert.assertEquals(testUrl, offlinePageItem.get().getUrl());
...@@ -497,7 +497,7 @@ public class OfflinePageUtilsTest { ...@@ -497,7 +497,7 @@ public class OfflinePageUtilsTest {
// Verify that we are currently showing a trusted page. // Verify that we are currently showing a trusted page.
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
Assert.assertTrue(OfflinePageUtils.isShowingTrustedOfflinePage( Assert.assertTrue(OfflinePageUtils.isShowingTrustedOfflinePage(
mActivityTestRule.getActivity().getActivityTab())); mActivityTestRule.getActivity().getActivityTab().getWebContents()));
}); });
} }
......
...@@ -39,7 +39,8 @@ public class ConnectionInfoPopupTest { ...@@ -39,7 +39,8 @@ public class ConnectionInfoPopupTest {
public void testShow() throws InterruptedException { public void testShow() throws InterruptedException {
mActivityTestRule.startMainActivityOnBlankPage(); mActivityTestRule.startMainActivityOnBlankPage();
TestThreadUtils.runOnUiThreadBlocking( TestThreadUtils.runOnUiThreadBlocking(
() -> ConnectionInfoPopup.show(mActivityTestRule.getActivity(), ()
mActivityTestRule.getActivity().getActivityTab())); -> ConnectionInfoPopup.show(mActivityTestRule.getActivity(),
mActivityTestRule.getActivity().getActivityTab().getWebContents()));
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment