-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Element Picker brave/brave-browser#33241 --------- Signed-off-by: Vadym Struts <[email protected]>
- Loading branch information
1 parent
58cc6e4
commit 4be896e
Showing
25 changed files
with
838 additions
and
154 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
48 changes: 48 additions & 0 deletions
48
android/java/org/chromium/chrome/browser/cosmetic_filters/BraveCosmeticFiltersUtils.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,48 @@ | ||
/* Copyright (c) 2024 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 https://mozilla.org/MPL/2.0/. */ | ||
|
||
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.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 = "CosmeticFiltersUtils"; | ||
|
||
public static boolean launchContentPickerForWebContent(Tab tab) { | ||
return BraveCosmeticFiltersUtilsJni.get().launchContentPickerForWebContent(tab); | ||
} | ||
|
||
@CalledByNative | ||
public static void showCustomFilterSettings() { | ||
try { | ||
BraveActivity.getBraveActivity().openBraveCreateCustomFiltersSettings(); | ||
} catch (BraveActivity.BraveActivityNotFoundException e) { | ||
Log.e(TAG, "open create custom filter settings" + e); | ||
} | ||
} | ||
|
||
@CalledByNative | ||
public static int getThemeBackgroundColor() { | ||
int backgroundColor = 0; | ||
try { | ||
backgroundColor = BraveActivity.getBraveActivity().getBraveThemeBackgroundColor(); | ||
} catch (BraveActivity.BraveActivityNotFoundException e) { | ||
Log.e(TAG, "Get theme background color" + e); | ||
} | ||
return backgroundColor; | ||
} | ||
|
||
@NativeMethods | ||
interface Natives { | ||
boolean launchContentPickerForWebContent(Tab tab); | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
browser/android/cosmetic_filters/cosmetic_filters_utils.cc
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,38 @@ | ||
/* Copyright (c) 2024 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 https://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/android/cosmetic_filters/cosmetic_filters_utils.h" | ||
|
||
#include "brave/browser/cosmetic_filters/cosmetic_filters_tab_helper.h" | ||
#include "brave/build/android/jni_headers/BraveCosmeticFiltersUtils_jni.h" | ||
#include "chrome/browser/android/tab_android.h" | ||
|
||
namespace cosmetic_filters { | ||
|
||
static jboolean JNI_BraveCosmeticFiltersUtils_LaunchContentPickerForWebContent( | ||
JNIEnv* env, | ||
const base::android::JavaParamRef<jobject>& tab) { | ||
TabAndroid* tab_android = TabAndroid::GetNativeTab(env, tab); | ||
content::WebContents* web_contents = tab_android->web_contents(); | ||
if (!web_contents) { | ||
return false; | ||
} | ||
|
||
CosmeticFiltersTabHelper::LaunchContentPicker(web_contents); | ||
|
||
return true; | ||
} | ||
|
||
void ShowCustomFilterSettings() { | ||
JNIEnv* env = base::android::AttachCurrentThread(); | ||
Java_BraveCosmeticFiltersUtils_showCustomFilterSettings(env); | ||
} | ||
|
||
int32_t GetThemeBackgroundColor() { | ||
JNIEnv* env = base::android::AttachCurrentThread(); | ||
return Java_BraveCosmeticFiltersUtils_getThemeBackgroundColor(env); | ||
} | ||
|
||
} // namespace cosmetic_filters |
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,18 @@ | ||
/* Copyright (c) 2024 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 https://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_ANDROID_COSMETIC_FILTERS_COSMETIC_FILTERS_UTILS_H_ | ||
#define BRAVE_BROWSER_ANDROID_COSMETIC_FILTERS_COSMETIC_FILTERS_UTILS_H_ | ||
|
||
#include "content/public/browser/web_contents.h" | ||
|
||
namespace cosmetic_filters { | ||
|
||
void ShowCustomFilterSettings(); | ||
int GetThemeBackgroundColor(); | ||
|
||
} // namespace cosmetic_filters | ||
|
||
#endif // BRAVE_BROWSER_ANDROID_COSMETIC_FILTERS_COSMETIC_FILTERS_UTILS_H_ |
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
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
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
Oops, something went wrong.