Chromium Code Reviews| Index: chrome/browser/guest_view/web_view/web_view_guest.cc |
| diff --git a/chrome/browser/guest_view/web_view/web_view_guest.cc b/chrome/browser/guest_view/web_view/web_view_guest.cc |
| index 3286f09b41a09e63a7dd305bf6e59110523b3ef6..79d48ca015bb9b0f25c4e01727d291b717ea314f 100644 |
| --- a/chrome/browser/guest_view/web_view/web_view_guest.cc |
| +++ b/chrome/browser/guest_view/web_view/web_view_guest.cc |
| @@ -140,6 +140,18 @@ static std::string PermissionTypeToString(WebViewPermissionType type) { |
| } |
| } |
| +std::string GetStoragePartitionIdFromSiteURL(const GURL& site_url) { |
| + const std::string& partition_id = site_url.query(); |
| + bool persist_storage = site_url.path().find("persist") != std::string::npos; |
| + |
| + printf("site_url: %s\n", site_url.possibly_invalid_spec().c_str()); |
| + printf("partition would be: %s\n", site_url.query().c_str()); |
| + printf("extracted: id: %s, persist_storage: %d\n", |
| + partition_id.c_str(), persist_storage); |
| + |
| + return (persist_storage ? webview::kPersistPrefix : "") + partition_id; |
| +} |
| + |
| void RemoveWebViewEventListenersOnIOThread( |
| void* profile, |
| const std::string& extension_id, |
| @@ -189,6 +201,7 @@ WebViewGuest::WebViewGuest(int guest_instance_id, |
| chromevox_injected_(false), |
| find_helper_(this), |
| javascript_dialog_helper_(this) { |
| + printf("++++ %s\n", __PRETTY_FUNCTION__); |
| notification_registrar_.Add( |
| this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| content::Source<WebContents>(guest_web_contents)); |
| @@ -337,6 +350,7 @@ void WebViewGuest::Attach(WebContents* embedder_web_contents, |
| bool WebViewGuest::HandleContextMenu( |
| const content::ContextMenuParams& params) { |
| + printf("++++ %s\n", __PRETTY_FUNCTION__); |
| ContextMenuDelegate* menu_delegate = |
| ContextMenuDelegate::FromWebContents(guest_web_contents()); |
| DCHECK(menu_delegate); |
| @@ -376,7 +390,15 @@ void WebViewGuest::CloseContents(WebContents* source) { |
| DispatchEvent(new GuestViewBase::Event(webview::kEventClose, args.Pass())); |
| } |
| -void WebViewGuest::DidAttach() { |
| +void WebViewGuest::DidAttach(const base::DictionaryValue& extra_params) { |
| + std::string src; |
| + if (extra_params.GetString("src", &src) && !src.empty()) { |
| + printf("DidAttach, src = %s\n", src.c_str()); |
| + NavigateGuest(src); |
| + } else { |
| + printf("DidAttach, no src\n"); |
| + } |
| + |
| if (GetOpener()) { |
| // We need to do a navigation here if the target URL has changed between |
| // the time the WebContents was created and the time it was attached. |
| @@ -506,16 +528,15 @@ WebViewGuest* WebViewGuest::CreateNewGuestWindow( |
| // We pull the partition information from the site's URL, which is of the |
| // form guest://site/{persist}?{partition_name}. |
| const GURL& site_url = guest_web_contents()->GetSiteInstance()->GetSiteURL(); |
| - |
| scoped_ptr<base::DictionaryValue> create_params(extra_params()->DeepCopy()); |
| - const std::string& storage_partition_id = site_url.query(); |
| - bool persist_storage = |
| - site_url.path().find("persist") != std::string::npos; |
| + const std::string storage_partition_id = |
| + GetStoragePartitionIdFromSiteURL(site_url); |
| + create_params->SetString(guestview::kStoragePartitionId, |
| + storage_partition_id); |
| + |
| WebContents* new_guest_web_contents = |
| guest_manager->CreateGuest(guest_web_contents()->GetSiteInstance(), |
| instance_id, |
| - storage_partition_id, |
| - persist_storage, |
| create_params.Pass()); |
| WebViewGuest* new_guest = |
| WebViewGuest::FromWebContents(new_guest_web_contents); |
| @@ -792,6 +813,7 @@ bool WebViewGuest::ClearData(const base::Time remove_since, |
| } |
| WebViewGuest::~WebViewGuest() { |
| + printf("++++ %s\n", __PRETTY_FUNCTION__); |
| } |
| void WebViewGuest::DidCommitProvisionalLoadForFrame( |
| @@ -1241,6 +1263,7 @@ WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { |
| void WebViewGuest::ShowContextMenu(int request_id, |
| const MenuItemVector* items) { |
| + printf("++++ %s\n", __PRETTY_FUNCTION__); |
| if (!pending_menu_.get()) |
| return; |
| @@ -1355,6 +1378,12 @@ void WebViewGuest::RequestNewWindowPermission( |
| return; |
| const NewWindowInfo& new_window_info = it->second; |
| + printf("Begin RequestNewWindowPermission\n"); |
| + printf("Try new contents\n"); |
| + // Retrieve the opener partition info if we have it. |
| + const GURL& site_url = new_contents->GetSiteInstance()->GetSiteURL(); |
| + std::string storage_partition_id = GetStoragePartitionIdFromSiteURL(site_url); |
| + |
| base::DictionaryValue request_info; |
| request_info.Set(webview::kInitialHeight, |
| base::Value::CreateIntegerValue(initial_bounds.height())); |
| @@ -1366,6 +1395,8 @@ void WebViewGuest::RequestNewWindowPermission( |
| base::Value::CreateStringValue(new_window_info.name)); |
| request_info.Set(webview::kWindowID, |
| base::Value::CreateIntegerValue(guest->guest_instance_id())); |
| + request_info.Set(guestview::kStoragePartitionId, |
|
Fady Samuel
2014/05/29 20:35:23
Comment explaining why we need to send the partiti
lazyboy
2014/05/30 05:48:21
Done.
|
| + base::Value::CreateStringValue(storage_partition_id)); |
| request_info.Set(webview::kWindowOpenDisposition, |
| base::Value::CreateStringValue( |
| WindowOpenDispositionToString(disposition))); |