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

Side by Side Diff: chrome/browser/ui/views/external_tab_container_win.cc

Issue 10868116: Pass result of blockage across content API when new tab blocked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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/ui/views/external_tab_container_win.h" 5 #include "chrome/browser/ui/views/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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 void ExternalTabContainerWin::NavigationStateChanged(const WebContents* source, 454 void ExternalTabContainerWin::NavigationStateChanged(const WebContents* source,
455 unsigned changed_flags) { 455 unsigned changed_flags) {
456 if (automation_) { 456 if (automation_) {
457 NavigationInfo nav_info; 457 NavigationInfo nav_info;
458 if (InitNavigationInfo(&nav_info, content::NAVIGATION_TYPE_NAV_IGNORE, 0)) 458 if (InitNavigationInfo(&nav_info, content::NAVIGATION_TYPE_NAV_IGNORE, 0))
459 automation_->Send(new AutomationMsg_NavigationStateChanged( 459 automation_->Send(new AutomationMsg_NavigationStateChanged(
460 tab_handle_, changed_flags, nav_info)); 460 tab_handle_, changed_flags, nav_info));
461 } 461 }
462 } 462 }
463 463
464 void ExternalTabContainerWin::AddNewContents(WebContents* source, 464 bool ExternalTabContainerWin::AddNewContents(WebContents* source,
465 WebContents* new_contents, 465 WebContents* new_contents,
466 WindowOpenDisposition disposition, 466 WindowOpenDisposition disposition,
467 const gfx::Rect& initial_pos, 467 const gfx::Rect& initial_pos,
468 bool user_gesture) { 468 bool user_gesture) {
469 if (!automation_) { 469 if (!automation_) {
470 DCHECK(pending_); 470 DCHECK(pending_);
471 LOG(ERROR) << "Invalid automation provider. Dropping new contents notify"; 471 LOG(ERROR) << "Invalid automation provider. Dropping new contents notify";
472 delete new_contents; 472 delete new_contents;
473 return; 473 return true;
474 } 474 }
475 475
476 scoped_refptr<ExternalTabContainerWin> new_container; 476 scoped_refptr<ExternalTabContainerWin> new_container;
477 // If the host is a browser like IE8, then the URL being navigated to in the 477 // If the host is a browser like IE8, then the URL being navigated to in the
478 // new tab contents could potentially navigate back to Chrome from a new 478 // new tab contents could potentially navigate back to Chrome from a new
479 // IE process. We support full tab mode only for IE and hence we use that as 479 // IE process. We support full tab mode only for IE and hence we use that as
480 // a determining factor in whether the new ExternalTabContainer instance is 480 // a determining factor in whether the new ExternalTabContainer instance is
481 // created as pending or not. 481 // created as pending or not.
482 if (!route_all_top_level_navigations_) { 482 if (!route_all_top_level_navigations_) {
483 new_container = new ExternalTabContainerWin(NULL, NULL); 483 new_container = new ExternalTabContainerWin(NULL, NULL);
(...skipping 20 matching lines...) Expand all
504 tab_contents.get(), 504 tab_contents.get(),
505 GURL(), 505 GURL(),
506 GURL(), 506 GURL(),
507 true, 507 true,
508 route_all_top_level_navigations_); 508 route_all_top_level_navigations_);
509 509
510 if (result) { 510 if (result) {
511 Profile* profile = tab_contents->profile(); 511 Profile* profile = tab_contents->profile();
512 tab_contents.release(); // Ownership has been transferred. 512 tab_contents.release(); // Ownership has been transferred.
513 if (route_all_top_level_navigations_) { 513 if (route_all_top_level_navigations_) {
514 return; 514 return true;
515 } 515 }
516 uintptr_t cookie = reinterpret_cast<uintptr_t>(new_container.get()); 516 uintptr_t cookie = reinterpret_cast<uintptr_t>(new_container.get());
517 pending_tabs_.Get()[cookie] = new_container; 517 pending_tabs_.Get()[cookie] = new_container;
518 new_container->set_pending(true); 518 new_container->set_pending(true);
519 new_container->set_is_popup_window(disposition == NEW_POPUP); 519 new_container->set_is_popup_window(disposition == NEW_POPUP);
520 AttachExternalTabParams attach_params_; 520 AttachExternalTabParams attach_params_;
521 attach_params_.cookie = static_cast<uint64>(cookie); 521 attach_params_.cookie = static_cast<uint64>(cookie);
522 attach_params_.dimensions = initial_pos; 522 attach_params_.dimensions = initial_pos;
523 attach_params_.user_gesture = user_gesture; 523 attach_params_.user_gesture = user_gesture;
524 attach_params_.disposition = disposition; 524 attach_params_.disposition = disposition;
525 attach_params_.profile_name = WideToUTF8( 525 attach_params_.profile_name = WideToUTF8(
526 profile->GetPath().DirName().BaseName().value()); 526 profile->GetPath().DirName().BaseName().value());
527 automation_->Send(new AutomationMsg_AttachExternalTab( 527 automation_->Send(new AutomationMsg_AttachExternalTab(
528 tab_handle_, attach_params_)); 528 tab_handle_, attach_params_));
529 } else { 529 } else {
530 NOTREACHED(); 530 NOTREACHED();
531 } 531 }
532 return true;
532 } 533 }
533 534
534 void ExternalTabContainerWin::WebContentsCreated(WebContents* source_contents, 535 bool ExternalTabContainerWin::WebContentsCreated(WebContents* source_contents,
535 int64 source_frame_id, 536 int64 source_frame_id,
536 const GURL& target_url, 537 const GURL& target_url,
537 WebContents* new_contents) { 538 WebContents* new_contents) {
538 if (!load_requests_via_automation_) 539 if (!load_requests_via_automation_)
539 return; 540 return false;
jam 2012/09/04 19:50:46 can you explain this? I'm not sure I understand wh
Tom Sepez 2012/09/04 20:46:16 Not sure there's any upside to returning false her
540 541
541 RenderViewHost* rvh = new_contents->GetRenderViewHost(); 542 RenderViewHost* rvh = new_contents->GetRenderViewHost();
542 DCHECK(rvh != NULL); 543 DCHECK(rvh != NULL);
543 544
544 // Register this render view as a pending render view, i.e. any network 545 // Register this render view as a pending render view, i.e. any network
545 // requests initiated by this render view would be serviced when the 546 // requests initiated by this render view would be serviced when the
546 // external host connects to the new external tab instance. 547 // external host connects to the new external tab instance.
547 RegisterRenderViewHostForAutomation(rvh, true); 548 RegisterRenderViewHostForAutomation(rvh, true);
549 return true;
548 } 550 }
549 551
550 void ExternalTabContainerWin::CloseContents(content::WebContents* source) { 552 void ExternalTabContainerWin::CloseContents(content::WebContents* source) {
551 if (!automation_) 553 if (!automation_)
552 return; 554 return;
553 555
554 if (unload_reply_message_) { 556 if (unload_reply_message_) {
555 AutomationMsg_RunUnloadHandlers::WriteReplyParams(unload_reply_message_, 557 AutomationMsg_RunUnloadHandlers::WriteReplyParams(unload_reply_message_,
556 true); 558 true);
557 automation_->Send(unload_reply_message_); 559 automation_->Send(unload_reply_message_);
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 if (params.disposition == CURRENT_TAB) { 1264 if (params.disposition == CURRENT_TAB) {
1263 DCHECK(route_all_top_level_navigations_); 1265 DCHECK(route_all_top_level_navigations_);
1264 forward_params.disposition = NEW_FOREGROUND_TAB; 1266 forward_params.disposition = NEW_FOREGROUND_TAB;
1265 } 1267 }
1266 WebContents* new_contents = 1268 WebContents* new_contents =
1267 ExternalTabContainerWin::OpenURLFromTab(source, forward_params); 1269 ExternalTabContainerWin::OpenURLFromTab(source, forward_params);
1268 // support only one navigation for a dummy tab before it is killed. 1270 // support only one navigation for a dummy tab before it is killed.
1269 ::DestroyWindow(GetNativeView()); 1271 ::DestroyWindow(GetNativeView());
1270 return new_contents; 1272 return new_contents;
1271 } 1273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698