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

Side by Side 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: external_tab_container_feedback 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 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 "chrome/browser/external_tab/external_tab_container_win.h" 5 #include "chrome/browser/external_tab/external_tab_container_win.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 tab_container = reinterpret_cast<ExternalTabContainer*>( 348 tab_container = reinterpret_cast<ExternalTabContainer*>(
349 ViewProp::GetValue(native_window, kWindowObjectKey)); 349 ViewProp::GetValue(native_window, kWindowObjectKey));
350 } 350 }
351 return tab_container; 351 return tab_container;
352 } 352 }
353 //////////////////////////////////////////////////////////////////////////////// 353 ////////////////////////////////////////////////////////////////////////////////
354 // ExternalTabContainer, content::WebContentsDelegate implementation: 354 // ExternalTabContainer, content::WebContentsDelegate implementation:
355 355
356 WebContents* ExternalTabContainer::OpenURLFromTab(WebContents* source, 356 WebContents* ExternalTabContainer::OpenURLFromTab(WebContents* source,
357 const OpenURLParams& params) { 357 const OpenURLParams& params) {
358 if (pending()) { 358 GURL referrer_url = GURL(WebSecurityPolicy::generateReferrerHeader(
359 pending_open_url_requests_.push_back(params); 359 params.referrer.policy,
360 return NULL; 360 params.url,
361 WebString::fromUTF8(params.referrer.url.spec())).utf8());
362 content::Referrer referrer = content::Referrer(referrer_url,
363 params.referrer.policy);
364 return OpenUrlInExtenalHost(source, params.url, params.disposition, referrer);
365 }
366
367 bool ExternalTabContainer::ShouldIgnoreNavigation(
368 WebContents* source,
369 const GURL& url,
370 const content::Referrer& referrer,
371 WindowOpenDisposition disposition,
372 bool is_content_initiated,
373 content::PageTransition transition_type) {
374
375 if (is_content_initiated) {
376 return (NULL == OpenUrlInExtenalHost(source, url, disposition, referrer));
ananta 2012/04/11 23:08:05 The OpenUrlInExtenalHost function will return NULL
mkosiba (inactive) 2012/04/12 10:12:52 Done.
361 } 377 }
362 378 return false;
363 switch (params.disposition) {
364 case CURRENT_TAB:
365 case SINGLETON_TAB:
366 case NEW_FOREGROUND_TAB:
367 case NEW_BACKGROUND_TAB:
368 case NEW_POPUP:
369 case NEW_WINDOW:
370 case SAVE_TO_DISK:
371 if (automation_) {
372 GURL referrer = GURL(WebSecurityPolicy::generateReferrerHeader(
373 params.referrer.policy,
374 params.url,
375 WebString::fromUTF8(params.referrer.url.spec())).utf8());
376 automation_->Send(new AutomationMsg_OpenURL(tab_handle_,
377 params.url,
378 referrer,
379 params.disposition));
380 // TODO(ananta)
381 // We should populate other fields in the
382 // ViewHostMsg_FrameNavigate_Params structure. Another option could be
383 // to refactor the UpdateHistoryForNavigation function in TabContents.
384 content::FrameNavigateParams nav_params;
385 nav_params.referrer = content::Referrer(referrer,
386 params.referrer.policy);
387 nav_params.url = params.url;
388 nav_params.page_id = -1;
389 nav_params.transition = content::PAGE_TRANSITION_LINK;
390
391 content::LoadCommittedDetails details;
392 details.did_replace_entry = false;
393
394 scoped_refptr<history::HistoryAddPageArgs> add_page_args(
395 tab_contents_->history_tab_helper()->
396 CreateHistoryAddPageArgs(params.url, details, nav_params));
397 tab_contents_->history_tab_helper()->
398 UpdateHistoryForNavigation(add_page_args);
399
400 return tab_contents_->web_contents();
401 }
402 break;
403 default:
404 NOTREACHED();
405 break;
406 }
407
408 return NULL;
409 } 379 }
410 380
411 void ExternalTabContainer::NavigationStateChanged(const WebContents* source, 381 void ExternalTabContainer::NavigationStateChanged(const WebContents* source,
412 unsigned changed_flags) { 382 unsigned changed_flags) {
413 if (automation_) { 383 if (automation_) {
414 NavigationInfo nav_info; 384 NavigationInfo nav_info;
415 if (InitNavigationInfo(&nav_info, content::NAVIGATION_TYPE_NAV_IGNORE, 0)) 385 if (InitNavigationInfo(&nav_info, content::NAVIGATION_TYPE_NAV_IGNORE, 0))
416 automation_->Send(new AutomationMsg_NavigationStateChanged( 386 automation_->Send(new AutomationMsg_NavigationStateChanged(
417 tab_handle_, changed_flags, nav_info)); 387 tab_handle_, changed_flags, nav_info));
418 } 388 }
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 ServicePendingOpenURLRequests(); 1113 ServicePendingOpenURLRequests();
1144 } 1114 }
1145 1115
1146 void ExternalTabContainer::ServicePendingOpenURLRequests() { 1116 void ExternalTabContainer::ServicePendingOpenURLRequests() {
1147 DCHECK(pending()); 1117 DCHECK(pending());
1148 1118
1149 set_pending(false); 1119 set_pending(false);
1150 1120
1151 for (size_t index = 0; index < pending_open_url_requests_.size(); 1121 for (size_t index = 0; index < pending_open_url_requests_.size();
1152 ++index) { 1122 ++index) {
1153 const OpenURLParams& url_request = pending_open_url_requests_[index]; 1123 const PendingOpenUrlRequest& url_request =
1154 OpenURLFromTab(web_contents(), url_request); 1124 pending_open_url_requests_[index];
1125 OpenUrlInExtenalHost(web_contents(), url_request.url,
1126 url_request.disposition, url_request.referrer);
1155 } 1127 }
1156 pending_open_url_requests_.clear(); 1128 pending_open_url_requests_.clear();
1157 } 1129 }
1158 1130
1159 void ExternalTabContainer::SetupExternalTabView() { 1131 void ExternalTabContainer::SetupExternalTabView() {
1160 // Create a TabContentsContainer to handle focus cycling using Tab and 1132 // Create a TabContentsContainer to handle focus cycling using Tab and
1161 // Shift-Tab. 1133 // Shift-Tab.
1162 tab_contents_container_ = new TabContentsContainer; 1134 tab_contents_container_ = new TabContentsContainer;
1163 1135
1164 // The views created here will be destroyed when the ExternalTabContainer 1136 // The views created here will be destroyed when the ExternalTabContainer
(...skipping 17 matching lines...) Expand all
1182 1154
1183 layout->StartRow(0, 0); 1155 layout->StartRow(0, 0);
1184 layout->AddView(info_bar_container); 1156 layout->AddView(info_bar_container);
1185 layout->StartRow(1, 0); 1157 layout->StartRow(1, 0);
1186 layout->AddView(tab_contents_container_); 1158 layout->AddView(tab_contents_container_);
1187 GetWidget()->SetContentsView(external_tab_view_); 1159 GetWidget()->SetContentsView(external_tab_view_);
1188 // Note that SetTabContents must be called after AddChildView is called 1160 // Note that SetTabContents must be called after AddChildView is called
1189 tab_contents_container_->ChangeWebContents(web_contents()); 1161 tab_contents_container_->ChangeWebContents(web_contents());
1190 } 1162 }
1191 1163
1164 content::WebContents* ExternalTabContainer::OpenUrlInExtenalHost(
1165 content::WebContents* source,
1166 const GURL& url,
1167 WindowOpenDisposition disposition,
1168 const content::Referrer& referrer) {
1169
1170 if (pending()) {
1171 PendingOpenUrlRequest pending_request;
1172 pending_request.url = url;
1173 pending_request.disposition = disposition;
1174 pending_request.referrer = referrer;
1175 pending_open_url_requests_.push_back(pending_request);
1176 return NULL;
1177 }
1178
1179 switch (disposition) {
1180 case CURRENT_TAB:
1181 case SINGLETON_TAB:
1182 case NEW_FOREGROUND_TAB:
1183 case NEW_BACKGROUND_TAB:
1184 case NEW_POPUP:
1185 case NEW_WINDOW:
1186 case SAVE_TO_DISK:
1187 if (automation_) {
1188 automation_->Send(new AutomationMsg_OpenURL(tab_handle_,
1189 url,
1190 referrer.url,
1191 disposition));
1192 // TODO(ananta)
1193 // We should populate other fields in the
1194 // ViewHostMsg_FrameNavigate_Params structure. Another option could be
1195 // to refactor the UpdateHistoryForNavigation function in TabContents.
1196 content::FrameNavigateParams nav_params;
1197 nav_params.referrer = referrer;
1198 nav_params.url = url;
1199 nav_params.page_id = -1;
1200 nav_params.transition = content::PAGE_TRANSITION_LINK;
1201
1202 content::LoadCommittedDetails details;
1203 details.did_replace_entry = false;
1204
1205 scoped_refptr<history::HistoryAddPageArgs> add_page_args(
1206 tab_contents_->history_tab_helper()->
1207 CreateHistoryAddPageArgs(url, details, nav_params));
1208 tab_contents_->history_tab_helper()->
1209 UpdateHistoryForNavigation(add_page_args);
1210
1211 return tab_contents_->web_contents();
1212 }
1213 break;
1214 default:
1215 NOTREACHED();
1216 break;
1217 }
1218
1219 return NULL;
1220 }
1221
1192 TemporaryPopupExternalTabContainer::TemporaryPopupExternalTabContainer( 1222 TemporaryPopupExternalTabContainer::TemporaryPopupExternalTabContainer(
1193 AutomationProvider* automation, 1223 AutomationProvider* automation,
1194 AutomationResourceMessageFilter* filter) 1224 AutomationResourceMessageFilter* filter)
1195 : ExternalTabContainer(automation, filter) { 1225 : ExternalTabContainer(automation, filter) {
1196 } 1226 }
1197 1227
1198 TemporaryPopupExternalTabContainer::~TemporaryPopupExternalTabContainer() { 1228 TemporaryPopupExternalTabContainer::~TemporaryPopupExternalTabContainer() {
1199 DVLOG(1) << __FUNCTION__; 1229 DVLOG(1) << __FUNCTION__;
1200 } 1230 }
1201 1231
1202 WebContents* TemporaryPopupExternalTabContainer::OpenURLFromTab( 1232 WebContents* TemporaryPopupExternalTabContainer::OpenURLFromTab(
1203 WebContents* source, 1233 WebContents* source,
1204 const OpenURLParams& params) { 1234 const OpenURLParams& params) {
1205 if (!automation_) 1235 if (!automation_)
1206 return NULL; 1236 return NULL;
1207 1237
1208 OpenURLParams forward_params = params; 1238 OpenURLParams forward_params = params;
1209 if (params.disposition == CURRENT_TAB) { 1239 if (params.disposition == CURRENT_TAB) {
1210 DCHECK(route_all_top_level_navigations_); 1240 DCHECK(route_all_top_level_navigations_);
1211 forward_params.disposition = NEW_FOREGROUND_TAB; 1241 forward_params.disposition = NEW_FOREGROUND_TAB;
1212 } 1242 }
1213 WebContents* new_contents = 1243 WebContents* new_contents =
1214 ExternalTabContainer::OpenURLFromTab(source, forward_params); 1244 ExternalTabContainer::OpenURLFromTab(source, forward_params);
1215 // support only one navigation for a dummy tab before it is killed. 1245 // support only one navigation for a dummy tab before it is killed.
1216 ::DestroyWindow(GetNativeView()); 1246 ::DestroyWindow(GetNativeView());
1217 return new_contents; 1247 return new_contents;
1218 } 1248 }
OLDNEW
« no previous file with comments | « chrome/browser/external_tab/external_tab_container_win.h ('k') | content/browser/renderer_host/render_view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698