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

Unified Diff: chrome/browser/external_tab/external_tab_container_win.cc

Issue 9978015: Make browser_handles_top_level_requests synchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ExternalTabContainer::ShouldIgnoreNavigation returns true if is_content_initiated Created 8 years, 8 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/external_tab/external_tab_container_win.cc
diff --git a/chrome/browser/external_tab/external_tab_container_win.cc b/chrome/browser/external_tab/external_tab_container_win.cc
index d76005913fd9cfc9842ff594cf1692403f42506f..59baf75f3ee63f69b12abf9ad61c6a5ecb9c732b 100644
--- a/chrome/browser/external_tab/external_tab_container_win.cc
+++ b/chrome/browser/external_tab/external_tab_container_win.cc
@@ -355,57 +355,28 @@ ExternalTabContainer*
WebContents* ExternalTabContainer::OpenURLFromTab(WebContents* source,
const OpenURLParams& params) {
- if (pending()) {
- pending_open_url_requests_.push_back(params);
- return NULL;
- }
-
- switch (params.disposition) {
- case CURRENT_TAB:
- case SINGLETON_TAB:
- case NEW_FOREGROUND_TAB:
- case NEW_BACKGROUND_TAB:
- case NEW_POPUP:
- case NEW_WINDOW:
- case SAVE_TO_DISK:
- if (automation_) {
- GURL referrer = GURL(WebSecurityPolicy::generateReferrerHeader(
- params.referrer.policy,
- params.url,
- WebString::fromUTF8(params.referrer.url.spec())).utf8());
- automation_->Send(new AutomationMsg_OpenURL(tab_handle_,
- params.url,
- referrer,
- params.disposition));
- // TODO(ananta)
- // We should populate other fields in the
- // ViewHostMsg_FrameNavigate_Params structure. Another option could be
- // to refactor the UpdateHistoryForNavigation function in TabContents.
- content::FrameNavigateParams nav_params;
- nav_params.referrer = content::Referrer(referrer,
- params.referrer.policy);
- nav_params.url = params.url;
- nav_params.page_id = -1;
- nav_params.transition = content::PAGE_TRANSITION_LINK;
-
- content::LoadCommittedDetails details;
- details.did_replace_entry = false;
-
- scoped_refptr<history::HistoryAddPageArgs> add_page_args(
- tab_contents_->history_tab_helper()->
- CreateHistoryAddPageArgs(params.url, details, nav_params));
- tab_contents_->history_tab_helper()->
- UpdateHistoryForNavigation(add_page_args);
+ GURL referrer_url = GURL(WebSecurityPolicy::generateReferrerHeader(
+ params.referrer.policy,
+ params.url,
+ WebString::fromUTF8(params.referrer.url.spec())).utf8());
+ content::Referrer referrer = content::Referrer(referrer_url,
+ params.referrer.policy);
+ return OpenUrlInExtenalHost(source, params.url, params.disposition, referrer);
+}
- return tab_contents_->web_contents();
- }
- break;
- default:
- NOTREACHED();
- break;
+bool ExternalTabContainer::ShouldIgnoreNavigation(
+ WebContents* source,
+ const GURL& url,
+ const content::Referrer& referrer,
+ WindowOpenDisposition disposition,
+ bool is_content_initiated,
+ content::PageTransition transition_type) {
+
+ if (is_content_initiated) {
+ OpenUrlInExtenalHost(source, url, disposition, referrer);
+ return true;
}
-
- return NULL;
+ return false;
}
void ExternalTabContainer::NavigationStateChanged(const WebContents* source,
@@ -1150,8 +1121,10 @@ void ExternalTabContainer::ServicePendingOpenURLRequests() {
for (size_t index = 0; index < pending_open_url_requests_.size();
++index) {
- const OpenURLParams& url_request = pending_open_url_requests_[index];
- OpenURLFromTab(web_contents(), url_request);
+ const PendingOpenUrlRequest& url_request =
+ pending_open_url_requests_[index];
+ OpenUrlInExtenalHost(web_contents(), url_request.url,
+ url_request.disposition, url_request.referrer);
}
pending_open_url_requests_.clear();
}
@@ -1189,6 +1162,64 @@ void ExternalTabContainer::SetupExternalTabView() {
tab_contents_container_->ChangeWebContents(web_contents());
}
+content::WebContents* ExternalTabContainer::OpenUrlInExtenalHost(
+ content::WebContents* source,
+ const GURL& url,
+ WindowOpenDisposition disposition,
+ const content::Referrer& referrer) {
+
+ if (pending()) {
+ PendingOpenUrlRequest pending_request;
+ pending_request.url = url;
+ pending_request.disposition = disposition;
+ pending_request.referrer = referrer;
+ pending_open_url_requests_.push_back(pending_request);
+ return NULL;
+ }
+
+ switch (disposition) {
+ case CURRENT_TAB:
+ case SINGLETON_TAB:
+ case NEW_FOREGROUND_TAB:
+ case NEW_BACKGROUND_TAB:
+ case NEW_POPUP:
+ case NEW_WINDOW:
+ case SAVE_TO_DISK:
+ if (automation_) {
+ automation_->Send(new AutomationMsg_OpenURL(tab_handle_,
+ url,
+ referrer.url,
+ disposition));
+ // TODO(ananta)
+ // We should populate other fields in the
+ // ViewHostMsg_FrameNavigate_Params structure. Another option could be
+ // to refactor the UpdateHistoryForNavigation function in TabContents.
+ content::FrameNavigateParams nav_params;
+ nav_params.referrer = referrer;
+ nav_params.url = url;
+ nav_params.page_id = -1;
+ nav_params.transition = content::PAGE_TRANSITION_LINK;
+
+ content::LoadCommittedDetails details;
+ details.did_replace_entry = false;
+
+ scoped_refptr<history::HistoryAddPageArgs> add_page_args(
+ tab_contents_->history_tab_helper()->
+ CreateHistoryAddPageArgs(url, details, nav_params));
+ tab_contents_->history_tab_helper()->
+ UpdateHistoryForNavigation(add_page_args);
+
+ return tab_contents_->web_contents();
+ }
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+
+ return NULL;
+}
+
TemporaryPopupExternalTabContainer::TemporaryPopupExternalTabContainer(
AutomationProvider* automation,
AutomationResourceMessageFilter* filter)

Powered by Google App Engine
This is Rietveld 408576698