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

HTTPS by default for Desktop #16521

Merged
merged 1 commit into from
Feb 8, 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: 1 addition & 0 deletions android/android_browser_tests.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android_test_exception_sources = [
"//brave/browser/brave_shields/cookie_expiry_browsertest.cc",
"//brave/browser/brave_shields/domain_block_page_browsertest.cc",
"//brave/browser/brave_shields/eventsource_pool_limit_browsertest.cc",
"//brave/browser/brave_shields/https_upgrade_browsertest.cc",
"//brave/browser/brave_shields/websockets_pool_limit_browsertest.cc",
"//brave/browser/brave_wallet/brave_wallet_ethereum_chain_browsertest.cc",
"//brave/browser/brave_wallet/brave_wallet_event_emitter_browsertest.cc",
Expand Down
12 changes: 12 additions & 0 deletions app/brave_settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@
<message name="IDS_SETTINGS_STRICT_FINGERPRINTING" desc="Select value">
Strict, may break sites
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_HTTPS_UPGRADE_CONTROL_LABEL" desc="Default Brave https upgrade control setting label">
Upgrade connections to HTTPS
</message>
<message name="IDS_SETTINGS_STANDARD_HTTPS_UPGRADE" desc="Select value">
Standard
</message>
<message name="IDS_SETTINGS_DISABLED_HTTPS_UPGRADE" desc="Select value">
Disabled
</message>
<message name="IDS_SETTINGS_STRICT_HTTPS_UPGRADE" desc="Select value">
Strict
</message>
<message name="IDS_SETTINGS_BRAVE_SHIELDS_COOKIE_CONTROL_LABEL" desc="Default Brave cookies control setting label">
Block cookies
</message>
Expand Down
5 changes: 5 additions & 0 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 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 https://mozilla.org/MPL/2.0/.

import("//brave/build/config.gni")
import("//build/buildflag_header.gni")
import("//build/config/features.gni")
Expand Down
12 changes: 11 additions & 1 deletion browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ constexpr char kAllowCertainClientHintsDescription[] =
"Allows setting certain request client hints (sec-ch-ua, sec-ch-ua-mobile, "
"sec-ch-ua-platform)";

constexpr char kBraveHttpsByDefaultName[] = "Use HTTPS by Default";
constexpr char kBraveHttpsByDefaultDescription[] =
"Attempt to connect to all websites using HTTPS before falling back to "
"HTTP.";

#if defined(TOOLKIT_VIEWS)
constexpr char kBraveVerticalTabsName[] = "Vertical tabs";
constexpr char kBraveVerticalTabsDescription[] =
Expand Down Expand Up @@ -813,7 +818,7 @@ constexpr char kRestrictEventSourcePoolDescription[] =
flag_descriptions::kBraveTorWindowsHttpsOnlyName, \
flag_descriptions::kBraveTorWindowsHttpsOnlyDescription, \
kOsAll, FEATURE_VALUE_TYPE( \
blink::features::kBraveTorWindowsHttpsOnly)}, \
net::features::kBraveTorWindowsHttpsOnly)}, \
{"brave-round-time-stamps", \
flag_descriptions::kBraveRoundTimeStampsName, \
flag_descriptions::kBraveRoundTimeStampsDescription, \
Expand All @@ -839,6 +844,11 @@ constexpr char kRestrictEventSourcePoolDescription[] =
flag_descriptions::kBraveSyncSendAllHistoryDescription, \
kOsAll, FEATURE_VALUE_TYPE( \
brave_sync::features::kBraveSyncSendAllHistory)}, \
{"https-by-default", \
flag_descriptions::kBraveHttpsByDefaultName, \
flag_descriptions::kBraveHttpsByDefaultDescription, \
kOsAll, FEATURE_VALUE_TYPE( \
net::features::kBraveHttpsByDefault)}, \
BRAVE_IPFS_FEATURE_ENTRIES \
BRAVE_NATIVE_WALLET_FEATURE_ENTRIES \
BRAVE_NEWS_FEATURE_ENTRIES \
Expand Down
8 changes: 7 additions & 1 deletion browser/brave_browser_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ namespace debounce {
class DebounceComponentInstaller;
} // namespace debounce

namespace https_upgrade_exceptions {
class HttpsUpgradeExceptionsService;
} // namespace https_upgrade_exceptions

namespace misc_metrics {
class MenuMetrics;
} // namespace misc_metrics
Expand All @@ -66,7 +70,7 @@ class NTPBackgroundImagesService;
namespace tor {
class BraveTorClientUpdater;
class BraveTorPluggableTransportUpdater;
}
} // namespace tor

namespace ipfs {
class BraveIpfsClientUpdater;
Expand All @@ -86,6 +90,8 @@ class BraveBrowserProcess {
virtual ~BraveBrowserProcess();
virtual void StartBraveServices() = 0;
virtual brave_shields::AdBlockService* ad_block_service() = 0;
virtual https_upgrade_exceptions::HttpsUpgradeExceptionsService*
https_upgrade_exceptions_service() = 0;
#if BUILDFLAG(ENABLE_GREASELION)
virtual greaselion::GreaselionDownloadService*
greaselion_download_service() = 0;
Expand Down
16 changes: 16 additions & 0 deletions browser/brave_browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "brave/components/constants/pref_names.h"
#include "brave/components/debounce/browser/debounce_component_installer.h"
#include "brave/components/debounce/common/features.h"
#include "brave/components/https_upgrade_exceptions/browser/https_upgrade_exceptions_service.h"
#include "brave/components/misc_metrics/menu_metrics.h"
#include "brave/components/ntp_background_images/browser/ntp_background_images_service.h"
#include "brave/components/p3a/brave_p3a_service.h"
Expand All @@ -53,6 +54,7 @@
#include "components/component_updater/timer_update_scheduler.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h"
#include "net/base/features.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "url/gurl.h"
Expand Down Expand Up @@ -200,6 +202,10 @@ void BraveBrowserProcessImpl::StartBraveServices() {
https_everywhere_service()->Start();
resource_component();

if (base::FeatureList::IsEnabled(net::features::kBraveHttpsByDefault)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is definitely not the right place for this check. All this is doing is delaying the initialization if the feature is disabled. The check should go inside HttpsUpgradeExceptionsService

https_upgrade_exceptions_service();
}

#if BUILDFLAG(ENABLE_GREASELION)
greaselion_download_service();
#endif
Expand Down Expand Up @@ -242,6 +248,16 @@ BraveBrowserProcessImpl::ntp_background_images_service() {
return ntp_background_images_service_.get();
}

https_upgrade_exceptions::HttpsUpgradeExceptionsService*
BraveBrowserProcessImpl::https_upgrade_exceptions_service() {
if (!https_upgrade_exceptions_service_) {
https_upgrade_exceptions_service_ =
https_upgrade_exceptions::HttpsUpgradeExceptionsServiceFactory(
local_data_files_service());
}
return https_upgrade_exceptions_service_.get();
}

#if BUILDFLAG(ENABLE_GREASELION)
greaselion::GreaselionDownloadService*
BraveBrowserProcessImpl::greaselion_download_service() {
Expand Down
12 changes: 10 additions & 2 deletions browser/brave_browser_process_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class AdBlockService;
class HTTPSEverywhereService;
} // namespace brave_shields

namespace https_upgrade_exceptions {
class HttpsUpgradeExceptionsService;
} // namespace https_upgrade_exceptions

namespace brave_stats {
class BraveStatsUpdater;
} // namespace brave_stats
Expand All @@ -63,7 +67,7 @@ class NTPBackgroundImagesService;
namespace tor {
class BraveTorClientUpdater;
class BraveTorPluggableTransportUpdater;
}
} // namespace tor

namespace ipfs {
class BraveIpfsClientUpdater;
Expand All @@ -76,7 +80,7 @@ class SpeedreaderRewriterService;
namespace brave_ads {
class BraveStatsUpdaterHelper;
class ResourceComponent;
}
} // namespace brave_ads

class BraveBrowserProcessImpl : public BraveBrowserProcess,
public BrowserProcessImpl {
Expand All @@ -95,6 +99,8 @@ class BraveBrowserProcessImpl : public BraveBrowserProcess,

void StartBraveServices() override;
brave_shields::AdBlockService* ad_block_service() override;
https_upgrade_exceptions::HttpsUpgradeExceptionsService*
https_upgrade_exceptions_service() override;
#if BUILDFLAG(ENABLE_GREASELION)
greaselion::GreaselionDownloadService* greaselion_download_service() override;
#endif
Expand Down Expand Up @@ -156,6 +162,8 @@ class BraveBrowserProcessImpl : public BraveBrowserProcess,
std::unique_ptr<brave_component_updater::BraveComponent::Delegate>
brave_component_updater_delegate_;
std::unique_ptr<brave_shields::AdBlockService> ad_block_service_;
std::unique_ptr<https_upgrade_exceptions::HttpsUpgradeExceptionsService>
https_upgrade_exceptions_service_;
#if BUILDFLAG(ENABLE_GREASELION)
std::unique_ptr<greaselion::GreaselionDownloadService>
greaselion_download_service_;
Expand Down
Loading