-
Notifications
You must be signed in to change notification settings - Fork 889
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15063 from brave/cookie_consent_dialog_android
Block cookie consent dialog android
- Loading branch information
Showing
39 changed files
with
637 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
android/java/org/chromium/chrome/browser/shields/CookieListOptInServiceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* Copyright (c) 2022 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.chromium.chrome.browser.shields; | ||
|
||
import org.chromium.base.annotations.JNINamespace; | ||
import org.chromium.base.annotations.NativeMethods; | ||
import org.chromium.brave_shields.mojom.CookieListOptInPageAndroidHandler; | ||
import org.chromium.chrome.browser.crypto_wallet.util.Utils; | ||
import org.chromium.chrome.browser.profiles.Profile; | ||
import org.chromium.mojo.bindings.ConnectionErrorHandler; | ||
import org.chromium.mojo.bindings.Interface; | ||
import org.chromium.mojo.bindings.Interface.Proxy.Handler; | ||
import org.chromium.mojo.system.MessagePipeHandle; | ||
import org.chromium.mojo.system.impl.CoreImpl; | ||
|
||
@JNINamespace("chrome::android") | ||
public class CookieListOptInServiceFactory { | ||
private static final Object lock = new Object(); | ||
private static CookieListOptInServiceFactory instance; | ||
|
||
public static CookieListOptInServiceFactory getInstance() { | ||
synchronized (lock) { | ||
if (instance == null) { | ||
instance = new CookieListOptInServiceFactory(); | ||
} | ||
} | ||
return instance; | ||
} | ||
|
||
private CookieListOptInServiceFactory() {} | ||
|
||
public CookieListOptInPageAndroidHandler getCookieListOptInPageAndroidHandler( | ||
ConnectionErrorHandler connectionErrorHandler) { | ||
Profile profile = Utils.getProfile(false); // Always use regular profile | ||
int nativeHandle = | ||
CookieListOptInServiceFactoryJni.get().getInterfaceToCookieListOptInService( | ||
profile); | ||
MessagePipeHandle handle = wrapNativeHandle(nativeHandle); | ||
CookieListOptInPageAndroidHandler cookieListOptInPageAndroidHandler = | ||
CookieListOptInPageAndroidHandler.MANAGER.attachProxy(handle, 0); | ||
Handler handler = ((Interface.Proxy) cookieListOptInPageAndroidHandler).getProxyHandler(); | ||
handler.setErrorHandler(connectionErrorHandler); | ||
|
||
return cookieListOptInPageAndroidHandler; | ||
} | ||
|
||
private MessagePipeHandle wrapNativeHandle(int nativeHandle) { | ||
return CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessagePipeHandle(); | ||
} | ||
|
||
@NativeMethods | ||
interface Natives { | ||
int getInterfaceToCookieListOptInService(Profile profile); | ||
} | ||
} |
Oops, something went wrong.