diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index 014642984814..d1d05133a473 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -300,6 +300,15 @@ By installing this extension, you are agreeing to the Google Widevine Terms of U Social media blocking + + Default view + + + Simple view + + + Advanced view + Block cross-site trackers diff --git a/browser/brave_profile_prefs.cc b/browser/brave_profile_prefs.cc index 7c2f45141b2a..e01307baf368 100644 --- a/browser/brave_profile_prefs.cc +++ b/browser/brave_profile_prefs.cc @@ -61,6 +61,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { registry->RegisterBooleanPref(kHTTPSEVerywhereControlType, true); registry->RegisterBooleanPref(kNoScriptControlType, false); registry->RegisterBooleanPref(kAdControlType, true); + registry->RegisterBooleanPref(kAdvancedViewControlType, false); registry->RegisterBooleanPref(kGoogleLoginControlType, true); registry->RegisterBooleanPref(kFBEmbedControlType, true); registry->RegisterBooleanPref(kTwitterEmbedControlType, true); diff --git a/browser/brave_profile_prefs_browsertest.cc b/browser/brave_profile_prefs_browsertest.cc index ababd071c8f1..89cf954fe06e 100644 --- a/browser/brave_profile_prefs_browsertest.cc +++ b/browser/brave_profile_prefs_browsertest.cc @@ -29,6 +29,8 @@ IN_PROC_BROWSER_TEST_F(BraveProfilePrefsBrowserTest, MiscBravePrefs) { kHTTPSEVerywhereControlType)); EXPECT_FALSE( browser()->profile()->GetPrefs()->GetBoolean(kNoScriptControlType)); + EXPECT_FALSE( + browser()->profile()->GetPrefs()->GetBoolean(kAdvancedViewControlType)); EXPECT_TRUE( browser()->profile()->GetPrefs()->GetBoolean(kAdControlType)); EXPECT_TRUE( diff --git a/browser/extensions/api/settings_private/brave_prefs_util.cc b/browser/extensions/api/settings_private/brave_prefs_util.cc index 19c2d5f2608c..65851f5babff 100644 --- a/browser/extensions/api/settings_private/brave_prefs_util.cc +++ b/browser/extensions/api/settings_private/brave_prefs_util.cc @@ -35,6 +35,8 @@ const PrefsUtil::TypedPrefMap& BravePrefsUtil::GetWhitelistedKeys() { (*s_brave_whitelist)[::prefs::kImportDialogWindows] = settings_api::PrefType::PREF_TYPE_BOOLEAN; // Default Brave shields + (*s_brave_whitelist)[kAdvancedViewControlType] = + settings_api::PrefType::PREF_TYPE_BOOLEAN; (*s_brave_whitelist)[kAdControlType] = settings_api::PrefType::PREF_TYPE_BOOLEAN; (*s_brave_whitelist)[kHTTPSEVerywhereControlType] = diff --git a/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.js b/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.js index f4635c7bb492..a035d473c70e 100644 --- a/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.js +++ b/browser/resources/settings/default_brave_shields_page/default_brave_shields_browser_proxy.js @@ -5,6 +5,11 @@ cr.define('settings', function() { /** @interface */ class DefaultBraveShieldsBrowserProxy { + /** + * @param {string} value name. + */ + setAdvancedViewControlType(value) {} + /** * @return {!Promise} */ @@ -47,6 +52,11 @@ cr.define('settings', function() { * @implements {settings.DefaultBraveShieldsBrowserProxy} */ class DefaultBraveShieldsBrowserProxyImpl { + /** @override */ + setAdvancedViewControlType(value) { + chrome.send('setAdvancedViewControlType', [value]); + } + /** @override */ getAdControlType() { return cr.sendWithPromise('getAdControlType'); diff --git a/browser/resources/settings/default_brave_shields_page/default_brave_shields_page.html b/browser/resources/settings/default_brave_shields_page/default_brave_shields_page.html index 0ca2dbf46f52..af46dee1705d 100644 --- a/browser/resources/settings/default_brave_shields_page/default_brave_shields_page.html +++ b/browser/resources/settings/default_brave_shields_page/default_brave_shields_page.html @@ -18,6 +18,23 @@ .label.shields-secondary-title { padding-bottom: 1em; } + .shields-views { + display: grid; + grid-template-columns: 1fr 1fr; + grid-gap: 16px; + } + .shields-view-col { + margin: 16px 0 24px; + padding: 24px; + height: 100px; + border-radius: 6px; + border: 1px solid rgba(0,0,0,0.5); + display: flex; + align-items: center; + } + .shields-view-label { + margin: 0 20px; + }
@@ -28,6 +45,35 @@
+ + + RegisterMessageCallback( + "setAdvancedViewControlType", + base::BindRepeating(&DefaultBraveShieldsHandler::SetAdvancedViewControlType, + base::Unretained(this))); web_ui()->RegisterMessageCallback( "getAdControlType", base::BindRepeating(&DefaultBraveShieldsHandler::GetAdControlType, @@ -56,6 +60,18 @@ void DefaultBraveShieldsHandler::RegisterMessages() { base::Unretained(this))); } +void DefaultBraveShieldsHandler::SetAdvancedViewControlType( + const base::ListValue* args) { + CHECK_EQ(args->GetSize(), 1U); + CHECK(profile_); + bool value; + args->GetBoolean(0, &value); + + // extensions::ExtensionService* service = + // extensions::ExtensionSystem::Get(profile_)->extension_service(); + // extensions::ComponentLoader* loader = service->component_loader(); +} + void DefaultBraveShieldsHandler::GetAdControlType(const base::ListValue* args) { CHECK_EQ(args->GetSize(), 1U); CHECK(profile_); diff --git a/browser/ui/webui/settings/default_brave_shields_handler.h b/browser/ui/webui/settings/default_brave_shields_handler.h index a2711cc51193..b6f295dd1c1f 100644 --- a/browser/ui/webui/settings/default_brave_shields_handler.h +++ b/browser/ui/webui/settings/default_brave_shields_handler.h @@ -20,6 +20,7 @@ class DefaultBraveShieldsHandler : public settings::SettingsPageUIHandler { void OnJavascriptAllowed() override {} void OnJavascriptDisallowed() override {} + void SetAdvancedViewControlType(const base::ListValue* args); void SetAdControlType(const base::ListValue* args); void GetAdControlType(const base::ListValue* args); void SetCookieControlType(const base::ListValue* args); diff --git a/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc b/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc index f54a230ff389..8b14a3db545f 100644 --- a/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc +++ b/chromium_src/chrome/browser/ui/webui/settings/settings_localized_strings_provider.cc @@ -66,6 +66,12 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DESCRIPTION_3}, {"socialBlocking", IDS_SETTINGS_SOCIAL_BLOCKING_DEFAULTS_TITLE}, + {"defaultView", + IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_DEFAULT_VIEW_LABEL}, + {"simpleView", + IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_SIMPLE_VIEW_LABEL}, + {"advancedView", + IDS_SETTINGS_BRAVE_SHIELDS_DEFAULTS_ADVANCED_VIEW_LABEL}, {"adControlLabel", IDS_SETTINGS_BRAVE_SHIELDS_AD_CONTROL_LABEL}, {"cookieControlLabel", diff --git a/common/pref_names.cc b/common/pref_names.cc index 7bcd76e3c01f..58cfb3b10935 100644 --- a/common/pref_names.cc +++ b/common/pref_names.cc @@ -40,6 +40,7 @@ const char kReferralCheckedForPromoCodeFile[] = "brave.referral.checked_for_promo_code_file"; const char kHTTPSEVerywhereControlType[] = "brave.https_everywhere_default"; const char kNoScriptControlType[] = "brave.no_script_default"; +const char kAdvancedViewControlType[] = "brave.advanced_view_default"; const char kAdControlType[] = "brave.ad_default"; const char kGoogleLoginControlType[] = "brave.google_login_default"; const char kFBEmbedControlType[] = "brave.fb_embed_default"; diff --git a/common/pref_names.h b/common/pref_names.h index 94942e1fee4c..c47cec2e4285 100644 --- a/common/pref_names.h +++ b/common/pref_names.h @@ -35,6 +35,7 @@ extern const char kReferralHeaders[]; extern const char kReferralCheckedForPromoCodeFile[]; extern const char kHTTPSEVerywhereControlType[]; extern const char kNoScriptControlType[]; +extern const char kAdvancedViewControlType[]; extern const char kAdControlType[]; extern const char kGoogleLoginControlType[]; extern const char kFBEmbedControlType[]; diff --git a/components/brave_extension/extension/brave_extension/components/advancedView/index.tsx b/components/brave_extension/extension/brave_extension/components/advancedView/index.tsx index d932a0b6988c..e4e9f2d1cd04 100644 --- a/components/brave_extension/extension/brave_extension/components/advancedView/index.tsx +++ b/components/brave_extension/extension/brave_extension/components/advancedView/index.tsx @@ -80,6 +80,12 @@ export default class Shields extends React.PureComponent { this.setState({ isBlockedListOpen: !this.state.isBlockedListOpen }) } + onClickTestEnableAdvancedView = () => { + // chrome.send is not exposed to extensions + // TODO: find the correct method + // chrome.send('setAdvancedViewControlType', [true]) + } + render () { const { shieldsPanelTabData, persistentData, actions } = this.props const { isBlockedListOpen } = this.state @@ -90,6 +96,9 @@ export default class Shields extends React.PureComponent { return ( + { persistentData.isFirstAccess &&