| 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/guest_view_manager.h" | 5 #include "chrome/browser/guest_view/guest_view_manager.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/guest_view/guest_view_base.h" | 9 #include "chrome/browser/guest_view/guest_view_base.h" |
| 10 #include "chrome/browser/guest_view/guest_view_constants.h" | 10 #include "chrome/browser/guest_view/guest_view_constants.h" |
| 11 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 12 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
| 13 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/browser/user_metrics.h" | 15 #include "content/public/browser/user_metrics.h" |
| 15 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
| 16 #include "content/public/common/result_codes.h" | 17 #include "content/public/common/result_codes.h" |
| 17 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
| 18 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
| 19 #include "net/base/escape.h" | 20 #include "net/base/escape.h" |
| 20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return GetGuestByInstanceID(guest_instance_id, embedder_render_process_id); | 53 return GetGuestByInstanceID(guest_instance_id, embedder_render_process_id); |
| 53 } | 54 } |
| 54 | 55 |
| 55 int GuestViewManager::GetNextInstanceID() { | 56 int GuestViewManager::GetNextInstanceID() { |
| 56 return ++current_instance_id_; | 57 return ++current_instance_id_; |
| 57 } | 58 } |
| 58 | 59 |
| 59 content::WebContents* GuestViewManager::CreateGuest( | 60 content::WebContents* GuestViewManager::CreateGuest( |
| 60 content::SiteInstance* embedder_site_instance, | 61 content::SiteInstance* embedder_site_instance, |
| 61 int instance_id, | 62 int instance_id, |
| 62 const std::string& storage_partition_id, | |
| 63 bool persist_storage, | |
| 64 scoped_ptr<base::DictionaryValue> extra_params) { | 63 scoped_ptr<base::DictionaryValue> extra_params) { |
| 64 std::string storage_partition_id; |
| 65 bool persist_storage = false; |
| 66 std::string storage_partition_string; |
| 67 WebViewGuest::ParsePartitionParam( |
| 68 extra_params.get(), &storage_partition_id, &persist_storage); |
| 69 |
| 65 content::RenderProcessHost* embedder_process_host = | 70 content::RenderProcessHost* embedder_process_host = |
| 66 embedder_site_instance->GetProcess(); | 71 embedder_site_instance->GetProcess(); |
| 67 // Validate that the partition id coming from the renderer is valid UTF-8, | 72 // Validate that the partition id coming from the renderer is valid UTF-8, |
| 68 // since we depend on this in other parts of the code, such as FilePath | 73 // since we depend on this in other parts of the code, such as FilePath |
| 69 // creation. If the validation fails, treat it as a bad message and kill the | 74 // creation. If the validation fails, treat it as a bad message and kill the |
| 70 // renderer process. | 75 // renderer process. |
| 71 if (!base::IsStringUTF8(storage_partition_id)) { | 76 if (!base::IsStringUTF8(storage_partition_id)) { |
| 72 content::RecordAction( | 77 content::RecordAction( |
| 73 base::UserMetricsAction("BadMessageTerminate_BPGM")); | 78 base::UserMetricsAction("BadMessageTerminate_BPGM")); |
| 74 base::KillProcess( | 79 base::KillProcess( |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 return false; | 263 return false; |
| 259 | 264 |
| 260 return embedder_render_process_id == | 265 return embedder_render_process_id == |
| 261 guest->GetOpener()->embedder_web_contents()->GetRenderProcessHost()-> | 266 guest->GetOpener()->embedder_web_contents()->GetRenderProcessHost()-> |
| 262 GetID(); | 267 GetID(); |
| 263 } | 268 } |
| 264 | 269 |
| 265 return embedder_render_process_id == | 270 return embedder_render_process_id == |
| 266 guest->embedder_web_contents()->GetRenderProcessHost()->GetID(); | 271 guest->embedder_web_contents()->GetRenderProcessHost()->GetID(); |
| 267 } | 272 } |
| OLD | NEW |