summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshishir@chromium.org <shishir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 19:11:59 +0000
committershishir@chromium.org <shishir@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 19:11:59 +0000
commit57b9396ce02f494dee0eb42a7eafde525aea1028 (patch)
tree3d0b99609965a76e85d711bb19a6eb727149be56
parentd7b10554d4bbe6d8224be2a14775e1a4b8089d99 (diff)
downloadchromium_src-57b9396ce02f494dee0eb42a7eafde525aea1028.zip
chromium_src-57b9396ce02f494dee0eb42a7eafde525aea1028.tar.gz
chromium_src-57b9396ce02f494dee0eb42a7eafde525aea1028.tar.bz2
Changes for cross domain prerenders to not cancel when there is a window.opener set.
This change will only cancel prerenders with window.opener set where the prerender is in the same domain as the page doing the prerendering. The window.opener case can be broken down into two cases: 1. When the page embedding the "link rel=prerender" does not have an opener set, but the opener is set only for the prerendered page. 2. The embedder page itself has the opener set and the prerendered page inherits it. This CL fixes both cases. BUG=85042 TEST=PrerenderBrowserTest Review URL: http://codereview.chromium.org/7906017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104538 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/prerender/prerender_browsertest.cc74
-rw-r--r--chrome/browser/prerender/prerender_manager.cc10
-rw-r--r--chrome/browser/prerender/prerender_manager.h53
-rw-r--r--chrome/browser/prerender/prerender_manager_unittest.cc11
-rw-r--r--chrome/browser/prerender/prerender_tab_helper.cc11
-rw-r--r--chrome/browser/prerender/prerender_tab_helper.h10
-rw-r--r--content/browser/tab_contents/navigation_controller_unittest.cc2
-rw-r--r--content/browser/tab_contents/tab_contents.cc8
-rw-r--r--content/browser/tab_contents/tab_contents.h4
-rw-r--r--content/browser/tab_contents/tab_contents_observer.cc2
-rw-r--r--content/browser/tab_contents/tab_contents_observer.h2
-rw-r--r--content/common/view_messages.h4
-rw-r--r--content/renderer/render_view.cc13
-rw-r--r--content/renderer/render_view.h3
14 files changed, 139 insertions, 68 deletions
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index 8fd20dc..b8e4434 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/path_service.h"
+#include "base/stringprintf.h"
#include "base/string_util.h"
#include "base/test/test_timeouts.h"
#include "base/utf_string_conversions.h"
@@ -38,6 +39,7 @@
#include "content/common/notification_service.h"
#include "content/common/url_constants.h"
#include "grit/generated_resources.h"
+#include "net/base/mock_host_resolver.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/l10n/l10n_util.h"
@@ -488,35 +490,38 @@ class PrerenderBrowserTest : public InProcessBrowserTest {
}
void OpenDestURLViaClick() const {
- OpenDestURLWithJSImpl("Click()", true);
+ OpenDestURLWithJSImpl("Click()");
}
void OpenDestURLViaClickTarget() const {
- OpenDestURLWithJSImpl("ClickTarget()", false);
+ OpenDestURLWithJSImpl("ClickTarget()");
}
void OpenDestURLViaClickNewWindow() const {
- OpenDestURLWithJSImpl("ShiftClick()", true);
+ OpenDestURLWithJSImpl("ShiftClick()");
}
void OpenDestURLViaClickNewForegroundTab() const {
#if defined(OS_MACOSX)
- OpenDestURLWithJSImpl("MetaShiftClick()", true);
+ OpenDestURLWithJSImpl("MetaShiftClick()");
#else
- OpenDestURLWithJSImpl("CtrlShiftClick()", true);
+ OpenDestURLWithJSImpl("CtrlShiftClick()");
#endif
}
void OpenDestURLViaClickNewBackgroundTab() const {
+ TestPrerenderContents* prerender_contents = GetPrerenderContents();
+ ASSERT_TRUE(prerender_contents != NULL);
+ prerender_contents->set_should_be_shown(false);
#if defined(OS_MACOSX)
- OpenDestURLWithJSImpl("MetaClick()", false);
+ OpenDestURLWithJSImpl("MetaClick()");
#else
- OpenDestURLWithJSImpl("CtrlClick()", false);
+ OpenDestURLWithJSImpl("CtrlClick()");
#endif
}
void OpenDestURLViaWindowOpen() const {
- OpenDestURLWithJSImpl("WindowOpen()", false);
+ OpenDestURLWithJSImpl("WindowOpen()");
}
void ClickToNextPageAfterPrerender(Browser* browser) {
@@ -619,6 +624,17 @@ class PrerenderBrowserTest : public InProcessBrowserTest {
loader_path_ = path;
}
+ GURL GetCrossDomainTestUrl(const std::string& path) {
+ static const std::string secondary_domain = "www.foo.com";
+ host_resolver()->AddRule(secondary_domain, "127.0.0.1");
+ std::string url_str(base::StringPrintf(
+ "http://%s:%d/%s",
+ secondary_domain.c_str(),
+ test_server()->host_port_pair().port(),
+ path.c_str()));
+ return GURL(url_str);
+ }
+
private:
void PrerenderTestURLImpl(
const GURL& url,
@@ -739,13 +755,11 @@ class PrerenderBrowserTest : public InProcessBrowserTest {
// Opens the prerendered page using javascript functions in the
// loader page. |javascript_function_name| should be a 0 argument function
- // which is invoked. |contents_should_be_shown| indicates whether the
- // prerendered page expects to become visible or stay hidden.
- void OpenDestURLWithJSImpl(const std::string& javascript_function_name,
- bool contents_should_be_shown) const {
+ // which is invoked.
+ void OpenDestURLWithJSImpl(const std::string& javascript_function_name)
+ const {
TestPrerenderContents* prerender_contents = GetPrerenderContents();
ASSERT_TRUE(prerender_contents != NULL);
- prerender_contents->set_should_be_shown(contents_should_be_shown);
RenderViewHost* render_view_host =
browser()->GetSelectedTabContents()->render_view_host();
@@ -1497,9 +1511,10 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderPrint) {
1);
}
-// Checks that if a page is opened in a new window by javascript the
-// prerendered page is not used.
-IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowOpenerWindowOpen) {
+// Checks that if a page is opened in a new window by javascript and both the
+// pages are in the same domain, the prerendered page is not used.
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
+ PrerenderSameDomainWindowOpenerWindowOpen) {
PrerenderTestURL("files/prerender/prerender_page.html",
FINAL_STATUS_WINDOW_OPENER,
1);
@@ -1507,14 +1522,37 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowOpenerWindowOpen) {
}
// Checks that if a page is opened due to click on a href with target="_blank"
-// the prerendered page is not used.
-IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderWindowOpenerClickTarget) {
+// and both pages are in the same domain the prerendered page is not used.
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
+ PrerenderSameDomainWindowOpenerClickTarget) {
PrerenderTestURL("files/prerender/prerender_page.html",
FINAL_STATUS_WINDOW_OPENER,
1);
OpenDestURLViaClickTarget();
}
+// Checks that if a page is opened in a new window by javascript and both the
+// pages are in different domains, the prerendered page is used.
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
+ PrerenderCrossDomainWindowOpenerWindowOpen) {
+ PrerenderTestURL(
+ GetCrossDomainTestUrl("files/prerender/prerender_page.html"),
+ FINAL_STATUS_USED,
+ 1);
+ OpenDestURLViaWindowOpen();
+}
+
+// Checks that if a page is opened due to click on a href with target="_blank"
+// and both pages are in different domains, the prerendered page is used.
+IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
+ PrerenderCrossDomainWindowOpenerClickTarget) {
+ PrerenderTestURL(
+ GetCrossDomainTestUrl("files/prerender/prerender_page.html"),
+ FINAL_STATUS_USED,
+ 1);
+ OpenDestURLViaClickTarget();
+}
+
// TODO(shishir): Add a test for the case when the page having the
// prerendering link already has an opener set.
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc
index 5205eb8..f99a5a7 100644
--- a/chrome/browser/prerender/prerender_manager.cc
+++ b/chrome/browser/prerender/prerender_manager.cc
@@ -477,7 +477,7 @@ PrerenderContents* PrerenderManager::GetEntry(const GURL& url) {
bool PrerenderManager::MaybeUsePrerenderedPage(TabContents* tab_contents,
const GURL& url,
- bool has_opener_set) {
+ const GURL& opener_url) {
DCHECK(CalledOnValidThread());
RecordNavigation(url);
@@ -486,9 +486,11 @@ bool PrerenderManager::MaybeUsePrerenderedPage(TabContents* tab_contents,
if (prerender_contents.get() == NULL)
return false;
- // Do not use the prerendered version if the opener window.property was
- // supposed to be set.
- if (has_opener_set) {
+ // Do not use the prerendered version if the opener url corresponding to the
+ // window.opener property has the same origin as the url.
+ // NOTE: This is broken in the cases where the document domain is modified
+ // using the javascript property for "document.domain".
+ if (opener_url.GetOrigin() == url.GetOrigin()) {
prerender_contents.release()->Destroy(FINAL_STATUS_WINDOW_OPENER);
return false;
}
diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h
index 788584d..d907545 100644
--- a/chrome/browser/prerender/prerender_manager.h
+++ b/chrome/browser/prerender/prerender_manager.h
@@ -114,29 +114,18 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// For a given TabContents that wants to navigate to the URL supplied,
// determines whether a prerendered version of the URL can be used,
- // and substitutes the prerendered RVH into the TabContents. Returns
- // whether or not a prerendered RVH could be used or not.
+ // and substitutes the prerendered RVH into the TabContents. |opener_url| is
+ // set to the window.opener url that the TabContents should have set and
+ // will be empty if there is no opener set. Returns whether or not a
+ // prerendered RVH could be used or not.
bool MaybeUsePrerenderedPage(TabContents* tab_contents,
const GURL& url,
- bool has_opener_set);
+ const GURL& opener_url);
// Moves a PrerenderContents to the pending delete list from the list of
// active prerenders when prerendering should be cancelled.
void MoveEntryToPendingDelete(PrerenderContents* entry);
- // Retrieves the PrerenderContents object for the specified URL, if it
- // has been prerendered. The caller will then have ownership of the
- // PrerenderContents object and is responsible for freeing it.
- // Returns NULL if the specified URL has not been prerendered.
- PrerenderContents* GetEntry(const GURL& url);
-
- // Identical to GetEntry, with one exception:
- // The TabContents specified indicates the TC in which to swap the
- // prerendering into. If the TabContents specified is the one
- // to doing the prerendered itself, will return NULL.
- PrerenderContents* GetEntryButNotSpecifiedTC(const GURL& url,
- TabContents* tc);
-
// Records the perceived page load time for a page - effectively the time from
// when the user navigates to a page to when it finishes loading. The actual
// load may have started prior to navigation due to prerender hints.
@@ -217,10 +206,6 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
bool IsPendingEntry(const GURL& url) const;
protected:
- // Test that needs needs access to internal functions.
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, ExpireTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, ExtractURLInQueryStringTest);
-
void SetPrerenderContentsFactory(
PrerenderContents::Factory* prerender_contents_factory);
@@ -235,6 +220,21 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// Test that needs needs access to internal functions.
friend class PrerenderBrowserTest;
+ FRIEND_TEST(PrerenderManagerTest, AliasURLTest);
+ FRIEND_TEST(PrerenderManagerTest, ClearTest);
+ FRIEND_TEST(PrerenderManagerTest, ControlGroup);
+ FRIEND_TEST(PrerenderManagerTest, DropOldestRequestTest);
+ FRIEND_TEST(PrerenderManagerTest, DropSecondRequestTest);
+ FRIEND_TEST(PrerenderManagerTest, ExpireTest);
+ FRIEND_TEST(PrerenderManagerTest, FoundTest);
+ FRIEND_TEST(PrerenderManagerTest, FragmentMatchesFragmentTest);
+ FRIEND_TEST(PrerenderManagerTest, FragmentMatchesPageTest);
+ FRIEND_TEST(PrerenderManagerTest, PageMatchesFragmentTest);
+ FRIEND_TEST(PrerenderManagerTest, PendingPrerenderTest);
+ FRIEND_TEST(PrerenderManagerTest, RateLimitInWindowTest);
+ FRIEND_TEST(PrerenderManagerTest, RateLimitOutsideWindowTest);
+ FRIEND_TEST(PrerenderManagerTest, SourceRenderViewClosed);
+ FRIEND_TEST(PrerenderManagerTest, TwoElementPrerenderTest);
struct PrerenderContentsData;
struct NavigationRecord;
@@ -260,6 +260,19 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
const GURL& url,
const GURL& referrer);
+ // Retrieves the PrerenderContents object for the specified URL, if it
+ // has been prerendered. The caller will then have ownership of the
+ // PrerenderContents object and is responsible for freeing it.
+ // Returns NULL if the specified URL has not been prerendered.
+ PrerenderContents* GetEntry(const GURL& url);
+
+ // Identical to GetEntry, with one exception:
+ // The TabContents specified indicates the TC in which to swap the
+ // prerendering into. If the TabContents specified is the one
+ // to doing the prerendered itself, will return NULL.
+ PrerenderContents* GetEntryButNotSpecifiedTC(const GURL& url,
+ TabContents* tc);
+
// Starts scheduling periodic cleanups.
void StartSchedulingPeriodicCleanups();
// Stops scheduling periodic cleanups if they're no longer needed.
diff --git a/chrome/browser/prerender/prerender_manager_unittest.cc b/chrome/browser/prerender/prerender_manager_unittest.cc
index 105c7b8..e84fed1 100644
--- a/chrome/browser/prerender/prerender_manager_unittest.cc
+++ b/chrome/browser/prerender/prerender_manager_unittest.cc
@@ -206,8 +206,15 @@ class PrerenderManagerTest : public testing::Test {
};
TEST_F(PrerenderManagerTest, EmptyTest) {
- GURL url("http://www.google.com/");
- EXPECT_FALSE(prerender_manager()->MaybeUsePrerenderedPage(NULL, url, false));
+ EXPECT_FALSE(prerender_manager()->MaybeUsePrerenderedPage(
+ NULL,
+ GURL("http://www.google.com/"),
+ GURL()));
+
+ EXPECT_FALSE(prerender_manager()->MaybeUsePrerenderedPage(
+ NULL,
+ GURL("http://www.google.com/search"),
+ GURL("http://www.google.com")));
}
TEST_F(PrerenderManagerTest, FoundTest) {
diff --git a/chrome/browser/prerender/prerender_tab_helper.cc b/chrome/browser/prerender/prerender_tab_helper.cc
index 592d484..feadc3b 100644
--- a/chrome/browser/prerender/prerender_tab_helper.cc
+++ b/chrome/browser/prerender/prerender_tab_helper.cc
@@ -177,8 +177,9 @@ PrerenderTabHelper::PrerenderTabHelper(TabContentsWrapper* tab)
PrerenderTabHelper::~PrerenderTabHelper() {
}
-void PrerenderTabHelper::ProvisionalChangeToMainFrameUrl(const GURL& url,
- bool has_opener_set) {
+void PrerenderTabHelper::ProvisionalChangeToMainFrameUrl(
+ const GURL& url,
+ const GURL& opener_url) {
RecordPageviewEvent(PAGEVIEW_EVENT_NEW_URL);
if (IsTopSite(url))
RecordPageviewEvent(PAGEVIEW_EVENT_TOP_SITE_NEW_URL);
@@ -191,7 +192,7 @@ void PrerenderTabHelper::ProvisionalChangeToMainFrameUrl(const GURL& url,
return;
prerender_manager->MarkTabContentsAsNotPrerendered(tab_contents());
url_ = url;
- MaybeUsePrerenderedPage(url, has_opener_set);
+ MaybeUsePrerenderedPage(url, opener_url);
}
void PrerenderTabHelper::UpdateTargetURL(int32 page_id, const GURL& url) {
@@ -247,14 +248,14 @@ PrerenderManager* PrerenderTabHelper::MaybeGetPrerenderManager() const {
}
bool PrerenderTabHelper::MaybeUsePrerenderedPage(const GURL& url,
- bool has_opener_set) {
+ const GURL& opener_url) {
PrerenderManager* prerender_manager = MaybeGetPrerenderManager();
if (!prerender_manager)
return false;
DCHECK(!prerender_manager->IsTabContentsPrerendering(tab_contents()));
return prerender_manager->MaybeUsePrerenderedPage(tab_contents(),
url,
- has_opener_set);
+ opener_url);
}
bool PrerenderTabHelper::IsPrerendering() {
diff --git a/chrome/browser/prerender/prerender_tab_helper.h b/chrome/browser/prerender/prerender_tab_helper.h
index 92e3aa8..0f184c5 100644
--- a/chrome/browser/prerender/prerender_tab_helper.h
+++ b/chrome/browser/prerender/prerender_tab_helper.h
@@ -25,8 +25,9 @@ class PrerenderTabHelper : public TabContentsObserver {
virtual ~PrerenderTabHelper();
// TabContentsObserver implementation.
- virtual void ProvisionalChangeToMainFrameUrl(const GURL& url,
- bool has_opener_set) OVERRIDE;
+ virtual void ProvisionalChangeToMainFrameUrl(
+ const GURL& url,
+ const GURL& opener_url) OVERRIDE;
virtual void DidStopLoading() OVERRIDE;
virtual void DidStartProvisionalLoadForFrame(
int64 frame_id,
@@ -49,8 +50,9 @@ class PrerenderTabHelper : public TabContentsObserver {
// Checks with the PrerenderManager if the specified URL has been preloaded,
// and if so, swap the RenderViewHost with the preload into this TabContents
- // object.
- bool MaybeUsePrerenderedPage(const GURL& url, bool has_opener_set);
+ // object. |opener_url| denotes the window.opener url that is set for this
+ // tab and is empty if there is no opener set.
+ bool MaybeUsePrerenderedPage(const GURL& url, const GURL& opener_url);
// Returns whether the TabContents being observed is currently prerendering.
bool IsPrerendering();
diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc
index 92685d1..39b6603 100644
--- a/content/browser/tab_contents/navigation_controller_unittest.cc
+++ b/content/browser/tab_contents/navigation_controller_unittest.cc
@@ -469,7 +469,7 @@ TEST_F(NavigationControllerTest, LoadURL_RedirectAbortCancelsPending) {
rvh()->TestOnMessageReceived(
ViewHostMsg_DidRedirectProvisionalLoad(0, // routing_id
-1, // pending page_id
- false, // opener
+ GURL(), // opener
kNewURL, // old url
kRedirectURL)); // new url
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index c5f7725..855956d 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -860,7 +860,7 @@ void TabContents::SetContentRestrictions(int restrictions) {
void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id,
bool is_main_frame,
- bool has_opener_set,
+ const GURL& opener_url,
const GURL& url) {
bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL);
GURL validated_url(url);
@@ -878,12 +878,12 @@ void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id,
if (is_main_frame) {
// Notify observers about the provisional change in the main frame URL.
FOR_EACH_OBSERVER(TabContentsObserver, observers_,
- ProvisionalChangeToMainFrameUrl(url, has_opener_set));
+ ProvisionalChangeToMainFrameUrl(url, opener_url));
}
}
void TabContents::OnDidRedirectProvisionalLoad(int32 page_id,
- bool has_opener_set,
+ const GURL& opener_url,
const GURL& source_url,
const GURL& target_url) {
// TODO(creis): Remove this method and have the pre-rendering code listen to
@@ -900,7 +900,7 @@ void TabContents::OnDidRedirectProvisionalLoad(int32 page_id,
// Notify observers about the provisional change in the main frame URL.
FOR_EACH_OBSERVER(TabContentsObserver, observers_,
ProvisionalChangeToMainFrameUrl(target_url,
- has_opener_set));
+ opener_url));
}
void TabContents::OnDidFailProvisionalLoadWithError(
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index d6465be..9307e63 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -505,10 +505,10 @@ class CONTENT_EXPORT TabContents : public PageNavigator,
// Message handlers.
void OnDidStartProvisionalLoadForFrame(int64 frame_id,
bool main_frame,
- bool has_opener_set,
+ const GURL& opener_url,
const GURL& url);
void OnDidRedirectProvisionalLoad(int32 page_id,
- bool has_opener_set,
+ const GURL& opener_url,
const GURL& source_url,
const GURL& target_url);
void OnDidFailProvisionalLoadWithError(int64 frame_id,
diff --git a/content/browser/tab_contents/tab_contents_observer.cc b/content/browser/tab_contents/tab_contents_observer.cc
index fa5ff3c..f1e71ff 100644
--- a/content/browser/tab_contents/tab_contents_observer.cc
+++ b/content/browser/tab_contents/tab_contents_observer.cc
@@ -36,7 +36,7 @@ void TabContentsObserver::DidStartProvisionalLoadForFrame(
void TabContentsObserver::ProvisionalChangeToMainFrameUrl(
const GURL& url,
- bool has_opener_set) {
+ const GURL& opener_url) {
}
void TabContentsObserver::DidCommitProvisionalLoadForFrame(
diff --git a/content/browser/tab_contents/tab_contents_observer.h b/content/browser/tab_contents/tab_contents_observer.h
index fdc157d..dfb884c 100644
--- a/content/browser/tab_contents/tab_contents_observer.h
+++ b/content/browser/tab_contents/tab_contents_observer.h
@@ -38,7 +38,7 @@ class CONTENT_EXPORT TabContentsObserver : public IPC::Channel::Listener,
bool is_error_page,
RenderViewHost* render_view_host);
virtual void ProvisionalChangeToMainFrameUrl(const GURL& url,
- bool has_opener_set);
+ const GURL& opener_url);
virtual void DidCommitProvisionalLoadForFrame(
int64 frame_id,
bool is_main_frame,
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index 3d439b7c..24be5ef 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -1364,7 +1364,7 @@ IPC_MESSAGE_ROUTED2(ViewHostMsg_DidRunInsecureContent,
IPC_MESSAGE_ROUTED4(ViewHostMsg_DidStartProvisionalLoadForFrame,
int64 /* frame_id */,
bool /* true if it is the main frame */,
- bool /* true if the frame has an opener set */,
+ GURL /* opener url if present, else empty */,
GURL /* url */)
// Sent when the renderer fails a provisional load with an error.
@@ -1720,7 +1720,7 @@ IPC_MESSAGE_CONTROL1(ViewHostMsg_RevealFolderInOS,
// Sent when a provisional load on the main frame redirects.
IPC_MESSAGE_ROUTED4(ViewHostMsg_DidRedirectProvisionalLoad,
int /* page_id */,
- bool /* true if the frame has an opener set */,
+ GURL /* opener url if present, else empty */,
GURL /* last url */,
GURL /* url redirected to */)
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index 0e58757..348c506 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -2311,9 +2311,8 @@ void RenderView::didStartProvisionalLoad(WebFrame* frame) {
FOR_EACH_OBSERVER(
RenderViewObserver, observers_, DidStartProvisionalLoad(frame));
- bool has_opener_set = opener_id_ != MSG_ROUTING_NONE;
Send(new ViewHostMsg_DidStartProvisionalLoadForFrame(
- routing_id_, frame->identifier(), is_top_most, has_opener_set,
+ routing_id_, frame->identifier(), is_top_most, GetOpenerUrl(),
ds->request().url()));
}
@@ -2330,9 +2329,8 @@ void RenderView::didReceiveServerRedirectForProvisionalLoad(WebFrame* frame) {
std::vector<GURL> redirects;
GetRedirectChain(data_source, &redirects);
if (redirects.size() >= 2) {
- bool has_opener_set = opener_id_ != MSG_ROUTING_NONE;
Send(new ViewHostMsg_DidRedirectProvisionalLoad(routing_id_, page_id_,
- has_opener_set, redirects[redirects.size() - 2], redirects.back()));
+ GetOpenerUrl(), redirects[redirects.size() - 2], redirects.back()));
}
}
@@ -3093,6 +3091,13 @@ GURL RenderView::GetAlternateErrorPageURL(const GURL& failed_url,
return url;
}
+GURL RenderView::GetOpenerUrl() const {
+ if (opener_id_ == MSG_ROUTING_NONE || opener_suppressed_)
+ return GURL();
+ else
+ return creator_url_;
+}
+
WebUIBindings* RenderView::GetWebUIBindings() {
if (!web_ui_bindings_.get()) {
web_ui_bindings_.reset(new WebUIBindings(this, routing_id_));
diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h
index b1728b3..37899c0 100644
--- a/content/renderer/render_view.h
+++ b/content/renderer/render_view.h
@@ -904,6 +904,9 @@ class RenderView : public RenderWidget,
// Locates a sub frame with given xpath
WebKit::WebFrame* GetChildFrame(const string16& frame_xpath) const;
+ // Returns the opener url if present, else an empty url.
+ GURL GetOpenerUrl() const;
+
WebUIBindings* GetWebUIBindings();
// Should only be called if this object wraps a PluginDocument.