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

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

Issue 10536058: TabContentsWrapper -> TabContents, part 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: GetOwningTabContentsForWebContents Created 8 years, 6 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 15 matching lines...) Expand all
26 #include "chrome/browser/infobars/infobar_tab_helper.h" 26 #include "chrome/browser/infobars/infobar_tab_helper.h"
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/repost_form_warning_controller.h" 28 #include "chrome/browser/repost_form_warning_controller.h"
29 #include "chrome/browser/tab_contents/render_view_context_menu_win.h" 29 #include "chrome/browser/tab_contents/render_view_context_menu_win.h"
30 #include "chrome/browser/themes/theme_service.h" 30 #include "chrome/browser/themes/theme_service.h"
31 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h" 31 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_creator.h"
32 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 32 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
33 #include "chrome/browser/ui/browser.h" 33 #include "chrome/browser/ui/browser.h"
34 #include "chrome/browser/ui/browser_dialogs.h" 34 #include "chrome/browser/ui/browser_dialogs.h"
35 #include "chrome/browser/ui/browser_window.h" 35 #include "chrome/browser/ui/browser_window.h"
36 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 36 #include "chrome/browser/ui/tab_contents/tab_contents.h"
37 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 37 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
38 #include "chrome/common/automation_messages.h" 38 #include "chrome/common/automation_messages.h"
39 #include "chrome/common/chrome_constants.h" 39 #include "chrome/common/chrome_constants.h"
40 #include "chrome/common/chrome_notification_types.h" 40 #include "chrome/common/chrome_notification_types.h"
41 #include "chrome/common/render_messages.h" 41 #include "chrome/common/render_messages.h"
42 #include "chrome/common/url_constants.h" 42 #include "chrome/common/url_constants.h"
43 #include "content/public/browser/load_notification_details.h" 43 #include "content/public/browser/load_notification_details.h"
44 #include "content/public/browser/native_web_keyboard_event.h" 44 #include "content/public/browser/native_web_keyboard_event.h"
45 #include "content/public/browser/navigation_details.h" 45 #include "content/public/browser/navigation_details.h"
46 #include "content/public/browser/navigation_entry.h" 46 #include "content/public/browser/navigation_entry.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 WebContents * ExternalTabContainer::web_contents() const { 143 WebContents * ExternalTabContainer::web_contents() const {
144 return tab_contents_.get() ? tab_contents_->web_contents() : NULL; 144 return tab_contents_.get() ? tab_contents_->web_contents() : NULL;
145 } 145 }
146 146
147 bool ExternalTabContainer::Init(Profile* profile, 147 bool ExternalTabContainer::Init(Profile* profile,
148 HWND parent, 148 HWND parent,
149 const gfx::Rect& bounds, 149 const gfx::Rect& bounds,
150 DWORD style, 150 DWORD style,
151 bool load_requests_via_automation, 151 bool load_requests_via_automation,
152 bool handle_top_level_requests, 152 bool handle_top_level_requests,
153 TabContentsWrapper* existing_contents, 153 TabContents* existing_contents,
154 const GURL& initial_url, 154 const GURL& initial_url,
155 const GURL& referrer, 155 const GURL& referrer,
156 bool infobars_enabled, 156 bool infobars_enabled,
157 bool route_all_top_level_navigations) { 157 bool route_all_top_level_navigations) {
158 if (IsWindow()) { 158 if (IsWindow()) {
159 NOTREACHED(); 159 NOTREACHED();
160 return false; 160 return false;
161 } 161 }
162 162
163 load_requests_via_automation_ = load_requests_via_automation; 163 load_requests_via_automation_ = load_requests_via_automation;
(...skipping 14 matching lines...) Expand all
178 // TODO(jcampan): limit focus traversal to contents. 178 // TODO(jcampan): limit focus traversal to contents.
179 179
180 prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this)); 180 prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this));
181 181
182 if (existing_contents) { 182 if (existing_contents) {
183 tab_contents_.reset(existing_contents); 183 tab_contents_.reset(existing_contents);
184 tab_contents_->web_contents()->GetController().SetBrowserContext(profile); 184 tab_contents_->web_contents()->GetController().SetBrowserContext(profile);
185 } else { 185 } else {
186 WebContents* new_contents = WebContents::Create( 186 WebContents* new_contents = WebContents::Create(
187 profile, NULL, MSG_ROUTING_NONE, NULL, NULL); 187 profile, NULL, MSG_ROUTING_NONE, NULL, NULL);
188 tab_contents_.reset(new TabContentsWrapper(new_contents)); 188 tab_contents_.reset(new TabContents(new_contents));
189 } 189 }
190 190
191 if (!infobars_enabled) 191 if (!infobars_enabled)
192 tab_contents_->infobar_tab_helper()->set_infobars_enabled(false); 192 tab_contents_->infobar_tab_helper()->set_infobars_enabled(false);
193 193
194 tab_contents_->web_contents()->SetDelegate(this); 194 tab_contents_->web_contents()->SetDelegate(this);
195 195
196 tab_contents_->web_contents()-> 196 tab_contents_->web_contents()->
197 GetMutableRendererPrefs()->browser_handles_non_local_top_level_requests = 197 GetMutableRendererPrefs()->browser_handles_non_local_top_level_requests =
198 handle_top_level_requests; 198 handle_top_level_requests;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // Reuse the same tab handle here as the new container instance is a dummy 443 // Reuse the same tab handle here as the new container instance is a dummy
444 // instance which does not have an automation client connected at the other 444 // instance which does not have an automation client connected at the other
445 // end. 445 // end.
446 new_container = new TemporaryPopupExternalTabContainer( 446 new_container = new TemporaryPopupExternalTabContainer(
447 automation_, automation_resource_message_filter_.get()); 447 automation_, automation_resource_message_filter_.get());
448 new_container->SetTabHandle(tab_handle_); 448 new_container->SetTabHandle(tab_handle_);
449 } 449 }
450 450
451 // Make sure that ExternalTabContainer instance is initialized with 451 // Make sure that ExternalTabContainer instance is initialized with
452 // an unwrapped Profile. 452 // an unwrapped Profile.
453 scoped_ptr<TabContentsWrapper> wrapper(new TabContentsWrapper(new_contents)); 453 scoped_ptr<TabContents> tab_contents(new TabContents(new_contents));
454 bool result = new_container->Init( 454 bool result = new_container->Init(
455 wrapper->profile()->GetOriginalProfile(), 455 tab_contents->profile()->GetOriginalProfile(),
456 NULL, 456 NULL,
457 initial_pos, 457 initial_pos,
458 WS_CHILD, 458 WS_CHILD,
459 load_requests_via_automation_, 459 load_requests_via_automation_,
460 handle_top_level_requests_, 460 handle_top_level_requests_,
461 wrapper.get(), 461 tab_contents.get(),
462 GURL(), 462 GURL(),
463 GURL(), 463 GURL(),
464 true, 464 true,
465 route_all_top_level_navigations_); 465 route_all_top_level_navigations_);
466 466
467 if (result) { 467 if (result) {
468 Profile* profile = wrapper->profile(); 468 Profile* profile = tab_contents->profile();
469 wrapper.release(); // Ownership has been transferred. 469 tab_contents.release(); // Ownership has been transferred.
470 if (route_all_top_level_navigations_) { 470 if (route_all_top_level_navigations_) {
471 return; 471 return;
472 } 472 }
473 uintptr_t cookie = reinterpret_cast<uintptr_t>(new_container.get()); 473 uintptr_t cookie = reinterpret_cast<uintptr_t>(new_container.get());
474 pending_tabs_.Get()[cookie] = new_container; 474 pending_tabs_.Get()[cookie] = new_container;
475 new_container->set_pending(true); 475 new_container->set_pending(true);
476 new_container->set_is_popup_window(disposition == NEW_POPUP); 476 new_container->set_is_popup_window(disposition == NEW_POPUP);
477 AttachExternalTabParams attach_params_; 477 AttachExternalTabParams attach_params_;
478 attach_params_.cookie = static_cast<uint64>(cookie); 478 attach_params_.cookie = static_cast<uint64>(cookie);
479 attach_params_.dimensions = initial_pos; 479 attach_params_.dimensions = initial_pos;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 automation_->Send(new AutomationMsg_CloseExternalTab(tab_handle_)); 514 automation_->Send(new AutomationMsg_CloseExternalTab(tab_handle_));
515 } 515 }
516 } 516 }
517 517
518 void ExternalTabContainer::MoveContents(WebContents* source, 518 void ExternalTabContainer::MoveContents(WebContents* source,
519 const gfx::Rect& pos) { 519 const gfx::Rect& pos) {
520 if (automation_ && is_popup_window_) 520 if (automation_ && is_popup_window_)
521 automation_->Send(new AutomationMsg_MoveWindow(tab_handle_, pos)); 521 automation_->Send(new AutomationMsg_MoveWindow(tab_handle_, pos));
522 } 522 }
523 523
524 TabContentsWrapper* ExternalTabContainer::GetConstrainingContentsWrapper( 524 TabContents* ExternalTabContainer::GetConstrainingContentsWrapper(
525 TabContentsWrapper* source) { 525 TabContents* source) {
526 return source; 526 return source;
527 } 527 }
528 528
529 bool ExternalTabContainer::IsPopupOrPanel(const WebContents* source) const { 529 bool ExternalTabContainer::IsPopupOrPanel(const WebContents* source) const {
530 return is_popup_window_; 530 return is_popup_window_;
531 } 531 }
532 532
533 void ExternalTabContainer::UpdateTargetURL(WebContents* source, 533 void ExternalTabContainer::UpdateTargetURL(WebContents* source,
534 int32 page_id, 534 int32 page_id,
535 const GURL& url) { 535 const GURL& url) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 automation_->Send(unload_reply_message_); 710 automation_->Send(unload_reply_message_);
711 unload_reply_message_ = NULL; 711 unload_reply_message_ = NULL;
712 *proceed_to_fire_unload = false; 712 *proceed_to_fire_unload = false;
713 } 713 }
714 } 714 }
715 715
716 void ExternalTabContainer::ShowRepostFormWarningDialog( 716 void ExternalTabContainer::ShowRepostFormWarningDialog(
717 WebContents* source) { 717 WebContents* source) {
718 browser::ShowTabModalConfirmDialog( 718 browser::ShowTabModalConfirmDialog(
719 new RepostFormWarningController(source), 719 new RepostFormWarningController(source),
720 TabContentsWrapper::GetCurrentWrapperForContents(source)); 720 TabContents::GetOwningTabContentsForWebContents(source));
721 } 721 }
722 722
723 void ExternalTabContainer::RunFileChooser( 723 void ExternalTabContainer::RunFileChooser(
724 WebContents* tab, const content::FileChooserParams& params) { 724 WebContents* tab, const content::FileChooserParams& params) {
725 FileSelectHelper::RunFileChooser(tab, params); 725 FileSelectHelper::RunFileChooser(tab, params);
726 } 726 }
727 727
728 void ExternalTabContainer::EnumerateDirectory(WebContents* tab, int request_id, 728 void ExternalTabContainer::EnumerateDirectory(WebContents* tab, int request_id,
729 const FilePath& path) { 729 const FilePath& path) {
730 FileSelectHelper::EnumerateDirectory(tab, request_id, path); 730 FileSelectHelper::EnumerateDirectory(tab, request_id, path);
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 if (params.disposition == CURRENT_TAB) { 1202 if (params.disposition == CURRENT_TAB) {
1203 DCHECK(route_all_top_level_navigations_); 1203 DCHECK(route_all_top_level_navigations_);
1204 forward_params.disposition = NEW_FOREGROUND_TAB; 1204 forward_params.disposition = NEW_FOREGROUND_TAB;
1205 } 1205 }
1206 WebContents* new_contents = 1206 WebContents* new_contents =
1207 ExternalTabContainer::OpenURLFromTab(source, forward_params); 1207 ExternalTabContainer::OpenURLFromTab(source, forward_params);
1208 // support only one navigation for a dummy tab before it is killed. 1208 // support only one navigation for a dummy tab before it is killed.
1209 ::DestroyWindow(GetNativeView()); 1209 ::DestroyWindow(GetNativeView());
1210 return new_contents; 1210 return new_contents;
1211 } 1211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698