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

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

Issue 3549006: Top level navigations are not sent to the host browser in the ChromeFrame NPA... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_container_win.h" 5 #include "chrome/browser/external_tab_container_win.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ignore_next_load_notification_(false), 54 ignore_next_load_notification_(false),
55 automation_resource_message_filter_(filter), 55 automation_resource_message_filter_(filter),
56 load_requests_via_automation_(false), 56 load_requests_via_automation_(false),
57 handle_top_level_requests_(false), 57 handle_top_level_requests_(false),
58 external_method_factory_(this), 58 external_method_factory_(this),
59 enabled_extension_automation_(false), 59 enabled_extension_automation_(false),
60 pending_(false), 60 pending_(false),
61 infobars_enabled_(true), 61 infobars_enabled_(true),
62 focus_manager_(NULL), 62 focus_manager_(NULL),
63 external_tab_view_(NULL), 63 external_tab_view_(NULL),
64 unload_reply_message_(NULL) { 64 unload_reply_message_(NULL),
65 route_all_top_level_navigations_(false) {
65 } 66 }
66 67
67 ExternalTabContainer::~ExternalTabContainer() { 68 ExternalTabContainer::~ExternalTabContainer() {
68 Uninitialize(); 69 Uninitialize();
69 } 70 }
70 71
71 bool ExternalTabContainer::Init(Profile* profile, 72 bool ExternalTabContainer::Init(Profile* profile,
72 HWND parent, 73 HWND parent,
73 const gfx::Rect& bounds, 74 const gfx::Rect& bounds,
74 DWORD style, 75 DWORD style,
75 bool load_requests_via_automation, 76 bool load_requests_via_automation,
76 bool handle_top_level_requests, 77 bool handle_top_level_requests,
77 TabContents* existing_contents, 78 TabContents* existing_contents,
78 const GURL& initial_url, 79 const GURL& initial_url,
79 const GURL& referrer, 80 const GURL& referrer,
80 bool infobars_enabled) { 81 bool infobars_enabled,
82 bool route_all_top_level_navigations) {
81 if (IsWindow()) { 83 if (IsWindow()) {
82 NOTREACHED(); 84 NOTREACHED();
83 return false; 85 return false;
84 } 86 }
85 87
86 load_requests_via_automation_ = load_requests_via_automation; 88 load_requests_via_automation_ = load_requests_via_automation;
87 handle_top_level_requests_ = handle_top_level_requests; 89 handle_top_level_requests_ = handle_top_level_requests;
88 infobars_enabled_ = infobars_enabled; 90 infobars_enabled_ = infobars_enabled;
91 route_all_top_level_navigations_ = route_all_top_level_navigations;
89 92
90 set_window_style(WS_POPUP | WS_CLIPCHILDREN); 93 set_window_style(WS_POPUP | WS_CLIPCHILDREN);
91 views::WidgetWin::Init(NULL, bounds); 94 views::WidgetWin::Init(NULL, bounds);
92 if (!IsWindow()) { 95 if (!IsWindow()) {
93 NOTREACHED(); 96 NOTREACHED();
94 return false; 97 return false;
95 } 98 }
96 99
97 // TODO(jcampan): limit focus traversal to contents. 100 // TODO(jcampan): limit focus traversal to contents.
98 101
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 WindowOpenDisposition disposition, 352 WindowOpenDisposition disposition,
350 const gfx::Rect& initial_pos, 353 const gfx::Rect& initial_pos,
351 bool user_gesture) { 354 bool user_gesture) {
352 if (!automation_) { 355 if (!automation_) {
353 DCHECK(pending_); 356 DCHECK(pending_);
354 LOG(ERROR) << "Invalid automation provider. Dropping new contents notify"; 357 LOG(ERROR) << "Invalid automation provider. Dropping new contents notify";
355 delete new_contents; 358 delete new_contents;
356 return; 359 return;
357 } 360 }
358 361
359 scoped_refptr<ExternalTabContainer> new_container = 362 scoped_refptr<ExternalTabContainer> new_container;
360 new ExternalTabContainer(NULL, NULL); 363 // If the host is a browser like IE8, then the URL being navigated to in the
364 // new tab contents could potentially navigate back to Chrome from a new
365 // IE process. We support full tab mode only for IE and hence we use that as
366 // a determining factor in whether the new ExternalTabContainer instance is
367 // created as pending or not.
368 if (!route_all_top_level_navigations_) {
369 new_container = new ExternalTabContainer(NULL, NULL);
370 } else {
371 // Reuse the same tab handle here as the new container instance is a dummy
372 // instance which does not have an automation client connected at the other
373 // end.
374 new_container = new TemporaryPopupExternalTabContainer(
375 automation_, automation_resource_message_filter_.get());
376 new_container->SetTabHandle(tab_handle_);
377 }
361 378
362 // Make sure that ExternalTabContainer instance is initialized with 379 // Make sure that ExternalTabContainer instance is initialized with
363 // an unwrapped Profile. 380 // an unwrapped Profile.
364 bool result = new_container->Init( 381 bool result = new_container->Init(
365 new_contents->profile()->GetOriginalProfile(), 382 new_contents->profile()->GetOriginalProfile(),
366 NULL, 383 NULL,
367 initial_pos, 384 initial_pos,
368 WS_CHILD, 385 WS_CHILD,
369 load_requests_via_automation_, 386 load_requests_via_automation_,
370 handle_top_level_requests_, 387 handle_top_level_requests_,
371 new_contents, 388 new_contents,
372 GURL(), 389 GURL(),
373 GURL(), 390 GURL(),
374 true); 391 true,
392 route_all_top_level_navigations_);
375 393
376 if (result) { 394 if (result) {
395 if (route_all_top_level_navigations_) {
396 return;
397 }
377 uintptr_t cookie = reinterpret_cast<uintptr_t>(new_container.get()); 398 uintptr_t cookie = reinterpret_cast<uintptr_t>(new_container.get());
378 pending_tabs_.Get()[cookie] = new_container; 399 pending_tabs_.Get()[cookie] = new_container;
379 new_container->set_pending(true); 400 new_container->set_pending(true);
380 IPC::AttachExternalTabParams attach_params_; 401 IPC::AttachExternalTabParams attach_params_;
381 attach_params_.cookie = static_cast<uint64>(cookie); 402 attach_params_.cookie = static_cast<uint64>(cookie);
382 attach_params_.dimensions = initial_pos; 403 attach_params_.dimensions = initial_pos;
383 attach_params_.user_gesture = user_gesture; 404 attach_params_.user_gesture = user_gesture;
384 attach_params_.disposition = disposition; 405 attach_params_.disposition = disposition;
385 attach_params_.profile_name = WideToUTF8( 406 attach_params_.profile_name = WideToUTF8(
386 tab_contents()->profile()->GetPath().DirName().BaseName().value()); 407 tab_contents()->profile()->GetPath().DirName().BaseName().value());
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 render_view_host->process()->id(), 559 render_view_host->process()->id(),
539 render_view_host->routing_id()); 560 render_view_host->routing_id());
540 } 561 }
541 } 562 }
542 563
543 bool ExternalTabContainer::HandleContextMenu(const ContextMenuParams& params) { 564 bool ExternalTabContainer::HandleContextMenu(const ContextMenuParams& params) {
544 if (!automation_) { 565 if (!automation_) {
545 NOTREACHED(); 566 NOTREACHED();
546 return false; 567 return false;
547 } 568 }
548
549 external_context_menu_.reset( 569 external_context_menu_.reset(
550 new RenderViewContextMenuViews(tab_contents(), params)); 570 new RenderViewContextMenuViews(tab_contents(), params));
551 external_context_menu_->SetExternal(); 571 external_context_menu_->SetExternal();
552 external_context_menu_->Init(); 572 external_context_menu_->Init();
553 external_context_menu_->UpdateMenuItemStates(); 573 external_context_menu_->UpdateMenuItemStates();
554 574
555 POINT screen_pt = { params.x, params.y }; 575 POINT screen_pt = { params.x, params.y };
556 MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_pt, 1); 576 MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_pt, 1);
557 577
558 IPC::ContextMenuParams ipc_params; 578 IPC::ContextMenuParams ipc_params;
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 external_tab_view_->SetLayoutManager(layout); 1033 external_tab_view_->SetLayoutManager(layout);
1014 1034
1015 layout->StartRow(0, 0); 1035 layout->StartRow(0, 0);
1016 layout->AddView(info_bar_container); 1036 layout->AddView(info_bar_container);
1017 layout->StartRow(1, 0); 1037 layout->StartRow(1, 0);
1018 layout->AddView(tab_contents_container_); 1038 layout->AddView(tab_contents_container_);
1019 SetContentsView(external_tab_view_); 1039 SetContentsView(external_tab_view_);
1020 // Note that SetTabContents must be called after AddChildView is called 1040 // Note that SetTabContents must be called after AddChildView is called
1021 tab_contents_container_->ChangeTabContents(tab_contents_); 1041 tab_contents_container_->ChangeTabContents(tab_contents_);
1022 } 1042 }
1043
1044 TemporaryPopupExternalTabContainer::TemporaryPopupExternalTabContainer(
1045 AutomationProvider* automation,
1046 AutomationResourceMessageFilter* filter)
1047 : ExternalTabContainer(automation, filter) {
1048 }
1049
1050 TemporaryPopupExternalTabContainer::~TemporaryPopupExternalTabContainer() {
1051 DLOG(INFO) << __FUNCTION__;
1052 }
1053
1054 void TemporaryPopupExternalTabContainer::OpenURLFromTab(
1055 TabContents* source, const GURL& url, const GURL& referrer,
1056 WindowOpenDisposition disposition, PageTransition::Type transition) {
1057 if (!automation_)
1058 return;
1059
1060 if (disposition == CURRENT_TAB) {
1061 DCHECK(route_all_top_level_navigations_);
1062 disposition = NEW_FOREGROUND_TAB;
1063 }
1064 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition,
1065 transition);
1066 // support only one navigation for a dummy tab before it is killed.
1067 ::DestroyWindow(GetNativeView());
1068 }
1069
OLDNEW
« no previous file with comments | « chrome/browser/external_tab_container_win.h ('k') | chrome/test/automation/automation_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698