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

Side by Side 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: Disabling session storage test for isolated apps. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/browser_context.cc ('k') | content/browser/storage_partition_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "content/browser/browser_plugin/browser_plugin_embedder_helper.h" 8 #include "content/browser/browser_plugin/browser_plugin_embedder_helper.h"
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" 9 #include "content/browser/browser_plugin/browser_plugin_guest.h"
10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
11 #include "content/browser/renderer_host/render_view_host_impl.h" 11 #include "content/browser/renderer_host/render_view_host_impl.h"
12 #include "content/browser/web_contents/web_contents_impl.h" 12 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/common/browser_plugin_messages.h" 13 #include "content/common/browser_plugin_messages.h"
14 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_source.h" 16 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h" 17 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/user_metrics.h"
19 #include "content/public/common/result_codes.h"
18 #include "content/public/common/url_constants.h" 20 #include "content/public/common/url_constants.h"
21 #include "net/base/escape.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
20 #include "ui/gfx/size.h" 23 #include "ui/gfx/size.h"
21 24
22 namespace content { 25 namespace content {
23 26
24 // static 27 // static
25 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; 28 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL;
26 29
27 BrowserPluginEmbedder::BrowserPluginEmbedder( 30 BrowserPluginEmbedder::BrowserPluginEmbedder(
28 WebContentsImpl* web_contents, 31 WebContentsImpl* web_contents,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 76 }
74 77
75 void BrowserPluginEmbedder::CreateGuest( 78 void BrowserPluginEmbedder::CreateGuest(
76 RenderViewHost* render_view_host, 79 RenderViewHost* render_view_host,
77 int instance_id, 80 int instance_id,
78 const BrowserPluginHostMsg_CreateGuest_Params& params) { 81 const BrowserPluginHostMsg_CreateGuest_Params& params) {
79 WebContentsImpl* guest_web_contents = NULL; 82 WebContentsImpl* guest_web_contents = NULL;
80 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); 83 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
81 CHECK(!guest); 84 CHECK(!guest);
82 85
86 // Validate that the partition id coming from the renderer is valid UTF-8,
87 // since we depend on this in other parts of the code, such as FilePath
88 // creation. If the validation fails, treat it as a bad message and kill the
89 // renderer process.
90 if (!IsStringUTF8(params.storage_partition_id)) {
91 content::RecordAction(UserMetricsAction("BadMessageTerminate_BPE"));
92 base::KillProcess(render_view_host->GetProcess()->GetHandle(),
93 content::RESULT_CODE_KILLED_BAD_MESSAGE, false);
94 return;
95 }
96
83 const std::string& host = 97 const std::string& host =
84 render_view_host->GetSiteInstance()->GetSiteURL().host(); 98 render_view_host->GetSiteInstance()->GetSiteURL().host();
99 std::string url_encoded_partition = net::EscapeQueryParamValue(
100 params.storage_partition_id, false);
101
102 // The SiteInstance of a given webview tag is based on the fact that it's a
103 // guest process in addition to which platform application the tag belongs to
104 // and what storage partition is in use, rather than the URL that the tag is
105 // being navigated to.
106 GURL guest_site(
107 base::StringPrintf("%s://%s/%s?%s", chrome::kGuestScheme,
108 host.c_str(), params.persist_storage ? "persist" : "",
109 url_encoded_partition.c_str()));
110 SiteInstance* guest_site_instance = SiteInstance::CreateForURL(
111 web_contents()->GetBrowserContext(), guest_site);
112
85 guest_web_contents = WebContentsImpl::CreateGuest( 113 guest_web_contents = WebContentsImpl::CreateGuest(
86 web_contents()->GetBrowserContext(), 114 web_contents()->GetBrowserContext(),
87 host, 115 guest_site_instance,
88 instance_id, 116 instance_id,
89 params); 117 params);
90 118
91 guest = guest_web_contents->GetBrowserPluginGuest(); 119 guest = guest_web_contents->GetBrowserPluginGuest();
92 guest->set_embedder_web_contents( 120 guest->set_embedder_web_contents(
93 static_cast<WebContentsImpl*>(web_contents())); 121 static_cast<WebContentsImpl*>(web_contents()));
94 122
95 RendererPreferences* guest_renderer_prefs = 123 RendererPreferences* guest_renderer_prefs =
96 guest_web_contents->GetMutableRendererPrefs(); 124 guest_web_contents->GetMutableRendererPrefs();
97 // Copy renderer preferences (and nothing else) from the embedder's 125 // Copy renderer preferences (and nothing else) from the embedder's
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 bool visible = *Details<bool>(details).ptr(); 303 bool visible = *Details<bool>(details).ptr();
276 WebContentsVisibilityChanged(visible); 304 WebContentsVisibilityChanged(visible);
277 break; 305 break;
278 } 306 }
279 default: 307 default:
280 NOTREACHED() << "Unexpected notification type: " << type; 308 NOTREACHED() << "Unexpected notification type: " << type;
281 } 309 }
282 } 310 }
283 311
284 } // namespace content 312 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_context.cc ('k') | content/browser/storage_partition_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698