OLD | NEW |
---|---|
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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "content/browser/browser_plugin/browser_plugin_embedder_helper.h" | 12 #include "content/browser/browser_plugin/browser_plugin_embedder_helper.h" |
13 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 13 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
14 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 14 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
15 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
16 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
17 #include "content/common/browser_plugin_messages.h" | 17 #include "content/common/browser_plugin_messages.h" |
18 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
20 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
21 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
22 #include "content/public/browser/web_contents_view.h" | 22 #include "content/public/browser/web_contents_view.h" |
23 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
24 #include "net/base/escape.h" | |
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
25 #include "ui/gfx/size.h" | 26 #include "ui/gfx/size.h" |
26 #include "ui/surface/transport_dib.h" | 27 #include "ui/surface/transport_dib.h" |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 // static | 31 // static |
31 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; | 32 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; |
32 | 33 |
33 BrowserPluginEmbedder::BrowserPluginEmbedder( | 34 BrowserPluginEmbedder::BrowserPluginEmbedder( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 void BrowserPluginEmbedder::CreateGuest(RenderViewHost* render_view_host, | 82 void BrowserPluginEmbedder::CreateGuest(RenderViewHost* render_view_host, |
82 int instance_id, | 83 int instance_id, |
83 std::string storage_partition_id, | 84 std::string storage_partition_id, |
84 bool persist_storage, | 85 bool persist_storage, |
85 bool focused, | 86 bool focused, |
86 bool visible) { | 87 bool visible) { |
87 WebContentsImpl* guest_web_contents = NULL; | 88 WebContentsImpl* guest_web_contents = NULL; |
88 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); | 89 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
89 CHECK(!guest); | 90 CHECK(!guest); |
90 | 91 |
92 // Validate that the partition id coming from the renderer is valid UTF-8, | |
93 // since we depend on this in other parts of the code, such as FilePath | |
94 // creation. | |
95 CHECK(IsStringUTF8(storage_partition_id)); | |
Charlie Reis
2012/11/06 00:17:18
Sanity check: Is crashing the browser process the
nasko
2012/11/07 00:33:57
Done.
| |
96 | |
91 const std::string& host = | 97 const std::string& host = |
92 render_view_host->GetSiteInstance()->GetSiteURL().host(); | 98 render_view_host->GetSiteInstance()->GetSiteURL().host(); |
99 std::string url_encoded_partition = | |
100 net::EscapeQueryParamValue(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(), persist_storage ? "persist" : "", | |
109 url_encoded_partition.c_str())); | |
110 SiteInstance* guest_site_instance = SiteInstance::CreateForURL( | |
Charlie Reis
2012/11/06 00:17:18
Not important for this CL, but if I understand cor
nasko
2012/11/06 01:21:52
Yes. It is not done yet, I will do it in a follow
| |
111 web_contents()->GetBrowserContext(), guest_site); | |
112 | |
93 guest_web_contents = WebContentsImpl::CreateGuest( | 113 guest_web_contents = WebContentsImpl::CreateGuest( |
94 web_contents()->GetBrowserContext(), | 114 web_contents()->GetBrowserContext(), |
95 host, | 115 guest_site_instance, |
96 instance_id, | 116 instance_id, |
97 focused, | 117 focused, |
98 visible); | 118 visible); |
99 | 119 |
100 guest = guest_web_contents->GetBrowserPluginGuest(); | 120 guest = guest_web_contents->GetBrowserPluginGuest(); |
101 guest->set_embedder_web_contents( | 121 guest->set_embedder_web_contents( |
102 static_cast<WebContentsImpl*>(web_contents())); | 122 static_cast<WebContentsImpl*>(web_contents())); |
103 | 123 |
104 RendererPreferences* guest_renderer_prefs = | 124 RendererPreferences* guest_renderer_prefs = |
105 guest_web_contents->GetMutableRendererPrefs(); | 125 guest_web_contents->GetMutableRendererPrefs(); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 bool visible = *Details<bool>(details).ptr(); | 354 bool visible = *Details<bool>(details).ptr(); |
335 WebContentsVisibilityChanged(visible); | 355 WebContentsVisibilityChanged(visible); |
336 break; | 356 break; |
337 } | 357 } |
338 default: | 358 default: |
339 NOTREACHED() << "Unexpected notification type: " << type; | 359 NOTREACHED() << "Unexpected notification type: " << type; |
340 } | 360 } |
341 } | 361 } |
342 | 362 |
343 } // namespace content | 363 } // namespace content |
OLD | NEW |