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

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: Removing the custom format of partition id. 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
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/common/url_constants.h" 18 #include "content/public/common/url_constants.h"
19 #include "net/base/escape.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
20 #include "ui/gfx/size.h" 21 #include "ui/gfx/size.h"
21 22
22 namespace content { 23 namespace content {
23 24
24 // static 25 // static
25 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; 26 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL;
26 27
27 BrowserPluginEmbedder::BrowserPluginEmbedder( 28 BrowserPluginEmbedder::BrowserPluginEmbedder(
28 WebContentsImpl* web_contents, 29 WebContentsImpl* web_contents,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 74 }
74 75
75 void BrowserPluginEmbedder::CreateGuest( 76 void BrowserPluginEmbedder::CreateGuest(
76 RenderViewHost* render_view_host, 77 RenderViewHost* render_view_host,
77 int instance_id, 78 int instance_id,
78 const BrowserPluginHostMsg_CreateGuest_Params& params) { 79 const BrowserPluginHostMsg_CreateGuest_Params& params) {
79 WebContentsImpl* guest_web_contents = NULL; 80 WebContentsImpl* guest_web_contents = NULL;
80 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); 81 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
81 CHECK(!guest); 82 CHECK(!guest);
82 83
84 std::string url_encoded_partition;
85 bool persist_storage = params.persist_storage;
86
87 // Validate that the partition id coming from the renderer is valid UTF-8,
88 // since we depend on this in other parts of the code, such as FilePath
89 // creation.
90 if (IsStringUTF8(params.storage_partition_id)) {
91 url_encoded_partition = net::EscapeQueryParamValue(
92 params.storage_partition_id, false);
93 } else {
94 // Since the partition id is not valid UTF-8, fallback to the default
95 // in-memory partition.
awong 2012/11/07 01:14:11 Not sure how I feel about this. It's okay, but ki
awong 2012/11/07 01:14:11 Not sure how I feel about this. If the renderer is
Charlie Reis 2012/11/07 02:36:34 I don't know if we have access to BrowserMessageFi
nasko 2012/11/07 17:47:01 As Charlie pointed in offline discussion, FilterUR
nasko 2012/11/07 17:47:01 BadMessageReceived is a MessageFilter method that
96 url_encoded_partition.clear();
97 persist_storage = false;
98 }
99
83 const std::string& host = 100 const std::string& host =
84 render_view_host->GetSiteInstance()->GetSiteURL().host(); 101 render_view_host->GetSiteInstance()->GetSiteURL().host();
102
103 // The SiteInstance of a given webview tag is based on the fact that it's a
104 // guest process in addition to which platform application the tag belongs to
105 // and what storage partition is in use, rather than the URL that the tag is
106 // being navigated to.
107 GURL guest_site(
108 base::StringPrintf("%s://%s/%s?%s", chrome::kGuestScheme,
109 host.c_str(), persist_storage ? "persist" : "",
110 url_encoded_partition.c_str()));
111 SiteInstance* guest_site_instance = SiteInstance::CreateForURL(
112 web_contents()->GetBrowserContext(), guest_site);
113
85 guest_web_contents = WebContentsImpl::CreateGuest( 114 guest_web_contents = WebContentsImpl::CreateGuest(
86 web_contents()->GetBrowserContext(), 115 web_contents()->GetBrowserContext(),
87 host, 116 guest_site_instance,
88 instance_id, 117 instance_id,
89 params); 118 params);
90 119
91 guest = guest_web_contents->GetBrowserPluginGuest(); 120 guest = guest_web_contents->GetBrowserPluginGuest();
92 guest->set_embedder_web_contents( 121 guest->set_embedder_web_contents(
93 static_cast<WebContentsImpl*>(web_contents())); 122 static_cast<WebContentsImpl*>(web_contents()));
94 123
95 RendererPreferences* guest_renderer_prefs = 124 RendererPreferences* guest_renderer_prefs =
96 guest_web_contents->GetMutableRendererPrefs(); 125 guest_web_contents->GetMutableRendererPrefs();
97 // Copy renderer preferences (and nothing else) from the embedder's 126 // 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(); 304 bool visible = *Details<bool>(details).ptr();
276 WebContentsVisibilityChanged(visible); 305 WebContentsVisibilityChanged(visible);
277 break; 306 break;
278 } 307 }
279 default: 308 default:
280 NOTREACHED() << "Unexpected notification type: " << type; 309 NOTREACHED() << "Unexpected notification type: " << type;
281 } 310 }
282 } 311 }
283 312
284 } // namespace content 313 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698