| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 bool persist_storage = false; | 208 bool persist_storage = false; |
| 209 std::string storage_partition_string; | 209 std::string storage_partition_string; |
| 210 ParsePartitionParam(create_params, &storage_partition_id, &persist_storage); | 210 ParsePartitionParam(create_params, &storage_partition_id, &persist_storage); |
| 211 // Validate that the partition id coming from the renderer is valid UTF-8, | 211 // Validate that the partition id coming from the renderer is valid UTF-8, |
| 212 // since we depend on this in other parts of the code, such as FilePath | 212 // since we depend on this in other parts of the code, such as FilePath |
| 213 // creation. If the validation fails, treat it as a bad message and kill the | 213 // creation. If the validation fails, treat it as a bad message and kill the |
| 214 // renderer process. | 214 // renderer process. |
| 215 if (!base::IsStringUTF8(storage_partition_id)) { | 215 if (!base::IsStringUTF8(storage_partition_id)) { |
| 216 content::RecordAction( | 216 content::RecordAction( |
| 217 base::UserMetricsAction("BadMessageTerminate_BPGM")); | 217 base::UserMetricsAction("BadMessageTerminate_BPGM")); |
| 218 base::KillProcess( | 218 embedder_render_process_host->FastShutdown( |
| 219 embedder_render_process_host->GetHandle(), | |
| 220 content::RESULT_CODE_KILLED_BAD_MESSAGE, false); | 219 content::RESULT_CODE_KILLED_BAD_MESSAGE, false); |
| 221 callback.Run(NULL); | 220 callback.Run(NULL); |
| 222 return; | 221 return; |
| 223 } | 222 } |
| 224 std::string url_encoded_partition = net::EscapeQueryParamValue( | 223 std::string url_encoded_partition = net::EscapeQueryParamValue( |
| 225 storage_partition_id, false); | 224 storage_partition_id, false); |
| 226 std::string partition_domain = embedder_site_url.host(); | 225 std::string partition_domain = embedder_site_url.host(); |
| 227 GURL guest_site(base::StringPrintf("%s://%s/%s?%s", | 226 GURL guest_site(base::StringPrintf("%s://%s/%s?%s", |
| 228 content::kGuestScheme, | 227 content::kGuestScheme, |
| 229 partition_domain.c_str(), | 228 partition_domain.c_str(), |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 | 631 |
| 633 void WebViewGuest::Stop() { | 632 void WebViewGuest::Stop() { |
| 634 web_contents()->Stop(); | 633 web_contents()->Stop(); |
| 635 } | 634 } |
| 636 | 635 |
| 637 void WebViewGuest::Terminate() { | 636 void WebViewGuest::Terminate() { |
| 638 content::RecordAction(UserMetricsAction("WebView.Guest.Terminate")); | 637 content::RecordAction(UserMetricsAction("WebView.Guest.Terminate")); |
| 639 base::ProcessHandle process_handle = | 638 base::ProcessHandle process_handle = |
| 640 web_contents()->GetRenderProcessHost()->GetHandle(); | 639 web_contents()->GetRenderProcessHost()->GetHandle(); |
| 641 if (process_handle) | 640 if (process_handle) |
| 642 base::KillProcess(process_handle, content::RESULT_CODE_KILLED, false); | 641 web_contents()->GetRenderProcessHost()->FastShutdown( |
| 642 content::RESULT_CODE_KILLED, false); |
| 643 } | 643 } |
| 644 | 644 |
| 645 bool WebViewGuest::ClearData(const base::Time remove_since, | 645 bool WebViewGuest::ClearData(const base::Time remove_since, |
| 646 uint32 removal_mask, | 646 uint32 removal_mask, |
| 647 const base::Closure& callback) { | 647 const base::Closure& callback) { |
| 648 content::RecordAction(UserMetricsAction("WebView.Guest.ClearData")); | 648 content::RecordAction(UserMetricsAction("WebView.Guest.ClearData")); |
| 649 content::StoragePartition* partition = | 649 content::StoragePartition* partition = |
| 650 content::BrowserContext::GetStoragePartition( | 650 content::BrowserContext::GetStoragePartition( |
| 651 web_contents()->GetBrowserContext(), | 651 web_contents()->GetBrowserContext(), |
| 652 web_contents()->GetSiteInstance()); | 652 web_contents()->GetSiteInstance()); |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 WebViewGuest* guest = | 1219 WebViewGuest* guest = |
| 1220 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1220 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
| 1221 if (!guest) | 1221 if (!guest) |
| 1222 return; | 1222 return; |
| 1223 | 1223 |
| 1224 if (!allow) | 1224 if (!allow) |
| 1225 guest->Destroy(); | 1225 guest->Destroy(); |
| 1226 } | 1226 } |
| 1227 | 1227 |
| 1228 } // namespace extensions | 1228 } // namespace extensions |
| OLD | NEW |