-
Notifications
You must be signed in to change notification settings - Fork 921
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8392 from brave/bsc-extension-verify-parity
Match Chromium behavior for extension loading
- Loading branch information
Showing
6 changed files
with
162 additions
and
9 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
25 changes: 25 additions & 0 deletions
25
browser/extensions/chrome_content_verifier_delegate_unittest.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,25 @@ | ||
/* Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "chrome/browser/extensions/chrome_content_verifier_delegate.h" | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
#if defined(OFFICIAL_BUILD) | ||
|
||
TEST(ChromeContentVerifierDelegateUnitTest, TestShouldEnforce) { | ||
EXPECT_EQ(extensions::ChromeContentVerifierDelegate::GetDefaultMode(), | ||
extensions::ChromeContentVerifierDelegate::VerifyInfo::Mode:: | ||
ENFORCE_STRICT); | ||
} | ||
|
||
#else | ||
|
||
TEST(ChromeContentVerifierDelegateUnitTest, TestShouldNotEnforce) { | ||
EXPECT_EQ(extensions::ChromeContentVerifierDelegate::GetDefaultMode(), | ||
extensions::ChromeContentVerifierDelegate::VerifyInfo::Mode::NONE); | ||
} | ||
|
||
#endif // defined(OFFICIAL_BUILD) |
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,22 @@ | ||
/* Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "chrome/browser/extensions/install_verifier.h" | ||
|
||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
#if defined(OFFICIAL_BUILD) | ||
|
||
#if defined(OS_WIN) || defined(OS_MAC) | ||
TEST(InstallVerifierUnitTest, TestShouldEnforce) { | ||
EXPECT_TRUE(extensions::InstallVerifier::ShouldEnforce()); | ||
} | ||
#else | ||
TEST(InstallVerifierUnitTest, TestShouldNotEnforce) { | ||
EXPECT_FALSE(extensions::InstallVerifier::ShouldEnforce()); | ||
} | ||
#endif // defined(OS_WIN) || defined(OS_MAC) | ||
|
||
#endif // defined(OFFICIAL_BUILD) |
58 changes: 58 additions & 0 deletions
58
chromium_src/chrome/browser/extensions/chrome_content_verifier_delegate.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,58 @@ | ||
/* Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. */ | ||
#include "chrome/browser/extensions/chrome_content_verifier_delegate.h" | ||
|
||
#include <algorithm> | ||
#include <memory> | ||
#include <set> | ||
#include <vector> | ||
|
||
#include "base/base_switches.h" | ||
#include "base/command_line.h" | ||
#include "base/metrics/field_trial.h" | ||
#include "base/metrics/histogram_macros.h" | ||
#include "base/no_destructor.h" | ||
#include "base/strings/string_piece.h" | ||
#include "base/strings/string_util.h" | ||
#include "base/syslog_logging.h" | ||
#include "base/threading/thread_task_runner_handle.h" | ||
#include "base/version.h" | ||
#include "build/branding_buildflags.h" | ||
#include "build/build_config.h" | ||
#include "build/chromeos_buildflags.h" | ||
#include "chrome/browser/extensions/extension_service.h" | ||
#include "chrome/browser/extensions/install_verifier.h" | ||
#include "chrome/browser/extensions/policy_extension_reinstaller.h" | ||
#include "chrome/common/chrome_switches.h" | ||
#include "chrome/common/extensions/extension_constants.h" | ||
#include "extensions/browser/disable_reason.h" | ||
#include "extensions/browser/extension_prefs.h" | ||
#include "extensions/browser/extension_registry.h" | ||
#include "extensions/browser/extension_system.h" | ||
#include "extensions/browser/management_policy.h" | ||
#include "extensions/browser/pref_types.h" | ||
#include "extensions/common/extension_urls.h" | ||
#include "extensions/common/extensions_client.h" | ||
#include "extensions/common/manifest.h" | ||
#include "extensions/common/manifest_url_handlers.h" | ||
#include "net/base/backoff_entry.h" | ||
#include "net/base/escape.h" | ||
|
||
#if BUILDFLAG(IS_CHROMEOS_ASH) | ||
#include "chrome/browser/extensions/extension_assets_manager_chromeos.h" | ||
#endif | ||
|
||
// All above headers copied from original chrome_content_verifier_delegate.cc | ||
// are included to prevent below GOOGLE_CHROME_BUILD affect them. | ||
|
||
// `VerifyInfo::Mode::ENFORCE_STRICT` is only defaulted for google chrome. | ||
#if defined(OFFICIAL_BUILD) | ||
#undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING | ||
#define BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING() (1) | ||
#endif | ||
#include "../../../../../chrome/browser/extensions/chrome_content_verifier_delegate.cc" | ||
#if defined(OFFICIAL_BUILD) | ||
#undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING | ||
#endif |
54 changes: 54 additions & 0 deletions
54
chromium_src/chrome/browser/extensions/install_verifier.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,54 @@ | ||
/* Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. */ | ||
#include "chrome/browser/extensions/install_verifier.h" | ||
|
||
#include <algorithm> | ||
#include <string> | ||
#include <utility> | ||
|
||
#include "base/base_switches.h" | ||
#include "base/bind.h" | ||
#include "base/command_line.h" | ||
#include "base/containers/contains.h" | ||
#include "base/metrics/field_trial.h" | ||
#include "base/metrics/histogram_macros.h" | ||
#include "base/one_shot_event.h" | ||
#include "base/trace_event/trace_event.h" | ||
#include "build/branding_buildflags.h" | ||
#include "build/build_config.h" | ||
#include "chrome/browser/extensions/extension_management.h" | ||
#include "chrome/browser/extensions/extension_service.h" | ||
#include "chrome/browser/extensions/install_signer.h" | ||
#include "chrome/browser/extensions/install_verifier_factory.h" | ||
#include "chrome/common/chrome_switches.h" | ||
#include "chrome/grit/generated_resources.h" | ||
#include "components/prefs/pref_service.h" | ||
#include "content/public/browser/browser_context.h" | ||
#include "content/public/browser/storage_partition.h" | ||
#include "content/public/common/content_switches.h" | ||
#include "extensions/browser/extension_prefs.h" | ||
#include "extensions/browser/extension_registry.h" | ||
#include "extensions/browser/extension_system.h" | ||
#include "extensions/browser/pref_names.h" | ||
#include "extensions/common/extension.h" | ||
#include "extensions/common/extension_id.h" | ||
#include "extensions/common/extension_set.h" | ||
#include "extensions/common/manifest.h" | ||
#include "extensions/common/manifest_url_handlers.h" | ||
#include "services/network/public/mojom/url_loader_factory.mojom.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
|
||
// All above headers copied from original install_verifier.cc are | ||
// included to prevent below GOOGLE_CHROME_BUILD affect them. | ||
|
||
// `VerifyStatus::ENFORCE` is only defaulted for google chrome. | ||
#if defined(OFFICIAL_BUILD) | ||
#undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING | ||
#define BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING() (1) | ||
#endif | ||
#include "../../../../../chrome/browser/extensions/install_verifier.cc" | ||
#if defined(OFFICIAL_BUILD) | ||
#undef BUILDFLAG_INTERNAL_GOOGLE_CHROME_BRANDING | ||
#endif |
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