Files
helium/patches/brave/fix-component-content-settings-store.patch
wukko e67c0db58f patches: move everything from contrib to root dir (#557)
now all chromium patches in all helium repos follow
the same dir pattern: `<vendor>/<group>/<...>/<patch>`

and there's no longer a "contrib" dir which was admittedly
kind of confusing
2025-12-04 01:43:34 +06:00

59 lines
2.5 KiB
C++

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/.
Copyright (c) 2025, The Brave Authors
Copyright (c) 2025, The Helium Authors
Alternatively, the contents of this file may be used under the terms
of the GNU General Public License Version 3, as described below:
Copyright (C) 2025 The Helium Authors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--- a/extensions/browser/extension_registrar.cc
+++ b/extensions/browser/extension_registrar.cc
@@ -18,6 +18,7 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/devtools_agent_host.h"
+#include "extensions/browser/api/content_settings/content_settings_service.h"
#include "extensions/browser/blocklist_extension_prefs.h"
#include "extensions/browser/delayed_install_manager.h"
#include "extensions/browser/disable_reason.h"
@@ -540,6 +541,22 @@ void ExtensionRegistrar::AddComponentExt
}
AddExtension(extension);
+
+ if (!IsExtensionEnabled(extension->id()))
+ return;
+
+ // ContentSettingsStore::RegisterExtension is only called for default
+ // components on the first run with a fresh profile. All restarts of the
+ // browser after that do not call it. This causes ContentSettingsStore's
+ // `entries_` to never insert the component ID and then
+ // ContentSettingsStore::GetValueMap always returns nullptr. I don't think
+ // Chromium is affected by this simply because they don't use content settings
+ // from default component extensions.
+ extension_prefs_->OnExtensionInstalled(
+ extension, /*disable_reasons=*/{}, syncer::StringOrdinal(),
+ extensions::kInstallFlagNone, std::string(), {} /* ruleset_checksums */);
+ extensions::ContentSettingsService::Get(browser_context_)
+ ->OnExtensionPrefsLoaded(extension->id(), extension_prefs_);
}
void ExtensionRegistrar::RemoveComponentExtension(