summaryrefslogtreecommitdiffstats
path: root/extensions/browser/guest_view
diff options
context:
space:
mode:
authorpaulmeyer <paulmeyer@chromium.org>2015-09-09 08:29:59 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-09 15:30:39 +0000
commitad727fc6c70d04cdd0a9a7d14c4aa68b4c0e8e72 (patch)
tree636ac8f7f24b949da300eac03b6ac9668d8b0c84 /extensions/browser/guest_view
parentcb8a8e9c598b6a59c1955b89618680acdca17231 (diff)
downloadchromium_src-ad727fc6c70d04cdd0a9a7d14c4aa68b4c0e8e72.zip
chromium_src-ad727fc6c70d04cdd0a9a7d14c4aa68b4c0e8e72.tar.gz
chromium_src-ad727fc6c70d04cdd0a9a7d14c4aa68b4c0e8e72.tar.bz2
This patch allows the webview.partitions.accessible_resources entry in chrome app manifests to work fully as intended.
Previously, web pages attempting to use resources specified as webview accessible would fail to load those resources. This happened because a check in the renderer would stop the resource request from being made before the request ever reached the browser process where the webview accessible resources are checked in the manifest. This patch corrects this problem by propagating webview partition IDs to webview guest renderer processes, so that they can check the correct entry in the manifest for accessible resources and allow valid requests to go through to the browser process. BUG=460797 Review URL: https://codereview.chromium.org/1312653003 Cr-Commit-Position: refs/heads/master@{#347936}
Diffstat (limited to 'extensions/browser/guest_view')
-rw-r--r--extensions/browser/guest_view/web_view/web_view_guest.cc18
-rw-r--r--extensions/browser/guest_view/web_view/web_view_guest.h6
-rw-r--r--extensions/browser/guest_view/web_view/web_view_renderer_state.h22
3 files changed, 34 insertions, 12 deletions
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc
index bab38da..3c3c0e5 100644
--- a/extensions/browser/guest_view/web_view/web_view_guest.cc
+++ b/extensions/browser/guest_view/web_view/web_view_guest.cc
@@ -48,6 +48,7 @@
#include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_messages.h"
+#include "extensions/common/manifest_constants.h"
#include "extensions/strings/grit/extensions_strings.h"
#include "ipc/ipc_message_macros.h"
#include "net/base/escape.h"
@@ -58,6 +59,7 @@
using base::UserMetricsAction;
using content::GlobalRequestID;
using content::RenderFrameHost;
+using content::RenderProcessHost;
using content::ResourceType;
using content::StoragePartition;
using content::WebContents;
@@ -266,6 +268,18 @@ bool WebViewGuest::GetGuestPartitionConfigForSite(
}
// static
+std::string WebViewGuest::GetPartitionID(
+ const RenderProcessHost* render_process_host) {
+ WebViewRendererState* renderer_state = WebViewRendererState::GetInstance();
+ int process_id = render_process_host->GetID();
+ std::string partition_id;
+ if (renderer_state->IsGuest(process_id))
+ renderer_state->GetPartitionID(process_id, &partition_id);
+
+ return partition_id;
+}
+
+// static
const char WebViewGuest::Type[] = "webview";
// static
@@ -281,7 +295,7 @@ int WebViewGuest::GetOrGenerateRulesRegistryID(
if (it != web_view_key_to_id_map.Get().end())
return it->second;
- auto rph = content::RenderProcessHost::FromID(embedder_process_id);
+ auto rph = RenderProcessHost::FromID(embedder_process_id);
int rules_registry_id =
RulesRegistryService::Get(rph->GetBrowserContext())->
GetNextRulesRegistryID();
@@ -296,7 +310,7 @@ bool WebViewGuest::CanRunInDetachedState() const {
void WebViewGuest::CreateWebContents(
const base::DictionaryValue& create_params,
const WebContentsCreatedCallback& callback) {
- content::RenderProcessHost* owner_render_process_host =
+ RenderProcessHost* owner_render_process_host =
owner_web_contents()->GetRenderProcessHost();
std::string storage_partition_id;
bool persist_storage = false;
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.h b/extensions/browser/guest_view/web_view/web_view_guest.h
index 9144c68..1f1a1ad 100644
--- a/extensions/browser/guest_view/web_view/web_view_guest.h
+++ b/extensions/browser/guest_view/web_view/web_view_guest.h
@@ -60,6 +60,12 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest>,
std::string* partition_name,
bool* in_memory);
+ // Returns the WebView partition ID associated with the render process
+ // represented by |render_process_host|, if any. Otherwise, an empty string is
+ // returned.
+ static std::string GetPartitionID(
+ const content::RenderProcessHost* render_process_host);
+
static const char Type[];
// Returns the stored rules registry ID of the given webview. Will generate
diff --git a/extensions/browser/guest_view/web_view/web_view_renderer_state.h b/extensions/browser/guest_view/web_view/web_view_renderer_state.h
index c43afd2..24dce02 100644
--- a/extensions/browser/guest_view/web_view/web_view_renderer_state.h
+++ b/extensions/browser/guest_view/web_view/web_view_renderer_state.h
@@ -24,8 +24,6 @@ namespace extensions {
class WebViewGuest;
-// This class keeps track of <webview> renderer state for use on the IO thread.
-// All methods should be called on the IO thread.
class WebViewRendererState {
public:
struct WebViewInfo {
@@ -42,23 +40,27 @@ class WebViewRendererState {
static WebViewRendererState* GetInstance();
- // Looks up the information for the embedder <webview> for a given render
- // view, if one exists. Called on the IO thread.
+ // Looks up the information for the embedder WebView for a RenderViewHost,
+ // given its process and view ID. Returns true and writes the information to
+ // |web_view_info| if found, otherwise returns false.
bool GetInfo(int guest_process_id,
int guest_routing_id,
WebViewInfo* web_view_info) const;
- // Looks up the information for the owner for a given guest process in a
- // <webview>. Called on the IO thread.
+ // Looks up the information for the owner of a WebView guest process, given
+ // its process ID. Returns true and writes the info to |owner_process_id| and
+ // |owner_host| if found, otherwise returns false.
bool GetOwnerInfo(int guest_process_id,
int* owner_process_id,
std::string* owner_host) const;
- // Looks up the partition info for the embedder <webview> for a given guest
- // process. Called on the IO thread.
+ // Looks up the partition ID for a WebView guest process, given its
+ // process ID. Returns true and writes the partition ID to |partition_id| if
+ // found, otherwise returns false.
bool GetPartitionID(int guest_process_id, std::string* partition_id) const;
- // Returns true if the given renderer is used by webviews.
+ // Returns true if the renderer with process ID |render_process_id| is a
+ // WebView guest process.
bool IsGuest(int render_process_id) const;
void AddContentScriptIDs(int embedder_process_id,
@@ -89,7 +91,7 @@ class WebViewRendererState {
WebViewRendererState();
~WebViewRendererState();
- // Adds or removes a <webview> guest render process from the set.
+ // Adds/removes a WebView guest render process to/from the set.
void AddGuest(int render_process_host_id, int routing_id,
const WebViewInfo& web_view_info);
void RemoveGuest(int render_process_host_id, int routing_id);