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 "extensions/browser/guest_view/web_view/web_view_guest.h" | 5 #include "extensions/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 "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 bool persist_storage = false; | 235 bool persist_storage = false; |
236 std::string storage_partition_string; | 236 std::string storage_partition_string; |
237 ParsePartitionParam(create_params, &storage_partition_id, &persist_storage); | 237 ParsePartitionParam(create_params, &storage_partition_id, &persist_storage); |
238 // Validate that the partition id coming from the renderer is valid UTF-8, | 238 // Validate that the partition id coming from the renderer is valid UTF-8, |
239 // since we depend on this in other parts of the code, such as FilePath | 239 // since we depend on this in other parts of the code, such as FilePath |
240 // creation. If the validation fails, treat it as a bad message and kill the | 240 // creation. If the validation fails, treat it as a bad message and kill the |
241 // renderer process. | 241 // renderer process. |
242 if (!base::IsStringUTF8(storage_partition_id)) { | 242 if (!base::IsStringUTF8(storage_partition_id)) { |
243 content::RecordAction( | 243 content::RecordAction( |
244 base::UserMetricsAction("BadMessageTerminate_BPGM")); | 244 base::UserMetricsAction("BadMessageTerminate_BPGM")); |
245 base::KillProcess( | 245 owner_render_process_host->Shutdown(content::RESULT_CODE_KILLED_BAD_MESSAGE, |
246 owner_render_process_host->GetHandle(), | 246 false); |
247 content::RESULT_CODE_KILLED_BAD_MESSAGE, false); | |
248 callback.Run(NULL); | 247 callback.Run(NULL); |
249 return; | 248 return; |
250 } | 249 } |
251 std::string url_encoded_partition = net::EscapeQueryParamValue( | 250 std::string url_encoded_partition = net::EscapeQueryParamValue( |
252 storage_partition_id, false); | 251 storage_partition_id, false); |
253 std::string partition_domain = GetOwnerSiteURL().host(); | 252 std::string partition_domain = GetOwnerSiteURL().host(); |
254 GURL guest_site(base::StringPrintf("%s://%s/%s?%s", | 253 GURL guest_site(base::StringPrintf("%s://%s/%s?%s", |
255 content::kGuestScheme, | 254 content::kGuestScheme, |
256 partition_domain.c_str(), | 255 partition_domain.c_str(), |
257 persist_storage ? "persist" : "", | 256 persist_storage ? "persist" : "", |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 | 664 |
666 void WebViewGuest::Stop() { | 665 void WebViewGuest::Stop() { |
667 web_contents()->Stop(); | 666 web_contents()->Stop(); |
668 } | 667 } |
669 | 668 |
670 void WebViewGuest::Terminate() { | 669 void WebViewGuest::Terminate() { |
671 content::RecordAction(UserMetricsAction("WebView.Guest.Terminate")); | 670 content::RecordAction(UserMetricsAction("WebView.Guest.Terminate")); |
672 base::ProcessHandle process_handle = | 671 base::ProcessHandle process_handle = |
673 web_contents()->GetRenderProcessHost()->GetHandle(); | 672 web_contents()->GetRenderProcessHost()->GetHandle(); |
674 if (process_handle) | 673 if (process_handle) |
675 base::KillProcess(process_handle, content::RESULT_CODE_KILLED, false); | 674 web_contents()->GetRenderProcessHost()->Shutdown( |
| 675 content::RESULT_CODE_KILLED, false); |
676 } | 676 } |
677 | 677 |
678 bool WebViewGuest::ClearData(const base::Time remove_since, | 678 bool WebViewGuest::ClearData(const base::Time remove_since, |
679 uint32 removal_mask, | 679 uint32 removal_mask, |
680 const base::Closure& callback) { | 680 const base::Closure& callback) { |
681 content::RecordAction(UserMetricsAction("WebView.Guest.ClearData")); | 681 content::RecordAction(UserMetricsAction("WebView.Guest.ClearData")); |
682 content::StoragePartition* partition = | 682 content::StoragePartition* partition = |
683 content::BrowserContext::GetStoragePartition( | 683 content::BrowserContext::GetStoragePartition( |
684 web_contents()->GetBrowserContext(), | 684 web_contents()->GetBrowserContext(), |
685 web_contents()->GetSiteInstance()); | 685 web_contents()->GetSiteInstance()); |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 WebViewGuest* guest = | 1260 WebViewGuest* guest = |
1261 WebViewGuest::From(owner_render_process_id(), new_window_instance_id); | 1261 WebViewGuest::From(owner_render_process_id(), new_window_instance_id); |
1262 if (!guest) | 1262 if (!guest) |
1263 return; | 1263 return; |
1264 | 1264 |
1265 if (!allow) | 1265 if (!allow) |
1266 guest->Destroy(); | 1266 guest->Destroy(); |
1267 } | 1267 } |
1268 | 1268 |
1269 } // namespace extensions | 1269 } // namespace extensions |
OLD | NEW |