Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1780)

Unified Diff: chrome/browser/guest_view/web_view/web_view_guest.cc

Issue 299753011: Move allocate instance id to chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from fady Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 ae77819af6cd586d019476d25239da264f4e87cd..5718bdce73c01a307f1419d58f976806c0bce70d 100644
--- a/chrome/browser/guest_view/web_view/web_view_guest.cc
+++ b/chrome/browser/guest_view/web_view/web_view_guest.cc
@@ -139,6 +139,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,
@@ -188,6 +200,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));
@@ -336,6 +349,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);
@@ -375,7 +389,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");
Fady Samuel 2014/06/03 16:36:34 Is this even possible? I want to say this is inval
lazyboy 2014/06/03 19:17:58 I see this on newwindow API test, e.window.attach(
+ }
+
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.
@@ -494,16 +516,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);
@@ -780,6 +801,7 @@ bool WebViewGuest::ClearData(const base::Time remove_since,
}
WebViewGuest::~WebViewGuest() {
+ printf("++++ %s\n", __PRETTY_FUNCTION__);
}
void WebViewGuest::DidCommitProvisionalLoadForFrame(
@@ -1240,6 +1262,7 @@ WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() {
void WebViewGuest::ShowContextMenu(int request_id,
const MenuItemVector* items) {
+ printf("++++ %s\n", __PRETTY_FUNCTION__);
if (!pending_menu_.get())
return;
@@ -1354,6 +1377,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()));
@@ -1365,6 +1394,10 @@ void WebViewGuest::RequestNewWindowPermission(
base::Value::CreateStringValue(new_window_info.name));
request_info.Set(webview::kWindowID,
base::Value::CreateIntegerValue(guest->guest_instance_id()));
+ // We pass in partition info so that window-s created through newwindow
+ // API can use it to set their partition attribute.
+ request_info.Set(guestview::kStoragePartitionId,
+ base::Value::CreateStringValue(storage_partition_id));
request_info.Set(webview::kWindowOpenDisposition,
base::Value::CreateStringValue(
WindowOpenDispositionToString(disposition)));

Powered by Google App Engine
This is Rietveld 408576698