Chromium Code Reviews| 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 "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/result_codes.h" | |
| 18 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| 20 #include "net/base/escape.h" | |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 20 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 21 | 23 |
| 22 namespace content { | 24 namespace content { |
| 23 | 25 |
| 24 // static | 26 // static |
| 25 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; | 27 BrowserPluginHostFactory* BrowserPluginEmbedder::factory_ = NULL; |
| 26 | 28 |
| 27 BrowserPluginEmbedder::BrowserPluginEmbedder( | 29 BrowserPluginEmbedder::BrowserPluginEmbedder( |
| 28 WebContentsImpl* web_contents, | 30 WebContentsImpl* web_contents, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 } | 75 } |
| 74 | 76 |
| 75 void BrowserPluginEmbedder::CreateGuest( | 77 void BrowserPluginEmbedder::CreateGuest( |
| 76 RenderViewHost* render_view_host, | 78 RenderViewHost* render_view_host, |
| 77 int instance_id, | 79 int instance_id, |
| 78 const BrowserPluginHostMsg_CreateGuest_Params& params) { | 80 const BrowserPluginHostMsg_CreateGuest_Params& params) { |
| 79 WebContentsImpl* guest_web_contents = NULL; | 81 WebContentsImpl* guest_web_contents = NULL; |
| 80 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); | 82 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
| 81 CHECK(!guest); | 83 CHECK(!guest); |
| 82 | 84 |
| 85 // Validate that the partition id coming from the renderer is valid UTF-8, | |
| 86 // since we depend on this in other parts of the code, such as FilePath | |
| 87 // creation. If the validation fails, treat it as a bad message and kill the | |
| 88 // process. | |
|
awong
2012/11/07 18:14:30
process -> renderer process
nasko
2012/11/07 18:48:05
Done.
| |
| 89 if (!IsStringUTF8(params.storage_partition_id)) { | |
| 90 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.
| |
| 91 content::RESULT_CODE_KILLED_BAD_MESSAGE, false); | |
| 92 return; | |
| 93 } | |
| 94 | |
| 83 const std::string& host = | 95 const std::string& host = |
| 84 render_view_host->GetSiteInstance()->GetSiteURL().host(); | 96 render_view_host->GetSiteInstance()->GetSiteURL().host(); |
| 97 std::string url_encoded_partition = net::EscapeQueryParamValue( | |
| 98 params.storage_partition_id, false); | |
| 99 | |
| 100 // The SiteInstance of a given webview tag is based on the fact that it's a | |
| 101 // guest process in addition to which platform application the tag belongs to | |
| 102 // and what storage partition is in use, rather than the URL that the tag is | |
| 103 // being navigated to. | |
| 104 GURL guest_site( | |
| 105 base::StringPrintf("%s://%s/%s?%s", chrome::kGuestScheme, | |
| 106 host.c_str(), params.persist_storage ? "persist" : "", | |
| 107 url_encoded_partition.c_str())); | |
| 108 SiteInstance* guest_site_instance = SiteInstance::CreateForURL( | |
| 109 web_contents()->GetBrowserContext(), guest_site); | |
| 110 | |
| 85 guest_web_contents = WebContentsImpl::CreateGuest( | 111 guest_web_contents = WebContentsImpl::CreateGuest( |
| 86 web_contents()->GetBrowserContext(), | 112 web_contents()->GetBrowserContext(), |
| 87 host, | 113 guest_site_instance, |
| 88 instance_id, | 114 instance_id, |
| 89 params); | 115 params); |
| 90 | 116 |
| 91 guest = guest_web_contents->GetBrowserPluginGuest(); | 117 guest = guest_web_contents->GetBrowserPluginGuest(); |
| 92 guest->set_embedder_web_contents( | 118 guest->set_embedder_web_contents( |
| 93 static_cast<WebContentsImpl*>(web_contents())); | 119 static_cast<WebContentsImpl*>(web_contents())); |
| 94 | 120 |
| 95 RendererPreferences* guest_renderer_prefs = | 121 RendererPreferences* guest_renderer_prefs = |
| 96 guest_web_contents->GetMutableRendererPrefs(); | 122 guest_web_contents->GetMutableRendererPrefs(); |
| 97 // Copy renderer preferences (and nothing else) from the embedder's | 123 // Copy renderer preferences (and nothing else) from the embedder's |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 bool visible = *Details<bool>(details).ptr(); | 301 bool visible = *Details<bool>(details).ptr(); |
| 276 WebContentsVisibilityChanged(visible); | 302 WebContentsVisibilityChanged(visible); |
| 277 break; | 303 break; |
| 278 } | 304 } |
| 279 default: | 305 default: |
| 280 NOTREACHED() << "Unexpected notification type: " << type; | 306 NOTREACHED() << "Unexpected notification type: " << type; |
| 281 } | 307 } |
| 282 } | 308 } |
| 283 | 309 |
| 284 } // namespace content | 310 } // namespace content |
| OLD | NEW |