Commit 16a53959 authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

[content] Add RenderFrameHost::{GetStoragePartition,GetBrowserContext}

Add direct methods for getting storage partition and browser context
to RenderFrameHost. This allows more features to be implemented only
on top of RenderFrameHost without referencing WebContents, which can
lead to the wrong RenderFrameHost being queried.

R=alexmos@chromium.org
TBR=amistry@chromium.org,reillyg@chromium.org
BUG=1061899

Change-Id: Ib000cd0b28b90c92cccdca3e29799542e07a0145
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2162857Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#763449}
parent 590a0d2c
...@@ -25,8 +25,7 @@ using device::BluetoothUUID; ...@@ -25,8 +25,7 @@ using device::BluetoothUUID;
namespace { namespace {
BluetoothChooserContext* GetBluetoothChooserContext(RenderFrameHost* frame) { BluetoothChooserContext* GetBluetoothChooserContext(RenderFrameHost* frame) {
auto* profile = Profile::FromBrowserContext( auto* profile = Profile::FromBrowserContext(frame->GetBrowserContext());
WebContents::FromRenderFrameHost(frame)->GetBrowserContext());
return BluetoothChooserContextFactory::GetForProfile(profile); return BluetoothChooserContextFactory::GetForProfile(profile);
} }
......
...@@ -461,9 +461,7 @@ storage::FileSystemContext* GetFileSystemContextForExtensionId( ...@@ -461,9 +461,7 @@ storage::FileSystemContext* GetFileSystemContextForExtensionId(
storage::FileSystemContext* GetFileSystemContextForRenderFrameHost( storage::FileSystemContext* GetFileSystemContextForRenderFrameHost(
Profile* profile, Profile* profile,
content::RenderFrameHost* render_frame_host) { content::RenderFrameHost* render_frame_host) {
content::SiteInstance* site_instance = render_frame_host->GetSiteInstance(); return render_frame_host->GetStoragePartition()->GetFileSystemContext();
return content::BrowserContext::GetStoragePartition(profile, site_instance)->
GetFileSystemContext();
} }
bool ConvertAbsoluteFilePathToFileSystemUrl(Profile* profile, bool ConvertAbsoluteFilePathToFileSystemUrl(Profile* profile,
......
...@@ -3325,6 +3325,15 @@ ukm::SourceId RenderFrameHostImpl::GetPageUkmSourceId() { ...@@ -3325,6 +3325,15 @@ ukm::SourceId RenderFrameHostImpl::GetPageUkmSourceId() {
ukm::SourceIdType::NAVIGATION_ID); ukm::SourceIdType::NAVIGATION_ID);
} }
BrowserContext* RenderFrameHostImpl::GetBrowserContext() {
return GetProcess()->GetBrowserContext();
}
StoragePartition* RenderFrameHostImpl::GetStoragePartition() {
return BrowserContext::GetStoragePartition(GetBrowserContext(),
GetSiteInstance());
}
void RenderFrameHostImpl::RequestTextSurroundingSelection( void RenderFrameHostImpl::RequestTextSurroundingSelection(
blink::mojom::LocalFrame::GetTextSurroundingSelectionCallback callback, blink::mojom::LocalFrame::GetTextSurroundingSelectionCallback callback,
int max_length) { int max_length) {
......
...@@ -363,6 +363,8 @@ class CONTENT_EXPORT RenderFrameHostImpl ...@@ -363,6 +363,8 @@ class CONTENT_EXPORT RenderFrameHostImpl
void SetIsXrOverlaySetup() override; void SetIsXrOverlaySetup() override;
bool IsInBackForwardCache() override; bool IsInBackForwardCache() override;
ukm::SourceId GetPageUkmSourceId() override; ukm::SourceId GetPageUkmSourceId() override;
StoragePartition* GetStoragePartition() override;
BrowserContext* GetBrowserContext() override;
// Determines if a clipboard paste using |data| of type |data_type| is allowed // Determines if a clipboard paste using |data| of type |data_type| is allowed
// in this renderer frame. The implementation delegates to // in this renderer frame. The implementation delegates to
......
...@@ -75,6 +75,8 @@ class RenderProcessHost; ...@@ -75,6 +75,8 @@ class RenderProcessHost;
class RenderViewHost; class RenderViewHost;
class RenderWidgetHostView; class RenderWidgetHostView;
class SiteInstance; class SiteInstance;
class BrowserContext;
class StoragePartition;
// The interface provides a communication conduit with a frame in the renderer. // The interface provides a communication conduit with a frame in the renderer.
class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
...@@ -126,11 +128,21 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, ...@@ -126,11 +128,21 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
// Returns the SiteInstance grouping all RenderFrameHosts that have script // Returns the SiteInstance grouping all RenderFrameHosts that have script
// access to this RenderFrameHost, and must therefore live in the same // access to this RenderFrameHost, and must therefore live in the same
// process. // process.
// Associated SiteInstance never changes.
virtual SiteInstance* GetSiteInstance() = 0; virtual SiteInstance* GetSiteInstance() = 0;
// Returns the process for this frame. // Returns the process for this frame.
// Associated RenderProcessHost never changes.
virtual RenderProcessHost* GetProcess() = 0; virtual RenderProcessHost* GetProcess() = 0;
// Returns a StoragePartition associated with this RenderFrameHost.
// Associated StoragePartition never changes.
virtual StoragePartition* GetStoragePartition() = 0;
// Returns the user browser context associated with this RenderFrameHost.
// Associated BrowserContext never changes.
virtual BrowserContext* GetBrowserContext() = 0;
// Returns the RenderWidgetHostView that can be used to control focus and // Returns the RenderWidgetHostView that can be used to control focus and
// visibility for this frame. // visibility for this frame.
virtual RenderWidgetHostView* GetView() = 0; virtual RenderWidgetHostView* GetView() = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment