Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
Signed-off-by: Vadym Struts <[email protected]>
  • Loading branch information
vadimstruts committed Dec 3, 2024
1 parent d03694c commit a3fec02
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 47 deletions.
2 changes: 1 addition & 1 deletion android/brave_java_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/browsing_data/BraveClearBrowsingDataFragmentAdvanced.java",
"../../brave/android/java/org/chromium/chrome/browser/compositor/layouts/BraveToolbarSwipeLayout.java",
"../../brave/android/java/org/chromium/chrome/browser/contextmenu/BraveChromeContextMenuPopulator.java",
"../../brave/android/java/org/chromium/chrome/browser/cosmetic_filters/BraveCosmeticFiltersUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/crash/BravePureJavaExceptionReporter.java",
"../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/AssetRatioServiceFactory.java",
"../../brave/android/java/org/chromium/chrome/browser/crypto_wallet/BlockchainRegistryFactory.java",
Expand Down Expand Up @@ -413,7 +414,6 @@ brave_java_sources = [
"../../brave/android/java/org/chromium/chrome/browser/site_settings/BraveWalletSolanaConnectedSitesPreference.java",
"../../brave/android/java/org/chromium/chrome/browser/speedreader/BraveSpeedReaderManager.java",
"../../brave/android/java/org/chromium/chrome/browser/speedreader/BraveSpeedReaderUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/cosmetic_filters/BraveCosmeticFiltersUtils.java",
"../../brave/android/java/org/chromium/chrome/browser/suggestions/tile/BraveMostVisitedTilesLayoutBase.java",
"../../brave/android/java/org/chromium/chrome/browser/suggestions/tile/BraveMostVisitedTilesMediator.java",
"../../brave/android/java/org/chromium/chrome/browser/suggestions/tile/BraveTileView.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
import org.chromium.chrome.browser.settings.developer.BraveQAPreferences;
import org.chromium.chrome.browser.share.ShareDelegate;
import org.chromium.chrome.browser.share.ShareDelegate.ShareOrigin;
import org.chromium.chrome.browser.shields.AddCustomFilterListsFragment;
import org.chromium.chrome.browser.shields.ContentFilteringFragment;
import org.chromium.chrome.browser.shields.CreateCustomFiltersFragment;
import org.chromium.chrome.browser.site_settings.BraveWalletEthereumConnectedSites;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,25 @@

package org.chromium.chrome.browser.cosmetic_filters;

import org.jni_zero.CalledByNative;
import org.jni_zero.JNINamespace;
import org.jni_zero.NativeMethods;

import org.chromium.chrome.browser.tab.Tab;
import org.chromium.content_public.browser.WebContents;
import org.jni_zero.CalledByNative;
import org.chromium.chrome.browser.app.BraveActivity;
import org.chromium.chrome.browser.settings.BraveLeoPreferences;
import org.chromium.chrome.browser.settings.SettingsNavigationFactory;
import org.chromium.components.browser_ui.settings.SettingsNavigation;

import android.app.Activity;
import android.content.Context;

import org.chromium.base.Log;
import org.chromium.chrome.browser.app.BraveActivity;
import org.chromium.chrome.browser.tab.Tab;

@JNINamespace("cosmetic_filters")
public class BraveCosmeticFiltersUtils {
private static final String TAG = "BraveCosmeticFiltersUtils";
private static final String TAG = "CosmeticFiltersUtils";

public static boolean launchContentPickerForWebContent(Tab tab) {
return BraveCosmeticFiltersUtilsJni.get().launchContentPickerForWebContent(tab);
}

@CalledByNative
public static void showCustomFilterSettings() {
try {
try {
BraveActivity.getBraveActivity().openBraveCreateCustomFiltersSettings();
} catch (BraveActivity.BraveActivityNotFoundException e) {
Log.e(TAG, "open create custom filter settings" + e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
import org.chromium.base.Log;
import org.chromium.base.SysUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.cosmetic_filters.BraveCosmeticFiltersUtils;
import org.chromium.chrome.browser.BraveRewardsHelper;
import org.chromium.chrome.browser.BraveRewardsNativeWorker;
import org.chromium.chrome.browser.app.BraveActivity;
import org.chromium.chrome.browser.brave_stats.BraveStatsUtil;
import org.chromium.chrome.browser.cosmetic_filters.BraveCosmeticFiltersUtils;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.onboarding.OnboardingPrefManager;
Expand Down Expand Up @@ -746,15 +746,18 @@ private void setUpSwitchLayouts() {
fingerprintingSwitchLayout.setVisibility(View.GONE);
}

TextView blockElementsText = mSecondaryLayout.findViewById(R.id.brave_shields_block_element_text);
blockElementsText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hideBraveShieldsMenu();
Tab currentActiveTab = mIconFetcher.getTab();
BraveCosmeticFiltersUtils.launchContentPickerForWebContent(currentActiveTab);
}
});
TextView blockElementsText =
mSecondaryLayout.findViewById(R.id.brave_shields_block_element_text);
blockElementsText.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
hideBraveShieldsMenu();
Tab currentActiveTab = mIconFetcher.getTab();
BraveCosmeticFiltersUtils.launchContentPickerForWebContent(
currentActiveTab);
}
});
}

private void setUpAboutLayout() {
Expand Down
2 changes: 1 addition & 1 deletion browser/android/cosmetic_filters/cosmetic_filters_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static jboolean JNI_BraveCosmeticFiltersUtils_LaunchContentPickerForWebContent(
}

CosmeticFiltersTabHelper::LaunchContentPicker(web_contents);

return true;
}

Expand Down
11 changes: 5 additions & 6 deletions browser/cosmetic_filters/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ brave_browser_cosmetic_filters_deps = [
]

if (is_android) {
brave_browser_cosmetic_filters_sources +=
[
"//brave/browser/android/cosmetic_filters/cosmetic_filters_utils.cc",
"//brave/browser/android/cosmetic_filters/cosmetic_filters_utils.h"
]
brave_browser_cosmetic_filters_sources += [
"//brave/browser/android/cosmetic_filters/cosmetic_filters_utils.cc",
"//brave/browser/android/cosmetic_filters/cosmetic_filters_utils.h",
]

brave_browser_cosmetic_filters_deps += [ "//brave/build/android:jni_headers" ]
}
}
2 changes: 1 addition & 1 deletion build/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ generate_jni("jni_headers") {
"//brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoSettingsLauncherHelper.java",
"//brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoUtils.java",
"//brave/android/java/org/chromium/chrome/browser/brave_news/BraveNewsControllerFactory.java",
"//brave/android/java/org/chromium/chrome/browser/cosmetic_filters/BraveCosmeticFiltersUtils.java",
"//brave/android/java/org/chromium/chrome/browser/crypto_wallet/AssetRatioServiceFactory.java",
"//brave/android/java/org/chromium/chrome/browser/crypto_wallet/BlockchainRegistryFactory.java",
"//brave/android/java/org/chromium/chrome/browser/crypto_wallet/BraveWalletProviderDelegateImplHelper.java",
Expand All @@ -242,7 +243,6 @@ generate_jni("jni_headers") {
"//brave/android/java/org/chromium/chrome/browser/vpn/BraveVpnNativeWorker.java",
"//brave/android/java/org/chromium/chrome/browser/vpn/BraveVpnServiceFactoryAndroid.java",
"//brave/android/java/org/chromium/chrome/browser/webcompat_reporter/WebcompatReporterServiceFactory.java",
"//brave/android/java/org/chromium/chrome/browser/cosmetic_filters/BraveCosmeticFiltersUtils.java",
]

public_deps = [ "//brave/android/java/org/chromium/chrome/browser/search_engines:jni_headers" ]
Expand Down
2 changes: 1 addition & 1 deletion build/android/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ brave_jni_headers_sources = [
"//brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoMojomHelper.java",
"//brave/android/java/org/chromium/chrome/browser/brave_leo/BraveLeoUtils.java",
"//brave/android/java/org/chromium/chrome/browser/brave_news/BraveNewsControllerFactory.java",
"//brave/android/java/org/chromium/chrome/browser/cosmetic_filters/BraveCosmeticFiltersUtils.java",
"//brave/android/java/org/chromium/chrome/browser/crypto_wallet/AssetRatioServiceFactory.java",
"//brave/android/java/org/chromium/chrome/browser/crypto_wallet/BlockchainRegistryFactory.java",
"//brave/android/java/org/chromium/chrome/browser/crypto_wallet/BraveWalletProviderDelegateImplHelper.java",
Expand Down Expand Up @@ -133,5 +134,4 @@ brave_jni_headers_sources = [
"//brave/android/java/org/chromium/chrome/browser/webcompat_reporter/WebcompatReporterServiceFactory.java",
"//brave/browser/brave_ads/android/java/org/chromium/chrome/browser/BraveAdsNativeHelper.java",
"//brave/components/safetynet/java/org/chromium/chrome/browser/util/SafetyNetCheck.java",
"//brave/android/java/org/chromium/chrome/browser/cosmetic_filters/BraveCosmeticFiltersUtils.java",
]
26 changes: 13 additions & 13 deletions components/cosmetic_filters/resources/data/element_picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ class Target {

class TargetsCollection {
targets: Target[] = []

reset(elems: Element[]) {
this.targets.length = 0
elems.forEach((elem: Element) => {
Expand Down Expand Up @@ -440,10 +439,10 @@ const hideByXPath = (xpath: string): void => {
display: 'none'
}
const result = document.evaluate(
xpath,
document,
null,
XPathResult.ORDERED_NODE_ITERATOR_TYPE,
xpath,
document,
null,
XPathResult.ORDERED_NODE_ITERATOR_TYPE,
null
);

Expand Down Expand Up @@ -547,7 +546,8 @@ const elementPickerUserSelectedTarget = (specificity: number) => {
const selector = onTargetSelected(lastHoveredElem, specificity)
if (selector !== '') {
try {
recalculateAndSendTargets(Array.from(document.querySelectorAll(selector)))
recalculateAndSendTargets(
Array.from(document.querySelectorAll(selector)))
} catch {}
}
return {
Expand Down Expand Up @@ -631,7 +631,7 @@ const launchElementPicker = (root: ShadowRoot) => {
togglePopup(true)
})

const section = root.querySelector('section')!
const section = root.querySelector('section')!
const togglePopup = (show: boolean) => {
section.style.setProperty('opacity', show ? '1' : '0.2')
}
Expand All @@ -657,7 +657,6 @@ const launchElementPicker = (root: ShadowRoot) => {
})

const doubleOrLongClickEventHandler = (event: MouseEvent | TouchEvent) => {

let elem: Element | null = null
if (event instanceof MouseEvent) {
elem = elementFromFrameCoords(event.clientX, event.clientY)
Expand All @@ -679,7 +678,7 @@ const launchElementPicker = (root: ShadowRoot) => {
if (!clickedElement || !hasSelectedTarget) {
return
}

if (targetedElems.toggleElementMark(clickedElement) === null) {
hasSelectedTarget = false
slider.value = '4'
Expand Down Expand Up @@ -750,12 +749,13 @@ const launchElementPicker = (root: ShadowRoot) => {
quitElementPicker()
})

const toggleDisplay = (target: HTMLElement | null, trigger: HTMLElement | null) => {
const toggleDisplay = (target: HTMLElement | null,
trigger: HTMLElement | null) => {
if(!target || !trigger){
return
}
return
}
trigger.addEventListener('click', e => {
if (target.style.display != 'block') {
if (target.style.display !== 'block') {
target.style.display = 'block'
trigger.textContent = 'Hide rules'
} else {
Expand Down

0 comments on commit a3fec02

Please sign in to comment.