OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/guest_view/web_view/web_view_guest.h" | 5 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 if (!base::IsStringUTF8(storage_partition_id)) { | 385 if (!base::IsStringUTF8(storage_partition_id)) { |
386 content::RecordAction( | 386 content::RecordAction( |
387 base::UserMetricsAction("BadMessageTerminate_BPGM")); | 387 base::UserMetricsAction("BadMessageTerminate_BPGM")); |
388 base::KillProcess( | 388 base::KillProcess( |
389 embedder_render_process_host->GetHandle(), | 389 embedder_render_process_host->GetHandle(), |
390 content::RESULT_CODE_KILLED_BAD_MESSAGE, false); | 390 content::RESULT_CODE_KILLED_BAD_MESSAGE, false); |
391 return; | 391 return; |
392 } | 392 } |
393 std::string url_encoded_partition = net::EscapeQueryParamValue( | 393 std::string url_encoded_partition = net::EscapeQueryParamValue( |
394 storage_partition_id, false); | 394 storage_partition_id, false); |
| 395 std::string emburl; |
| 396 if (!create_params.GetString("emburl", &emburl)) { |
| 397 emburl = embedder_extension_id; |
| 398 } else { |
| 399 printf("Found emburl: %s\n", emburl.c_str()); |
| 400 } |
395 // The SiteInstance of a given webview tag is based on the fact that it's | 401 // The SiteInstance of a given webview tag is based on the fact that it's |
396 // a guest process in addition to which platform application the tag | 402 // a guest process in addition to which platform application the tag |
397 // belongs to and what storage partition is in use, rather than the URL | 403 // belongs to and what storage partition is in use, rather than the URL |
398 // that the tag is being navigated to. | 404 // that the tag is being navigated to. |
399 GURL guest_site(base::StringPrintf("%s://%s/%s?%s", | 405 GURL guest_site(base::StringPrintf("%s://%s/%s?%s", |
400 content::kGuestScheme, | 406 content::kGuestScheme, |
401 embedder_extension_id.c_str(), | 407 //embedder_extension_id.c_str(), |
| 408 emburl.c_str(), |
402 persist_storage ? "persist" : "", | 409 persist_storage ? "persist" : "", |
403 url_encoded_partition.c_str())); | 410 url_encoded_partition.c_str())); |
404 | 411 |
405 // If we already have a webview tag in the same app using the same storage | 412 // If we already have a webview tag in the same app using the same storage |
406 // partition, we should use the same SiteInstance so the existing tag and | 413 // partition, we should use the same SiteInstance so the existing tag and |
407 // the new tag can script each other. | 414 // the new tag can script each other. |
408 GuestViewManager* guest_view_manager = | 415 GuestViewManager* guest_view_manager = |
409 GuestViewManager::FromBrowserContext( | 416 GuestViewManager::FromBrowserContext( |
410 embedder_render_process_host->GetBrowserContext()); | 417 embedder_render_process_host->GetBrowserContext()); |
411 content::SiteInstance* guest_site_instance = | 418 content::SiteInstance* guest_site_instance = |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 void WebViewGuest::DocumentLoadedInFrame( | 1082 void WebViewGuest::DocumentLoadedInFrame( |
1076 int64 frame_id, | 1083 int64 frame_id, |
1077 content::RenderViewHost* render_view_host) { | 1084 content::RenderViewHost* render_view_host) { |
1078 if (frame_id == main_frame_id_) | 1085 if (frame_id == main_frame_id_) |
1079 InjectChromeVoxIfNeeded(render_view_host); | 1086 InjectChromeVoxIfNeeded(render_view_host); |
1080 } | 1087 } |
1081 | 1088 |
1082 bool WebViewGuest::OnMessageReceived(const IPC::Message& message, | 1089 bool WebViewGuest::OnMessageReceived(const IPC::Message& message, |
1083 RenderFrameHost* render_frame_host) { | 1090 RenderFrameHost* render_frame_host) { |
1084 bool handled = true; | 1091 bool handled = true; |
| 1092 printf("+++++ %s\n", __PRETTY_FUNCTION__); |
1085 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message) | 1093 IPC_BEGIN_MESSAGE_MAP(WebViewGuest, message) |
1086 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdateFrameName, OnUpdateFrameName) | 1094 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdateFrameName, OnUpdateFrameName) |
1087 IPC_MESSAGE_UNHANDLED(handled = false) | 1095 IPC_MESSAGE_UNHANDLED(handled = false) |
1088 IPC_END_MESSAGE_MAP() | 1096 IPC_END_MESSAGE_MAP() |
1089 return handled; | 1097 return handled; |
1090 } | 1098 } |
1091 | 1099 |
1092 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { | 1100 void WebViewGuest::RenderProcessGone(base::TerminationStatus status) { |
1093 // Cancel all find sessions in progress. | 1101 // Cancel all find sessions in progress. |
1094 find_helper_.CancelAllFindSessions(); | 1102 find_helper_.CancelAllFindSessions(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 void WebViewGuest::PushWebViewStateToIOThread() { | 1154 void WebViewGuest::PushWebViewStateToIOThread() { |
1147 const GURL& site_url = guest_web_contents()->GetSiteInstance()->GetSiteURL(); | 1155 const GURL& site_url = guest_web_contents()->GetSiteInstance()->GetSiteURL(); |
1148 std::string partition_domain; | 1156 std::string partition_domain; |
1149 std::string partition_id; | 1157 std::string partition_id; |
1150 bool in_memory; | 1158 bool in_memory; |
1151 if (!GetGuestPartitionConfigForSite( | 1159 if (!GetGuestPartitionConfigForSite( |
1152 site_url, &partition_domain, &partition_id, &in_memory)) { | 1160 site_url, &partition_domain, &partition_id, &in_memory)) { |
1153 NOTREACHED(); | 1161 NOTREACHED(); |
1154 return; | 1162 return; |
1155 } | 1163 } |
1156 DCHECK(embedder_extension_id() == partition_domain); | 1164 //DCHECK(embedder_extension_id() == partition_domain); |
1157 | 1165 |
1158 WebViewRendererState::WebViewInfo web_view_info; | 1166 WebViewRendererState::WebViewInfo web_view_info; |
1159 web_view_info.embedder_process_id = embedder_render_process_id(); | 1167 web_view_info.embedder_process_id = embedder_render_process_id(); |
1160 web_view_info.instance_id = view_instance_id(); | 1168 web_view_info.instance_id = view_instance_id(); |
1161 web_view_info.partition_id = partition_id; | 1169 web_view_info.partition_id = partition_id; |
1162 web_view_info.embedder_extension_id = embedder_extension_id(); | 1170 web_view_info.embedder_extension_id = embedder_extension_id(); |
1163 | 1171 |
1164 content::BrowserThread::PostTask( | 1172 content::BrowserThread::PostTask( |
1165 content::BrowserThread::IO, | 1173 content::BrowserThread::IO, |
1166 FROM_HERE, | 1174 FROM_HERE, |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 it != pending_new_windows.end(); ++it) { | 1646 it != pending_new_windows.end(); ++it) { |
1639 it->first->Destroy(); | 1647 it->first->Destroy(); |
1640 } | 1648 } |
1641 // All pending windows should be removed from the set after Destroy() is | 1649 // All pending windows should be removed from the set after Destroy() is |
1642 // called on all of them. | 1650 // called on all of them. |
1643 DCHECK(pending_new_windows_.empty()); | 1651 DCHECK(pending_new_windows_.empty()); |
1644 } | 1652 } |
1645 | 1653 |
1646 GURL WebViewGuest::ResolveURL(const std::string& src) { | 1654 GURL WebViewGuest::ResolveURL(const std::string& src) { |
1647 if (!in_extension()) { | 1655 if (!in_extension()) { |
1648 NOTREACHED(); | 1656 //NOTREACHED(); |
1649 return GURL(src); | 1657 return GURL(src); |
1650 } | 1658 } |
1651 | 1659 |
1652 GURL default_url(base::StringPrintf("%s://%s/", | 1660 GURL default_url(base::StringPrintf("%s://%s/", |
1653 extensions::kExtensionScheme, | 1661 extensions::kExtensionScheme, |
1654 embedder_extension_id().c_str())); | 1662 embedder_extension_id().c_str())); |
1655 return default_url.Resolve(src); | 1663 return default_url.Resolve(src); |
1656 } | 1664 } |
1657 | 1665 |
1658 void WebViewGuest::OnWebViewNewWindowResponse( | 1666 void WebViewGuest::OnWebViewNewWindowResponse( |
1659 int new_window_instance_id, | 1667 int new_window_instance_id, |
1660 bool allow, | 1668 bool allow, |
1661 const std::string& user_input) { | 1669 const std::string& user_input) { |
1662 WebViewGuest* guest = | 1670 WebViewGuest* guest = |
1663 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1671 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
1664 if (!guest) | 1672 if (!guest) |
1665 return; | 1673 return; |
1666 | 1674 |
1667 if (!allow) | 1675 if (!allow) |
1668 guest->Destroy(); | 1676 guest->Destroy(); |
1669 } | 1677 } |
OLD | NEW |