Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HTTPS Everywhere #19779

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion android/android_browser_tests.gni
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ android_test_exception_sources = [
"//brave/components/brave_rewards/browser/test/rewards_promotion_browsertest.cc",
"//brave/components/brave_rewards/browser/test/rewards_publisher_browsertest.cc",
"//brave/components/brave_rewards/browser/test/rewards_state_browsertest.cc",
"//brave/components/brave_shields/browser/https_everywhere_service_browsertest.cc",
"//brave/components/brave_shields/browser/test_filters_provider.cc",
"//brave/components/content_settings/renderer/brave_content_settings_agent_impl_browsertest.cc",
"//brave/third_party/blink/renderer/modules/brave/navigator_browsertest.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class BraveShieldsContentSettings {
static public final String RESOURCE_IDENTIFIER_ADS = "shieldsAds";
static public final String RESOURCE_IDENTIFIER_TRACKERS = "trackers";
static public final String RESOURCE_IDENTIFIER_DATA_SAVED = "data_saved";
static public final String RESOURCE_IDENTIFIER_HTTP_UPGRADABLE_RESOURCES = "httpUpgradableResources";
static public final String RESOURCE_IDENTIFIER_BRAVE_SHIELDS = "braveShields";
static public final String RESOURCE_IDENTIFIER_FINGERPRINTING = "fingerprinting";
static public final String RESOURCE_IDENTIFIER_COOKIES = "shieldsCookies";
Expand Down Expand Up @@ -85,8 +84,6 @@ static public void setShields(Profile profile, String host, String resourceInden
String setting_string = (value ? BLOCK_RESOURCE : ALLOW_RESOURCE);
if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_BRAVE_SHIELDS)) {
BraveShieldsContentSettingsJni.get().setBraveShieldsEnabled(value, host, profile);
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_HTTP_UPGRADABLE_RESOURCES)) {
BraveShieldsContentSettingsJni.get().setHTTPSEverywhereEnabled(value, host, profile);
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_JAVASCRIPTS)) {
BraveShieldsContentSettingsJni.get().setNoScriptControlType(setting_string, host, profile);
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_FORGET_FIRST_PARTY_STORAGE)) {
Expand Down Expand Up @@ -119,8 +116,6 @@ public static boolean getShields(Profile profile, String host, String resourceIn
String settings = BLOCK_RESOURCE;
if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_BRAVE_SHIELDS)) {
return BraveShieldsContentSettingsJni.get().getBraveShieldsEnabled(host, profile);
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_HTTP_UPGRADABLE_RESOURCES)) {
return BraveShieldsContentSettingsJni.get().getHTTPSEverywhereEnabled(host, profile);
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_JAVASCRIPTS)) {
settings = BraveShieldsContentSettingsJni.get().getNoScriptControlType(host, profile);
} else if (resourceIndentifier.equals(RESOURCE_IDENTIFIER_FORGET_FIRST_PARTY_STORAGE)) {
Expand Down Expand Up @@ -151,12 +146,6 @@ public static String getShieldsValue(Profile profile, String host, String resour
return settings;
}

public static void setHTTPSEverywherePref(boolean value) {
setShields(Profile.getLastUsedRegularProfile(), "",
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_HTTP_UPGRADABLE_RESOURCES, value,
false);
}

public static void setFingerprintingPref(String value) {
setShieldsValue(Profile.getLastUsedRegularProfile(), "",
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FINGERPRINTING, value, false);
Expand Down Expand Up @@ -208,11 +197,6 @@ public static String getHttpsUpgradePref() {
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_HTTPS_UPGRADE);
}

public static boolean getHTTPSEverywherePref() {
return getShields(Profile.getLastUsedRegularProfile(), "",
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_HTTP_UPGRADABLE_RESOURCES);
}

public static boolean getForgetFirstPartyStoragePref() {
return getShields(Profile.getLastUsedRegularProfile(), "",
BraveShieldsContentSettings.RESOURCE_IDENTIFIER_FORGET_FIRST_PARTY_STORAGE);
Expand Down Expand Up @@ -251,8 +235,6 @@ interface Natives {
String getCookieControlType(String url, Profile profile);
void setFingerprintingControlType(String type, String url, Profile profile);
String getFingerprintingControlType(String url, Profile profile);
void setHTTPSEverywhereEnabled(boolean enabled, String url, Profile profile);
boolean getHTTPSEverywhereEnabled(String url, Profile profile);
void setHttpsUpgradeControlType(String type, String url, Profile profile);
String getHttpsUpgradeControlType(String url, Profile profile);
void setNoScriptControlType(String type, String url, Profile profile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
private static final String PREF_OTHER_PRIVACY_SETTINGS_SECTION =
"other_privacy_settings_section";

private static final String PREF_HTTPSE = "httpse";
private static final String PREF_DE_AMP = "de_amp";
private static final String PREF_DEBOUNCE = "debounce";
private static final String PREF_IPFS_GATEWAY = "ipfs_gateway";
Expand Down Expand Up @@ -117,27 +116,56 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
private static final String PREF_FORGET_FIRST_PARTY_STORAGE = "forget_first_party_storage";

private static final String[] NEW_PRIVACY_PREFERENCE_ORDER = {
PREF_BRAVE_SHIELDS_GLOBALS_SECTION, // shields globals section
PREF_SHIELDS_SUMMARY, PREF_BLOCK_TRACKERS_ADS, PREF_DE_AMP, PREF_DEBOUNCE,
PREF_HTTPS_UPGRADE, PREF_HTTPSE, PREF_HTTPS_FIRST_MODE, PREF_BLOCK_SCRIPTS,
PREF_BLOCK_CROSS_SITE_COOKIES, PREF_FINGERPRINTING_PROTECTION,
PREF_FINGERPRINT_LANGUAGE, PREF_CONTENT_FILTERING, PREF_FORGET_FIRST_PARTY_STORAGE,
PREF_CLEAR_DATA_SECTION, // clear data automatically section
PREF_CLEAR_ON_EXIT, PREF_CLEAR_BROWSING_DATA,
PREF_BRAVE_SOCIAL_BLOCKING_SECTION, // social blocking section
PREF_SOCIAL_BLOCKING_GOOGLE, PREF_SOCIAL_BLOCKING_FACEBOOK,
PREF_SOCIAL_BLOCKING_TWITTER, PREF_SOCIAL_BLOCKING_LINKEDIN,
PREF_YOUTUBE_SECTION, // Youtube section
PREF_HIDE_YOUTUBE_RECOMMENDED_CONTENT, PREF_HIDE_YOUTUBE_DISTRACTING_ELEMENTS,
PREF_OTHER_PRIVACY_SETTINGS_SECTION, // other section
PREF_APP_LINKS, PREF_WEBRTC_POLICY, PREF_SAFE_BROWSING, PREF_INCOGNITO_LOCK,
PREF_CAN_MAKE_PAYMENT, PREF_UNSTOPPABLE_DOMAINS, PREF_ENS, PREF_SNS, PREF_REQUEST_OTR,
PREF_IPFS_GATEWAY, PREF_SECURE_DNS, PREF_BLOCK_COOKIE_CONSENT_NOTICES,
PREF_BLOCK_SWITCH_TO_APP_NOTICES, PREF_DO_NOT_TRACK, PREF_PHONE_AS_A_SECURITY_KEY,
PREF_CLOSE_TABS_ON_EXIT, PREF_SEND_P3A, PREF_SEND_CRASH_REPORTS,
PREF_BRAVE_STATS_USAGE_PING, PREF_SHOW_AUTOCOMPLETE_IN_ADDRESS_BAR,
PREF_SEARCH_SUGGESTIONS, PREF_AUTOCOMPLETE_TOP_SITES, PREF_USAGE_STATS,
PREF_PRIVACY_SANDBOX};
PREF_BRAVE_SHIELDS_GLOBALS_SECTION, // shields globals section
PREF_SHIELDS_SUMMARY,
PREF_BLOCK_TRACKERS_ADS,
PREF_DE_AMP,
PREF_DEBOUNCE,
PREF_HTTPS_UPGRADE,
PREF_HTTPS_FIRST_MODE,
PREF_BLOCK_SCRIPTS,
PREF_BLOCK_CROSS_SITE_COOKIES,
PREF_FINGERPRINTING_PROTECTION,
PREF_FINGERPRINT_LANGUAGE,
PREF_CONTENT_FILTERING,
PREF_FORGET_FIRST_PARTY_STORAGE,
PREF_CLEAR_DATA_SECTION, // clear data automatically section
PREF_CLEAR_ON_EXIT,
PREF_CLEAR_BROWSING_DATA,
PREF_BRAVE_SOCIAL_BLOCKING_SECTION, // social blocking section
PREF_SOCIAL_BLOCKING_GOOGLE,
PREF_SOCIAL_BLOCKING_FACEBOOK,
PREF_SOCIAL_BLOCKING_TWITTER,
PREF_SOCIAL_BLOCKING_LINKEDIN,
PREF_YOUTUBE_SECTION, // Youtube section
PREF_HIDE_YOUTUBE_RECOMMENDED_CONTENT,
PREF_HIDE_YOUTUBE_DISTRACTING_ELEMENTS,
PREF_OTHER_PRIVACY_SETTINGS_SECTION, // other section
PREF_APP_LINKS,
PREF_WEBRTC_POLICY,
PREF_SAFE_BROWSING,
PREF_INCOGNITO_LOCK,
PREF_CAN_MAKE_PAYMENT,
PREF_UNSTOPPABLE_DOMAINS,
PREF_ENS,
PREF_SNS,
PREF_REQUEST_OTR,
PREF_IPFS_GATEWAY,
PREF_SECURE_DNS,
PREF_BLOCK_COOKIE_CONSENT_NOTICES,
PREF_BLOCK_SWITCH_TO_APP_NOTICES,
PREF_DO_NOT_TRACK,
PREF_PHONE_AS_A_SECURITY_KEY,
PREF_CLOSE_TABS_ON_EXIT,
PREF_SEND_P3A,
PREF_SEND_CRASH_REPORTS,
PREF_BRAVE_STATS_USAGE_PING,
PREF_SHOW_AUTOCOMPLETE_IN_ADDRESS_BAR,
PREF_SEARCH_SUGGESTIONS,
PREF_AUTOCOMPLETE_TOP_SITES,
PREF_USAGE_STATS,
PREF_PRIVACY_SANDBOX
};

private static final int STRICT = 0;
private static final int STANDARD = 1;
Expand All @@ -154,7 +182,6 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
private BraveDialogPreference mBlockCrosssiteCookies;
private ChromeSwitchPreference mShowAutocompleteInAddressBar;
private ChromeSwitchPreference mAutocompleteTopSites;
private ChromeSwitchPreference mHttpsePref;
private ChromeSwitchPreference mDeAmpPref;
private ChromeSwitchPreference mDebouncePref;
private ChromeSwitchPreference mHttpsFirstModePref;
Expand All @@ -174,7 +201,6 @@ public class BravePrivacySettings extends PrivacySettings implements ConnectionE
private ChromeSwitchPreference mHideYoutubeDistractingElementsPref;
private PreferenceCategory mSocialBlockingCategory;
private ChromeSwitchPreference mSocialBlockingGoogle;
private ChromeSwitchPreference mHttpsEverywhere;
private ChromeSwitchPreference mSocialBlockingFacebook;
private ChromeSwitchPreference mSocialBlockingTwitter;
private ChromeSwitchPreference mSocialBlockingLinkedin;
Expand Down Expand Up @@ -221,9 +247,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

initFilterListAndroidHandler();

mHttpsePref = (ChromeSwitchPreference) findPreference(PREF_HTTPSE);
mHttpsePref.setOnPreferenceChangeListener(this);

mDeAmpPref = (ChromeSwitchPreference) findPreference(PREF_DE_AMP);
mDeAmpPref.setOnPreferenceChangeListener(this);

Expand All @@ -241,8 +264,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

boolean httpsByDefaultIsEnabled =
ChromeFeatureList.isEnabled(BraveFeatureList.HTTPS_BY_DEFAULT);
mHttpsePref.setVisible(!httpsByDefaultIsEnabled);
mHttpsFirstModePref.setVisible(!httpsByDefaultIsEnabled && mHttpsePref.isChecked());
mHttpsFirstModePref.setVisible(!httpsByDefaultIsEnabled);
mHttpsUpgradePref.setVisible(httpsByDefaultIsEnabled);

mCanMakePayment = (ChromeSwitchPreference) findPreference(PREF_CAN_MAKE_PAYMENT);
Expand Down Expand Up @@ -408,27 +430,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
String key = preference.getKey();
SharedPreferences.Editor sharedPreferencesEditor =
ContextUtils.getAppSharedPreferences().edit();
if (PREF_HTTPSE.equals(key)) {
boolean newValueBool = (boolean) newValue;
BraveShieldsContentSettings.setHTTPSEverywherePref(newValueBool);
mHttpsFirstModePref.setVisible(newValueBool);
if (newValueBool) {
// Restore state of HTTPS_ONLY_MODE.
UserPrefs.get(Profile.getLastUsedRegularProfile())
.setBoolean(Pref.HTTPS_ONLY_MODE_ENABLED,
ContextUtils.getAppSharedPreferences().getBoolean(
PREF_HTTPS_ONLY_MODE_ENABLED_SAVED_STATE, false));
mHttpsFirstModePref.setChecked(UserPrefs.get(Profile.getLastUsedRegularProfile())
.getBoolean(Pref.HTTPS_ONLY_MODE_ENABLED));
} else {
// Save state for HTTPS_ONLY_MODE and disable it.
sharedPreferencesEditor.putBoolean(PREF_HTTPS_ONLY_MODE_ENABLED_SAVED_STATE,
UserPrefs.get(Profile.getLastUsedRegularProfile())
.getBoolean(Pref.HTTPS_ONLY_MODE_ENABLED));
UserPrefs.get(Profile.getLastUsedRegularProfile())
.setBoolean(Pref.HTTPS_ONLY_MODE_ENABLED, newValueBool);
}
} else if (PREF_HTTPS_FIRST_MODE.equals(key)) {
if (PREF_HTTPS_FIRST_MODE.equals(key)) {
UserPrefs.get(Profile.getLastUsedRegularProfile())
.setBoolean(Pref.HTTPS_ONLY_MODE_ENABLED, (boolean) newValue);
} else if (PREF_HTTPS_UPGRADE.equals(key)) {
Expand Down Expand Up @@ -640,16 +642,13 @@ private void updateBravePreferences() {

mBlockScriptsPref.setChecked(BraveShieldsContentSettings.getJavascriptPref());

// HTTPSE and HTTPS only mode
final boolean httpseEnabled = BraveShieldsContentSettings.getHTTPSEverywherePref();
mHttpsePref.setChecked(httpseEnabled);
// HTTPS only mode
boolean httpsByDefaultIsEnabled =
ChromeFeatureList.isEnabled(BraveFeatureList.HTTPS_BY_DEFAULT);
mHttpsFirstModePref.setVisible(!httpsByDefaultIsEnabled && httpseEnabled);
mHttpsFirstModePref.setChecked(httpseEnabled
? UserPrefs.get(Profile.getLastUsedRegularProfile())
.getBoolean(Pref.HTTPS_ONLY_MODE_ENABLED)
: false);
mHttpsFirstModePref.setVisible(!httpsByDefaultIsEnabled);
mHttpsFirstModePref.setChecked(
UserPrefs.get(Profile.getLastUsedRegularProfile())
.getBoolean(Pref.HTTPS_ONLY_MODE_ENABLED));

// IPFS Gateway
mIpfsGatewayPref.setChecked(BravePrivacySettingsIPFSUtils.getIPFSGatewayPref());
Expand Down
Loading