Commit 2f96e417 authored by Patrick Noland's avatar Patrick Noland Committed by Commit Bot

Revert "WebLayer: hook up CookieControlsBridge."

This reverts commit 0b009d85.

Reason for revert: Causes several tests to crash on Lollipop Tablet Tests (see e.g. https://luci-logdog.appspot.com/logs/chromium/android/swarming/logcats/4cfd793242a15611/+/logcat_logcat_org.chromium.chrome.browser.page_info.PageInfoViewTest.testShowWithPermissionsAndCookieBlocking_20200624T054824-UTC_09e0d212)

Original change's description:
> WebLayer: hook up CookieControlsBridge.
> 
> When enabled, and when third party cookies are being blocked, this will
> show an extra toggle in the page info bubble.
> 
> Test: run_weblayer_shell example.com --args="--enable-features=\"ImprovedCookieControls\""
> Bug: 1071775
> 
> Change-Id: Ib0a6d6a1c80cafa4b8aeeea19cb9919df55a7f83
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2240011
> Reviewed-by: Mugdha Lakhani <nator@chromium.org>
> Reviewed-by: Ted Choc <tedchoc@chromium.org>
> Reviewed-by: Christian Dullweber <dullweber@chromium.org>
> Commit-Queue: Evan Stade <estade@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#781552}

TBR=estade@chromium.org,tedchoc@chromium.org,dullweber@chromium.org,nator@chromium.org

Change-Id: I7594ba7b5b22dc2b402a5446d90645a9a26930e0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1071775
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2264199Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Commit-Queue: Patrick Noland <pnoland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781875}
parent 54d8c50a
...@@ -9,7 +9,6 @@ import android.content.Intent; ...@@ -9,7 +9,6 @@ import android.content.Intent;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
...@@ -57,6 +56,9 @@ public class ChromePageInfoControllerDelegate extends PageInfoControllerDelegate ...@@ -57,6 +56,9 @@ public class ChromePageInfoControllerDelegate extends PageInfoControllerDelegate
private String mOfflinePageCreationDate; private String mOfflinePageCreationDate;
private OfflinePageLoadUrlDelegate mOfflinePageLoadUrlDelegate; private OfflinePageLoadUrlDelegate mOfflinePageLoadUrlDelegate;
// Bridge updating the CookieControlsView when cookie settings change.
private CookieControlsBridge mBridge;
public ChromePageInfoControllerDelegate(Context context, WebContents webContents, public ChromePageInfoControllerDelegate(Context context, WebContents webContents,
Supplier<ModalDialogManager> modalDialogManagerSupplier, Supplier<ModalDialogManager> modalDialogManagerSupplier,
OfflinePageLoadUrlDelegate offlinePageLoadUrlDelegate) { OfflinePageLoadUrlDelegate offlinePageLoadUrlDelegate) {
...@@ -252,13 +254,28 @@ public class ChromePageInfoControllerDelegate extends PageInfoControllerDelegate ...@@ -252,13 +254,28 @@ public class ChromePageInfoControllerDelegate extends PageInfoControllerDelegate
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
@NonNull public void createCookieControlsBridge(CookieControlsObserver observer) {
public CookieControlsBridge createCookieControlsBridge(CookieControlsObserver observer) {
Profile profile = Profile.fromWebContents(mWebContents); Profile profile = Profile.fromWebContents(mWebContents);
return new CookieControlsBridge(observer, mWebContents, mBridge = new CookieControlsBridge(observer, mWebContents,
profile.isOffTheRecord() ? profile.getOriginalProfile() : null); profile.isOffTheRecord() ? profile.getOriginalProfile() : null);
} }
/**
* {@inheritDoc}
*/
@Override
public void onUiClosing() {
mBridge.onUiClosing();
}
/**
* {@inheritDoc}
*/
@Override
public void setThirdPartyCookieBlockingEnabledForSite(boolean blockCookies) {
mBridge.setThirdPartyCookieBlockingEnabledForSite(blockCookies);
}
@VisibleForTesting @VisibleForTesting
void setOfflinePageStateForTesting(@OfflinePageState int offlinePageState) { void setOfflinePageStateForTesting(@OfflinePageState int offlinePageState) {
mOfflinePageState = offlinePageState; mOfflinePageState = offlinePageState;
......
...@@ -32,7 +32,6 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -32,7 +32,6 @@ 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.components.content_settings.ContentSettingValues; import org.chromium.components.content_settings.ContentSettingValues;
import org.chromium.components.content_settings.CookieControlsBridge;
import org.chromium.components.content_settings.CookieControlsEnforcement; import org.chromium.components.content_settings.CookieControlsEnforcement;
import org.chromium.components.content_settings.CookieControlsObserver; import org.chromium.components.content_settings.CookieControlsObserver;
import org.chromium.components.content_settings.CookieControlsStatus; import org.chromium.components.content_settings.CookieControlsStatus;
...@@ -145,9 +144,6 @@ public class PageInfoController implements ModalDialogProperties.Controller, ...@@ -145,9 +144,6 @@ public class PageInfoController implements ModalDialogProperties.Controller,
// The controller for the cookies section of the page info. // The controller for the cookies section of the page info.
private PageInfoCookiesController mCookiesController; private PageInfoCookiesController mCookiesController;
// Bridge updating the CookieControlsView when cookie settings change.
private CookieControlsBridge mCookieBridge;
/** /**
* Creates the PageInfoController, but does not display it. Also initializes the corresponding * Creates the PageInfoController, but does not display it. Also initializes the corresponding
* C++ object and saves a pointer to it. * C++ object and saves a pointer to it.
...@@ -244,9 +240,7 @@ public class PageInfoController implements ModalDialogProperties.Controller, ...@@ -244,9 +240,7 @@ public class PageInfoController implements ModalDialogProperties.Controller,
viewParams.siteSettingsButtonShown = false; viewParams.siteSettingsButtonShown = false;
viewParams.cookieControlsShown = false; viewParams.cookieControlsShown = false;
} }
viewParams.onUiClosingCallback = () -> { viewParams.onUiClosingCallback = mDelegate::onUiClosing;
mCookieBridge.onUiClosing();
};
mDelegate.initPreviewUiParams(viewParams, mRunAfterDismissConsumer); mDelegate.initPreviewUiParams(viewParams, mRunAfterDismissConsumer);
mDelegate.initOfflinePageUiParams(viewParams, mRunAfterDismissConsumer); mDelegate.initOfflinePageUiParams(viewParams, mRunAfterDismissConsumer);
...@@ -285,7 +279,7 @@ public class PageInfoController implements ModalDialogProperties.Controller, ...@@ -285,7 +279,7 @@ public class PageInfoController implements ModalDialogProperties.Controller,
cookieControlsParams.onCheckedChangedCallback = (Boolean blockCookies) -> { cookieControlsParams.onCheckedChangedCallback = (Boolean blockCookies) -> {
recordAction(blockCookies ? PageInfoAction.PAGE_INFO_COOKIE_BLOCKED_FOR_SITE recordAction(blockCookies ? PageInfoAction.PAGE_INFO_COOKIE_BLOCKED_FOR_SITE
: PageInfoAction.PAGE_INFO_COOKIE_ALLOWED_FOR_SITE); : PageInfoAction.PAGE_INFO_COOKIE_ALLOWED_FOR_SITE);
mCookieBridge.setThirdPartyCookieBlockingEnabledForSite(blockCookies); mDelegate.setThirdPartyCookieBlockingEnabledForSite(blockCookies);
}; };
mView.getCookieControlsView().setParams(cookieControlsParams); mView.getCookieControlsView().setParams(cookieControlsParams);
} }
...@@ -296,7 +290,7 @@ public class PageInfoController implements ModalDialogProperties.Controller, ...@@ -296,7 +290,7 @@ public class PageInfoController implements ModalDialogProperties.Controller,
new PermissionParamsListBuilder(mContext, mWindowAndroid, mFullUrl, showTitle, this, new PermissionParamsListBuilder(mContext, mWindowAndroid, mFullUrl, showTitle, this,
mView::setPermissions, mPermissionParamsListBuilderDelegate); mView::setPermissions, mPermissionParamsListBuilderDelegate);
mNativePageInfoController = PageInfoControllerJni.get().init(this, mWebContents); mNativePageInfoController = PageInfoControllerJni.get().init(this, mWebContents);
mCookieBridge = mDelegate.createCookieControlsBridge(this); mDelegate.createCookieControlsBridge(this);
mWebContentsObserver = new WebContentsObserver(webContents) { mWebContentsObserver = new WebContentsObserver(webContents) {
@Override @Override
...@@ -339,10 +333,6 @@ public class PageInfoController implements ModalDialogProperties.Controller, ...@@ -339,10 +333,6 @@ public class PageInfoController implements ModalDialogProperties.Controller,
mDialog.destroy(); mDialog.destroy();
mDialog = null; mDialog = null;
} }
if (mCookieBridge != null) {
mCookieBridge.destroy();
mCookieBridge = null;
}
} }
/** /**
......
...@@ -7,12 +7,10 @@ package org.chromium.components.page_info; ...@@ -7,12 +7,10 @@ package org.chromium.components.page_info;
import android.content.Intent; import android.content.Intent;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import org.chromium.base.Consumer; import org.chromium.base.Consumer;
import org.chromium.base.supplier.Supplier; import org.chromium.base.supplier.Supplier;
import org.chromium.components.content_settings.CookieControlsBridge;
import org.chromium.components.content_settings.CookieControlsObserver; import org.chromium.components.content_settings.CookieControlsObserver;
import org.chromium.components.omnibox.AutocompleteSchemeClassifier; import org.chromium.components.omnibox.AutocompleteSchemeClassifier;
import org.chromium.components.page_info.PageInfoView.PageInfoViewParams; import org.chromium.components.page_info.PageInfoView.PageInfoViewParams;
...@@ -24,7 +22,7 @@ import java.lang.annotation.RetentionPolicy; ...@@ -24,7 +22,7 @@ import java.lang.annotation.RetentionPolicy;
/** /**
* Provides embedder-level information to PageInfoController. * Provides embedder-level information to PageInfoController.
*/ */
public abstract class PageInfoControllerDelegate { public class PageInfoControllerDelegate {
@IntDef({OfflinePageState.NOT_OFFLINE_PAGE, OfflinePageState.TRUSTED_OFFLINE_PAGE, @IntDef({OfflinePageState.NOT_OFFLINE_PAGE, OfflinePageState.TRUSTED_OFFLINE_PAGE,
OfflinePageState.UNTRUSTED_OFFLINE_PAGE}) OfflinePageState.UNTRUSTED_OFFLINE_PAGE})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
...@@ -195,14 +193,23 @@ public abstract class PageInfoControllerDelegate { ...@@ -195,14 +193,23 @@ public abstract class PageInfoControllerDelegate {
* Show site settings for the URL passed in. * Show site settings for the URL passed in.
* @param url The URL to show site settings for. * @param url The URL to show site settings for.
*/ */
public abstract void showSiteSettings(String url); public void showSiteSettings(String url) {}
// TODO(crbug.com/1052375): Remove the next three methods when cookie controls UI
// has been componentized.
/** /**
* Creates Cookie Controls Bridge. * Creates Cookie Controls Bridge.
* @param observer The CookieControlsObserver to create the bridge with. * @param The CookieControlsObserver to create the bridge with.
* @return the object that facilitates interfacing with native code.
*/ */
@NonNull public void createCookieControlsBridge(CookieControlsObserver observer) {}
public abstract CookieControlsBridge createCookieControlsBridge(
CookieControlsObserver observer); /**
* Called when cookie controls UI is closed.
*/
public void onUiClosing() {}
/**
* Notes whether third party cookies should be blocked for the site.
*/
public void setThirdPartyCookieBlockingEnabledForSite(boolean blockCookies) {}
} }
...@@ -7,15 +7,10 @@ package org.chromium.weblayer_private; ...@@ -7,15 +7,10 @@ package org.chromium.weblayer_private;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import androidx.annotation.NonNull;
import org.chromium.base.StrictModeContext; import org.chromium.base.StrictModeContext;
import org.chromium.base.supplier.Supplier; import org.chromium.base.supplier.Supplier;
import org.chromium.components.content_settings.CookieControlsBridge;
import org.chromium.components.content_settings.CookieControlsObserver;
import org.chromium.components.embedder_support.util.UrlConstants; import org.chromium.components.embedder_support.util.UrlConstants;
import org.chromium.components.page_info.PageInfoControllerDelegate; import org.chromium.components.page_info.PageInfoControllerDelegate;
import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.modaldialog.ModalDialogManager; import org.chromium.ui.modaldialog.ModalDialogManager;
import org.chromium.url.GURL; import org.chromium.url.GURL;
import org.chromium.weblayer_private.interfaces.SiteSettingsIntentHelper; import org.chromium.weblayer_private.interfaces.SiteSettingsIntentHelper;
...@@ -25,27 +20,18 @@ import org.chromium.weblayer_private.interfaces.SiteSettingsIntentHelper; ...@@ -25,27 +20,18 @@ import org.chromium.weblayer_private.interfaces.SiteSettingsIntentHelper;
*/ */
public class PageInfoControllerDelegateImpl extends PageInfoControllerDelegate { public class PageInfoControllerDelegateImpl extends PageInfoControllerDelegate {
private final Context mContext; private final Context mContext;
private final WebContents mWebContents;
private final String mProfileName; private final String mProfileName;
static PageInfoControllerDelegateImpl create(WebContents webContents) { public PageInfoControllerDelegateImpl(Context context, String profileName, GURL url,
TabImpl tab = TabImpl.fromWebContents(webContents); Supplier<ModalDialogManager> modalDialogManager) {
assert tab != null;
return new PageInfoControllerDelegateImpl(tab.getBrowser().getContext(), webContents,
tab.getProfile(), tab.getBrowser().getWindowAndroid()::getModalDialogManager);
}
private PageInfoControllerDelegateImpl(Context context, WebContents webContents,
ProfileImpl profile, Supplier<ModalDialogManager> modalDialogManager) {
super(modalDialogManager, new AutocompleteSchemeClassifierImpl(), super(modalDialogManager, new AutocompleteSchemeClassifierImpl(),
/** vrHandler= */ null, /** vrHandler= */ null,
/** isSiteSettingsAvailable= */ /** isSiteSettingsAvailable= */
isHttpOrHttps(webContents.getVisibleUrl()), UrlConstants.HTTP_SCHEME.equals(url.getScheme())
/** cookieControlsShown= */ || UrlConstants.HTTPS_SCHEME.equals(url.getScheme()),
CookieControlsBridge.isCookieControlsEnabled(profile)); /** cookieControlsShown= */ false);
mContext = context; mContext = context;
mWebContents = webContents; mProfileName = profileName;
mProfileName = profile.getName();
} }
/** /**
...@@ -61,18 +47,4 @@ public class PageInfoControllerDelegateImpl extends PageInfoControllerDelegate { ...@@ -61,18 +47,4 @@ public class PageInfoControllerDelegateImpl extends PageInfoControllerDelegate {
mContext.startActivity(intent); mContext.startActivity(intent);
} }
} }
/**
* {@inheritDoc}
*/
@Override
@NonNull
public CookieControlsBridge createCookieControlsBridge(CookieControlsObserver observer) {
return new CookieControlsBridge(observer, mWebContents, null);
}
private static boolean isHttpOrHttps(GURL url) {
String scheme = url.getScheme();
return UrlConstants.HTTP_SCHEME.equals(scheme) || UrlConstants.HTTPS_SCHEME.equals(scheme);
}
} }
...@@ -28,7 +28,6 @@ import org.chromium.components.omnibox.SecurityButtonAnimationDelegate; ...@@ -28,7 +28,6 @@ import org.chromium.components.omnibox.SecurityButtonAnimationDelegate;
import org.chromium.components.omnibox.SecurityStatusIcon; import org.chromium.components.omnibox.SecurityStatusIcon;
import org.chromium.components.page_info.PageInfoController; import org.chromium.components.page_info.PageInfoController;
import org.chromium.components.page_info.PermissionParamsListBuilderDelegate; import org.chromium.components.page_info.PermissionParamsListBuilderDelegate;
import org.chromium.content_public.browser.WebContents;
import org.chromium.weblayer_private.interfaces.IObjectWrapper; import org.chromium.weblayer_private.interfaces.IObjectWrapper;
import org.chromium.weblayer_private.interfaces.IUrlBarController; import org.chromium.weblayer_private.interfaces.IUrlBarController;
import org.chromium.weblayer_private.interfaces.ObjectWrapper; import org.chromium.weblayer_private.interfaces.ObjectWrapper;
...@@ -167,11 +166,13 @@ public class UrlBarControllerImpl extends IUrlBarController.Stub { ...@@ -167,11 +166,13 @@ public class UrlBarControllerImpl extends IUrlBarController.Stub {
} }
private void showPageInfoUi(View v) { private void showPageInfoUi(View v) {
WebContents webContents = mBrowserImpl.getActiveTab().getWebContents();
PageInfoController.show(mBrowserImpl.getWindowAndroid().getActivity().get(), PageInfoController.show(mBrowserImpl.getWindowAndroid().getActivity().get(),
webContents, mBrowserImpl.getActiveTab().getWebContents(),
/* contentPublisher= */ null, PageInfoController.OpenedFromSource.TOOLBAR, /* contentPublisher= */ null, PageInfoController.OpenedFromSource.TOOLBAR,
PageInfoControllerDelegateImpl.create(webContents), new PageInfoControllerDelegateImpl(mBrowserImpl.getContext(),
mBrowserImpl.getProfile().getName(),
mBrowserImpl.getActiveTab().getWebContents().getVisibleUrl(),
mBrowserImpl.getWindowAndroid()::getModalDialogManager),
new PermissionParamsListBuilderDelegate(mBrowserImpl.getProfile())); new PermissionParamsListBuilderDelegate(mBrowserImpl.getProfile()));
} }
......
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