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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 20924002: Try to restore window.opener when opening blocked popups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sessionStorage+opener Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 it != session_storage_namespace_map.end(); 280 it != session_storage_namespace_map.end();
281 ++it) { 281 ++it) {
282 new_contents->GetController() 282 new_contents->GetController()
283 .SetSessionStorageNamespace(it->first, it->second.get()); 283 .SetSessionStorageNamespace(it->first, it->second.get());
284 } 284 }
285 285
286 new_contents->Init(params); 286 new_contents->Init(params);
287 return new_contents; 287 return new_contents;
288 } 288 }
289 289
290 // static
291 WebContents* WebContents::CreateWithOpener(
292 const WebContents::CreateParams& params,
293 WebContents* opener,
294 bool propagate_opener) {
Charlie Reis 2013/07/30 01:26:30 Why switch from suppress_opener, which is used com
295 WebContentsImpl* new_contents = new WebContentsImpl(
296 params.browser_context,
297 propagate_opener ? static_cast<WebContentsImpl*>(opener) : NULL);
298
299 if (opener) {
300 // To clone the session storage namespace, we need a site instance.
301 CHECK(params.site_instance);
Bernhard Bauer 2013/07/30 08:34:50 I assume you have good reasons for using a CHECK o
302
303 // It's not possible to use a guest as opener.
Charlie Reis 2013/07/30 01:26:30 That's not true. Fady changed WebContentsImpl::Cr
304 CHECK(!opener->GetRenderProcessHost()->IsGuest());
305
306 // Clone the session storage namespace of the opener.
Charlie Reis 2013/07/30 01:26:30 This code only copies the session storage namespac
jochen (gone - plz use gerrit) 2013/07/30 14:50:39 No. it clones it (see line 320).
Charlie Reis 2013/07/31 17:16:16 You're only cloning a single SessionStorageNamespa
307 const std::string& partition_id =
308 GetContentClient()->browser()->
Bernhard Bauer 2013/07/30 08:34:50 Nit: This needs to be indented four spaces more.
309 GetStoragePartitionIdForSite(opener->GetBrowserContext(),
310 params.site_instance->GetSiteURL());
311 StoragePartition* partition = BrowserContext::GetStoragePartition(
312 opener->GetBrowserContext(), params.site_instance);
313 DOMStorageContextImpl* dom_storage_context =
314 static_cast<DOMStorageContextImpl*>(partition->GetDOMStorageContext());
315 SessionStorageNamespaceMap::const_iterator old_namespace = opener
316 ->GetController().GetSessionStorageNamespaceMap().find(partition_id);
Charlie Reis 2013/07/30 01:26:30 nit: Please be consistent about -> being at the en
317 CHECK(old_namespace !=
318 opener->GetController().GetSessionStorageNamespaceMap().end());
Bernhard Bauer 2013/07/30 08:34:50 If the partition ID isn't found, you'll crash late
319 scoped_refptr<SessionStorageNamespaceImpl> cloned_namespace =
320 new SessionStorageNamespaceImpl(dom_storage_context,
321 old_namespace->second->id());
322 new_contents->GetController()
323 .SetSessionStorageNamespace(partition_id, cloned_namespace.get());
324 }
325
326 new_contents->Init(params);
327 return new_contents;
328 }
329
290 void WebContents::AddCreatedCallback(const CreatedCallback& callback) { 330 void WebContents::AddCreatedCallback(const CreatedCallback& callback) {
291 g_created_callbacks.Get().push_back(callback); 331 g_created_callbacks.Get().push_back(callback);
292 } 332 }
293 333
294 void WebContents::RemoveCreatedCallback(const CreatedCallback& callback) { 334 void WebContents::RemoveCreatedCallback(const CreatedCallback& callback) {
295 for (size_t i = 0; i < g_created_callbacks.Get().size(); ++i) { 335 for (size_t i = 0; i < g_created_callbacks.Get().size(); ++i) {
296 if (g_created_callbacks.Get().at(i).Equals(callback)) { 336 if (g_created_callbacks.Get().at(i).Equals(callback)) {
297 g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i); 337 g_created_callbacks.Get().erase(g_created_callbacks.Get().begin() + i);
298 return; 338 return;
299 } 339 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 FOR_EACH_OBSERVER(WebContentsObserver, 442 FOR_EACH_OBSERVER(WebContentsObserver,
403 observers_, 443 observers_,
404 WebContentsImplDestroyed()); 444 WebContentsImplDestroyed());
405 445
406 SetDelegate(NULL); 446 SetDelegate(NULL);
407 447
408 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), 448 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(),
409 destruction_observers_.end()); 449 destruction_observers_.end());
410 } 450 }
411 451
412 WebContentsImpl* WebContentsImpl::CreateWithOpener( 452 WebContentsImpl* WebContentsImpl::CreateWithOpener(
Charlie Reis 2013/07/30 01:26:30 I'm finding it confusing that we have two differen
413 const WebContents::CreateParams& params, 453 const WebContents::CreateParams& params,
414 WebContentsImpl* opener) { 454 WebContentsImpl* opener) {
415 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); 455 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener");
416 WebContentsImpl* new_contents = new WebContentsImpl( 456 WebContentsImpl* new_contents = new WebContentsImpl(
417 params.browser_context, opener); 457 params.browser_context, opener);
418 458
419 new_contents->Init(params); 459 new_contents->Init(params);
420 return new_contents; 460 return new_contents;
421 } 461 }
422 462
(...skipping 3305 matching lines...) Expand 10 before | Expand all | Expand 10 after
3728 } 3768 }
3729 3769
3730 void WebContentsImpl::ClearAllPowerSaveBlockers() { 3770 void WebContentsImpl::ClearAllPowerSaveBlockers() {
3731 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin()); 3771 for (PowerSaveBlockerMap::iterator i(power_save_blockers_.begin());
3732 i != power_save_blockers_.end(); ++i) 3772 i != power_save_blockers_.end(); ++i)
3733 STLDeleteValues(&power_save_blockers_[i->first]); 3773 STLDeleteValues(&power_save_blockers_[i->first]);
3734 power_save_blockers_.clear(); 3774 power_save_blockers_.clear();
3735 } 3775 }
3736 3776
3737 } // namespace content 3777 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698