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

Enable security components #7521

Merged
merged 3 commits into from
Jan 13, 2021
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
50 changes: 25 additions & 25 deletions app/brave_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "components/omnibox/common/omnibox_features.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/safe_browsing/core/features.h"
#include "components/security_state/core/features.h"
#include "components/sync/base/sync_base_switches.h"
#include "components/translate/core/browser/translate_prefs.h"
#include "components/variations/variations_switches.h"
Expand Down Expand Up @@ -82,16 +83,14 @@ const char kBraveOriginTrialsPublicKey[] =

const char kDummyUrl[] = "https://no-thanks.invalid";

BraveMainDelegate::BraveMainDelegate()
: ChromeMainDelegate() {}
BraveMainDelegate::BraveMainDelegate() : ChromeMainDelegate() {}

BraveMainDelegate::BraveMainDelegate(base::TimeTicks exe_entry_point_ticks)
: ChromeMainDelegate(exe_entry_point_ticks) {}

BraveMainDelegate::~BraveMainDelegate() {}

content::ContentBrowserClient*
BraveMainDelegate::CreateContentBrowserClient() {
content::ContentBrowserClient* BraveMainDelegate::CreateContentBrowserClient() {
#if defined(CHROME_MULTIPLE_DLL_CHILD)
return NULL;
#else
Expand All @@ -112,8 +111,7 @@ BraveMainDelegate::CreateContentRendererClient() {
#endif
}

content::ContentUtilityClient*
BraveMainDelegate::CreateContentUtilityClient() {
content::ContentUtilityClient* BraveMainDelegate::CreateContentUtilityClient() {
#if defined(CHROME_MULTIPLE_DLL_BROWSER)
return NULL;
#else
Expand All @@ -131,19 +129,19 @@ void BraveMainDelegate::PreSandboxStartup() {
#if defined(OS_MAC)
base::PathService::Get(base::DIR_APP_DATA, &chrome_user_data_dir);
chrome_user_data_dir = chrome_user_data_dir.Append("Google/Chrome");
native_messaging_dir = base::FilePath(FILE_PATH_LITERAL(
"/Library/Google/Chrome/NativeMessagingHosts"));
native_messaging_dir = base::FilePath(
FILE_PATH_LITERAL("/Library/Google/Chrome/NativeMessagingHosts"));
#else
chrome::GetDefaultUserDataDirectory(&chrome_user_data_dir);
native_messaging_dir = base::FilePath(FILE_PATH_LITERAL(
"/etc/opt/chrome/native-messaging-hosts"));
native_messaging_dir = base::FilePath(
FILE_PATH_LITERAL("/etc/opt/chrome/native-messaging-hosts"));
#endif // defined(OS_MAC)
base::PathService::OverrideAndCreateIfNeeded(
chrome::DIR_USER_NATIVE_MESSAGING,
chrome_user_data_dir.Append(FILE_PATH_LITERAL("NativeMessagingHosts")),
false, true);
base::PathService::OverrideAndCreateIfNeeded(chrome::DIR_NATIVE_MESSAGING,
native_messaging_dir, false, true);
base::PathService::OverrideAndCreateIfNeeded(
chrome::DIR_NATIVE_MESSAGING, native_messaging_dir, false, true);
#endif // defined(OS_LINUX) || defined(OS_MAC)

#if defined(OS_POSIX) && !defined(OS_MAC)
Expand All @@ -168,10 +166,11 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) {
// Setting these to default values in Chromium to maintain parity
// See: ChromeContentVerifierDelegate::GetDefaultMode for ContentVerification
// See: GetStatus in install_verifier.cc for InstallVerification
command_line.AppendSwitchASCII(switches::kExtensionContentVerification,
command_line.AppendSwitchASCII(
switches::kExtensionContentVerification,
switches::kExtensionContentVerificationEnforceStrict);
command_line.AppendSwitchASCII(switches::kExtensionsInstallVerification,
"enforce");
"enforce");

if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
embedder_support::kOriginTrialPublicKey)) {
Expand All @@ -194,24 +193,25 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) {
// Brave variations
std::string kVariationsServerURL = BRAVE_VARIATIONS_SERVER_URL;
command_line.AppendSwitchASCII(variations::switches::kVariationsServerURL,
kVariationsServerURL.c_str());
kVariationsServerURL.c_str());
CHECK(!kVariationsServerURL.empty());
#endif

// Enabled features.
std::unordered_set<const char*> enabled_features = {
// Upgrade all mixed content
blink::features::kMixedContentAutoupgrade.name,
password_manager::features::kPasswordImport.name,
net::features::kLegacyTLSEnforced.name,
// Enable webui dark theme: @media (prefers-color-scheme: dark) is gated
// on this feature.
features::kWebUIDarkMode.name,
blink::features::kPrefetchPrivacyChanges.name,
blink::features::kReducedReferrerGranularity.name,
// Upgrade all mixed content
blink::features::kMixedContentAutoupgrade.name,
password_manager::features::kPasswordImport.name,
net::features::kLegacyTLSEnforced.name,
// Enable webui dark theme: @media (prefers-color-scheme: dark) is gated
// on this feature.
features::kWebUIDarkMode.name,
blink::features::kPrefetchPrivacyChanges.name,
blink::features::kReducedReferrerGranularity.name,
#if defined(OS_WIN)
features::kWinrtGeolocationImplementation.name,
features::kWinrtGeolocationImplementation.name,
#endif
security_state::features::kSafetyTipUI.name,
};

// Disabled features.
Expand Down
4 changes: 3 additions & 1 deletion app/brave_main_delegate_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
#include "components/omnibox/common/omnibox_features.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/safe_browsing/core/features.h"
#include "components/security_state/core/features.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/content_features.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
#include "content/public/test/browser_test.h"
#include "gpu/config/gpu_finch_features.h"
#include "net/base/features.h"
#include "services/device/public/cpp/device_features.h"
#include "services/network/public/cpp/features.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"

using BraveMainDelegateBrowserTest = InProcessBrowserTest;

Expand Down Expand Up @@ -89,6 +90,7 @@ IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, EnabledFeatures) {
&features::kWinrtGeolocationImplementation,
#endif
&net::features::kLegacyTLSEnforced,
&security_state::features::kSafetyTipUI,
};

for (const auto* feature : enabled_features)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ void ComponentInstaller::Register(ComponentUpdateService* cus,
"cmahhnpholdijhjokonmfdjbfmklppij", // Federated Learning of Cohorts
"eeigpngbgcognadeebkilcpcaedhellh", // Autofill States Data
"gcmjkmgdlgnkkcocmoeiminaijmmjnii", // Subresource Filter Rules
"giekcmmlnklenlaomppkphknjmnnpneh", // Certificate Error Assistant
"jflookgnkcckhobaglndicnbbgbonegd", // Safety Tips
"llkgjffcdpffmhiakmfcdcblohccpfmo", // Origin Trials
"ojhpjlocmbogdgmfpkhlaaeamibhnphh", // Zxcvbn Data Dictionaries
#if defined(OS_ANDROID)
Expand Down