-
Notifications
You must be signed in to change notification settings - Fork 858
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match kExtensionContentVerification behavior on Chromium
- Loading branch information
Showing
4 changed files
with
85 additions
and
7 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
26 changes: 26 additions & 0 deletions
26
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,26 @@ | ||
/* 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) |
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 |
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