Index: chrome/browser/guest_view/guest_view_manager.cc |
diff --git a/chrome/browser/guest_view/guest_view_manager.cc b/chrome/browser/guest_view/guest_view_manager.cc |
index 782ced5e1eb09d7c5f63501e950c4fc31cdf4d15..175ab444dd339f7efdae2fcccd88b41e8fe2c632 100644 |
--- a/chrome/browser/guest_view/guest_view_manager.cc |
+++ b/chrome/browser/guest_view/guest_view_manager.cc |
@@ -23,6 +23,38 @@ using content::BrowserContext; |
using content::SiteInstance; |
using content::WebContents; |
+namespace { |
+ |
+void ParsePartitionParam(const std::string& partition_str, |
+ std::string* storage_partition_id, |
+ bool* persist_storage) { |
+ // Since the "persist:" prefix is in ASCII, StartsWith will work fine on |
+ // UTF-8 encoded |partition_id|. If the prefix is a match, we can safely |
+ // remove the prefix without splicing in the middle of a multi-byte codepoint. |
+ // We can use the rest of the string as UTF-8 encoded one. |
+ if (StartsWithASCII(partition_str, "persist:", true)) { |
+ size_t index = partition_str.find(":"); |
+ CHECK(index != std::string::npos); |
+ // It is safe to do index + 1, since we tested for the full prefix above. |
+ *storage_partition_id = partition_str.substr(index + 1); |
+ |
+ if (storage_partition_id->empty()) { |
+ // TODO(lazyboy): Better way to deal with this error. |
+ return; |
+ } |
+ *persist_storage = true; |
+ } else { |
+ *storage_partition_id = partition_str; |
+ *persist_storage = false; |
+ } |
+ |
+ printf("Output: storage_partition_id: %s, persist_storage: %d\n", |
+ storage_partition_id->c_str(), *persist_storage); |
+} |
+ |
+} // namespace |
+ |
+ |
// A WebContents does not immediately have a RenderProcessHost. It acquires one |
// on initial navigation. This observer exists until that initial navigation in |
// order to grab the ID if tis RenderProcessHost so that it can register it as |
@@ -95,9 +127,18 @@ int GuestViewManager::GetNextInstanceID() { |
content::WebContents* GuestViewManager::CreateGuest( |
Fady Samuel
2014/05/27 14:19:06
I'd like to chat about this method. I want to make
lazyboy
2014/05/27 20:43:00
OK.
We can do this in future CLs.
|
content::SiteInstance* embedder_site_instance, |
int instance_id, |
- const std::string& storage_partition_id, |
- bool persist_storage, |
scoped_ptr<base::DictionaryValue> extra_params) { |
+ std::string storage_partition_id; |
+ bool persist_storage = false; |
+ std::string storage_partition_string; |
+ if (extra_params->GetString(guestview::kStoragePartitionId, |
+ &storage_partition_string)) { |
+ ParsePartitionParam( |
+ storage_partition_string, &storage_partition_id, &persist_storage); |
+ } else { |
+ printf("Not found storagePartitionId key\n"); |
+ } |
+ |
content::RenderProcessHost* embedder_process_host = |
embedder_site_instance->GetProcess(); |
// Validate that the partition id coming from the renderer is valid UTF-8, |