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 9f9ea466b834bb7667ae8d76cd3b6dcf6b5638ab..6b557a82afd841083f033a25e2d037bd58acf6c5 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); |
| @@ -374,7 +388,15 @@ void WebViewGuest::Close() { |
| 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. |
| @@ -498,20 +520,20 @@ WebViewGuest* WebViewGuest::CreateNewGuestWindow( |
| // Allocate a new instance ID for the new guest. |
| int instance_id = guest_manager->GetNextInstanceID(); |
| + // TODO(lazyboy): This codepath doesn't seem to tested by our tests. |
|
Fady Samuel
2014/05/27 14:19:06
This code comes from middle click or ctrl+click. I
lazyboy
2014/05/27 20:43:00
Ya you're right, WebViewInteractiveTest.NewWindow_
|
| // Set the attach params to use the same partition as the opener. |
| // 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); |
| @@ -788,6 +810,7 @@ bool WebViewGuest::ClearData(const base::Time remove_since, |
| } |
| WebViewGuest::~WebViewGuest() { |
| + printf("++++ %s\n", __PRETTY_FUNCTION__); |
| } |
| void WebViewGuest::DidCommitProvisionalLoadForFrame( |
| @@ -1235,6 +1258,7 @@ WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { |
| void WebViewGuest::ShowContextMenu(int request_id, |
| const MenuItemVector* items) { |
| + printf("++++ %s\n", __PRETTY_FUNCTION__); |
| if (!pending_menu_.get()) |
| return; |
| @@ -1349,6 +1373,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())); |
| @@ -1360,6 +1390,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, |
| + base::Value::CreateStringValue(storage_partition_id)); |
| request_info.Set(webview::kWindowOpenDisposition, |
| base::Value::CreateStringValue( |
| WindowOpenDispositionToString(disposition))); |