Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1898)

Unified Diff: content/browser/browser_plugin/browser_plugin_embedder.cc

Issue 11234032: Webview tag creation should be using storage partitions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for all comments so far. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_plugin/browser_plugin_embedder.cc
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc
index 1f4b64ba3657a4fd283fb7fd1e5c8f125e467336..c79ae8e776c763e4f85bede291b7618b313b342d 100644
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc
@@ -15,7 +15,9 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
+#include "content/public/common/result_codes.h"
#include "content/public/common/url_constants.h"
+#include "net/base/escape.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "ui/gfx/size.h"
@@ -80,11 +82,35 @@ void BrowserPluginEmbedder::CreateGuest(
BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
CHECK(!guest);
+ // Validate that the partition id coming from the renderer is valid UTF-8,
+ // since we depend on this in other parts of the code, such as FilePath
+ // creation. If the validation fails, treat it as a bad message and kill the
+ // process.
awong 2012/11/07 18:14:30 process -> renderer process
nasko 2012/11/07 18:48:05 Done.
+ if (!IsStringUTF8(params.storage_partition_id)) {
+ base::KillProcess(render_view_host->GetProcess()->GetHandle(),
Charlie Reis 2012/11/07 18:38:36 Please add this line before the kill: content::Rec
nasko 2012/11/07 18:48:05 Done.
+ content::RESULT_CODE_KILLED_BAD_MESSAGE, false);
+ return;
+ }
+
const std::string& host =
render_view_host->GetSiteInstance()->GetSiteURL().host();
+ std::string url_encoded_partition = net::EscapeQueryParamValue(
+ params.storage_partition_id, false);
+
+ // The SiteInstance of a given webview tag is based on the fact that it's a
+ // guest process in addition to which platform application the tag belongs to
+ // and what storage partition is in use, rather than the URL that the tag is
+ // being navigated to.
+ GURL guest_site(
+ base::StringPrintf("%s://%s/%s?%s", chrome::kGuestScheme,
+ host.c_str(), params.persist_storage ? "persist" : "",
+ url_encoded_partition.c_str()));
+ SiteInstance* guest_site_instance = SiteInstance::CreateForURL(
+ web_contents()->GetBrowserContext(), guest_site);
+
guest_web_contents = WebContentsImpl::CreateGuest(
web_contents()->GetBrowserContext(),
- host,
+ guest_site_instance,
instance_id,
params);

Powered by Google App Engine
This is Rietveld 408576698