This is a simple accessor change for our uses. Chromium changes: https://chromium.googlesource.com/chromium/src/+/02e3f72738b5ad02e8f30ab40ea1467550a91f2c commit 02e3f72738b5ad02e8f30ab40ea1467550a91f2c Author: Viktoriya Bryhider <vbryhider@microsoft.com> Date: Mon Feb 23 19:24:08 2026 -0800 Move GetStoragePartitionConfig to SecurityPrincipal interface Refactor storage partition configuration access by introducing GetStoragePartitionConfig() on the SecurityPrincipal interface and removing it from SiteInstance. Update all call sites to access the storage partition configuration through GetSecurityPrincipal().GetStoragePartitionConfig() instead of directly calling GetStoragePartitionConfig() on SiteInstance. This CL also adds unit test to ensure that the storage partition config remains unchanged once accessed, preventing accidental changes that could violate security boundaries. Most of existing functionality remains unchanged. The StoragePartitionConfig consistency verification now triggers on any call to GetSiteInfo()/GetSecurityPrincipal() before SetSiteInfoInternal() assigns the final SiteInfo, rather than only when the StoragePartitionConfig is explicitly accessed. This is a broader check than before, but it avoids the need to plumb an extra flag through SecurityPrincipal/SiteInfo to track whether GetSecurityPrincipal() was used specifically to read the StoragePartitionConfig. Bug: 397481045, 40526490 Change-Id: I21e504383273f0adea8035fd6a9432b96920190d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7231185 Commit-Queue: Viktoriya Bryhider <vbryhider@microsoft.com> Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Owners-Override: Alex Moshchuk <alexmos@chromium.org> Reviewed-by: Charlie Reis <creis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1589122}
72 lines
2.7 KiB
C++
72 lines
2.7 KiB
C++
/* Copyright (c) 2020 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 "content/public/browser/browser_context.h"
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include "base/check.h"
|
|
#include "brave/components/ai_chat/core/common/buildflags/buildflags.h"
|
|
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
|
|
#include "content/browser/dom_storage/dom_storage_context_wrapper.h"
|
|
#include "content/browser/dom_storage/session_storage_namespace_impl.h"
|
|
#include "content/browser/renderer_host/navigation_controller_impl.h"
|
|
#include "content/browser/renderer_host/render_view_host_delegate.h"
|
|
#include "content/browser/site_instance_impl.h"
|
|
#include "content/public/browser/render_view_host.h"
|
|
#include "content/public/browser/session_storage_namespace.h"
|
|
#include "content/public/browser/storage_partition.h"
|
|
#include "content/public/browser/web_contents.h"
|
|
|
|
namespace content {
|
|
|
|
mojo::PendingRemote<storage::mojom::BlobStorageContext>
|
|
GetRemoteBlobStorageContextFor(BrowserContext* browser_context) {
|
|
return content::ChromeBlobStorageContext::GetRemoteFor(browser_context);
|
|
}
|
|
|
|
scoped_refptr<content::SessionStorageNamespace> CreateSessionStorageNamespace(
|
|
content::StoragePartition* partition,
|
|
const std::string& namespace_id,
|
|
std::optional<std::string> clone_from_namespace_id) {
|
|
content::DOMStorageContextWrapper* context_wrapper =
|
|
static_cast<content::DOMStorageContextWrapper*>(
|
|
partition->GetDOMStorageContext());
|
|
|
|
if (clone_from_namespace_id) {
|
|
return content::SessionStorageNamespaceImpl::CloneFrom(
|
|
context_wrapper, namespace_id, clone_from_namespace_id.value(), true);
|
|
} else {
|
|
return content::SessionStorageNamespaceImpl::Create(context_wrapper,
|
|
namespace_id);
|
|
}
|
|
}
|
|
|
|
std::string GetSessionStorageNamespaceId(WebContents* web_contents) {
|
|
SiteInstanceImpl* site_instance_impl =
|
|
static_cast<SiteInstanceImpl*>(web_contents->GetSiteInstance());
|
|
DCHECK(site_instance_impl);
|
|
|
|
return static_cast<NavigationControllerImpl&>(web_contents->GetController())
|
|
.GetSessionStorageNamespace(site_instance_impl->GetSecurityPrincipal()
|
|
.GetStoragePartitionConfig())
|
|
->id();
|
|
}
|
|
|
|
} // namespace content
|
|
|
|
namespace content {
|
|
bool BrowserContext::IsTor() const {
|
|
return false;
|
|
}
|
|
|
|
bool BrowserContext::IsAIChatAgent() const {
|
|
NOTREACHED() << "Use Profile::IsAIChatAgent() instead";
|
|
}
|
|
} // namespace content
|
|
|
|
#include <content/browser/browser_context.cc>
|