| 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 efd5708e35a70a7899c6c65080c61eb31e832eaf..f3a74dfbdfecc8070f3d4c0397760c0aef7a2eb3 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(
|
| 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,
|
|
|