Chromium Code Reviews| 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 if (extra_params->GetString(guestview::kStoragePartitionId, | |
|
Fady Samuel
2014/06/03 19:40:40
The partition ID is really a <webview> concept. Ca
lazyboy
2014/06/03 22:30:11
Done.
| |
| 68 &storage_partition_string)) { | |
| 69 WebViewGuest::ParsePartitionParam( | |
| 70 storage_partition_string, &storage_partition_id, &persist_storage); | |
| 71 } | |
| 72 | |
| 65 content::RenderProcessHost* embedder_process_host = | 73 content::RenderProcessHost* embedder_process_host = |
| 66 embedder_site_instance->GetProcess(); | 74 embedder_site_instance->GetProcess(); |
| 67 // Validate that the partition id coming from the renderer is valid UTF-8, | 75 // 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 | 76 // 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 | 77 // creation. If the validation fails, treat it as a bad message and kill the |
| 70 // renderer process. | 78 // renderer process. |
| 71 if (!base::IsStringUTF8(storage_partition_id)) { | 79 if (!base::IsStringUTF8(storage_partition_id)) { |
| 72 content::RecordAction( | 80 content::RecordAction( |
| 73 base::UserMetricsAction("BadMessageTerminate_BPGM")); | 81 base::UserMetricsAction("BadMessageTerminate_BPGM")); |
| 74 base::KillProcess( | 82 base::KillProcess( |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 return false; | 266 return false; |
| 259 | 267 |
| 260 return embedder_render_process_id == | 268 return embedder_render_process_id == |
| 261 guest->GetOpener()->embedder_web_contents()->GetRenderProcessHost()-> | 269 guest->GetOpener()->embedder_web_contents()->GetRenderProcessHost()-> |
| 262 GetID(); | 270 GetID(); |
| 263 } | 271 } |
| 264 | 272 |
| 265 return embedder_render_process_id == | 273 return embedder_render_process_id == |
| 266 guest->embedder_web_contents()->GetRenderProcessHost()->GetID(); | 274 guest->embedder_web_contents()->GetRenderProcessHost()->GetID(); |
| 267 } | 275 } |
| OLD | NEW |