OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 if (existing_contents) { | 152 if (existing_contents) { |
153 tab_contents_.reset(existing_contents); | 153 tab_contents_.reset(existing_contents); |
154 tab_contents_->controller().set_profile(profile); | 154 tab_contents_->controller().set_profile(profile); |
155 } else { | 155 } else { |
156 TabContents* new_contents = new TabContents(profile, NULL, MSG_ROUTING_NONE, | 156 TabContents* new_contents = new TabContents(profile, NULL, MSG_ROUTING_NONE, |
157 NULL, NULL); | 157 NULL, NULL); |
158 tab_contents_.reset(new TabContentsWrapper(new_contents)); | 158 tab_contents_.reset(new TabContentsWrapper(new_contents)); |
159 } | 159 } |
160 | 160 |
161 tab_contents_->tab_contents()->set_delegate(this); | 161 tab_contents_->tab_contents()->set_delegate(this); |
162 tab_contents_->download_tab_helper()->set_delegate(this); | |
163 | 162 |
164 tab_contents_->tab_contents()-> | 163 tab_contents_->tab_contents()-> |
165 GetMutableRendererPrefs()->browser_handles_top_level_requests = | 164 GetMutableRendererPrefs()->browser_handles_top_level_requests = |
166 handle_top_level_requests; | 165 handle_top_level_requests; |
167 | 166 |
168 if (!existing_contents) { | 167 if (!existing_contents) { |
169 tab_contents_->render_view_host()->AllowBindings( | 168 tab_contents_->render_view_host()->AllowBindings( |
170 BindingsPolicy::EXTERNAL_HOST); | 169 BindingsPolicy::EXTERNAL_HOST); |
171 } | 170 } |
172 | 171 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 532 |
534 bool ExternalTabContainer::TakeFocus(bool reverse) { | 533 bool ExternalTabContainer::TakeFocus(bool reverse) { |
535 if (automation_) { | 534 if (automation_) { |
536 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_, | 535 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_, |
537 base::win::IsShiftPressed())); | 536 base::win::IsShiftPressed())); |
538 } | 537 } |
539 | 538 |
540 return true; | 539 return true; |
541 } | 540 } |
542 | 541 |
| 542 bool ExternalTabContainer::CanDownload(int request_id) { |
| 543 if (load_requests_via_automation_) { |
| 544 if (automation_) { |
| 545 // In case the host needs to show UI that needs to take the focus. |
| 546 ::AllowSetForegroundWindow(ASFW_ANY); |
| 547 |
| 548 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 549 NewRunnableMethod(automation_resource_message_filter_.get(), |
| 550 &AutomationResourceMessageFilter::SendDownloadRequestToHost, |
| 551 0, tab_handle_, request_id)); |
| 552 } |
| 553 } else { |
| 554 DLOG(WARNING) << "Downloads are only supported with host browser network " |
| 555 "stack enabled."; |
| 556 } |
| 557 |
| 558 // Never allow downloads. |
| 559 return false; |
| 560 } |
| 561 |
543 void ExternalTabContainer::ShowPageInfo(Profile* profile, | 562 void ExternalTabContainer::ShowPageInfo(Profile* profile, |
544 const GURL& url, | 563 const GURL& url, |
545 const NavigationEntry::SSLStatus& ssl, | 564 const NavigationEntry::SSLStatus& ssl, |
546 bool show_history) { | 565 bool show_history) { |
547 POINT cursor_pos = {0}; | 566 POINT cursor_pos = {0}; |
548 GetCursorPos(&cursor_pos); | 567 GetCursorPos(&cursor_pos); |
549 | 568 |
550 gfx::Rect bounds; | 569 gfx::Rect bounds; |
551 bounds.set_origin(gfx::Point(cursor_pos)); | 570 bounds.set_origin(gfx::Point(cursor_pos)); |
552 | 571 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 UnregisterRenderViewHost(rvh); | 777 UnregisterRenderViewHost(rvh); |
759 } | 778 } |
760 break; | 779 break; |
761 } | 780 } |
762 default: | 781 default: |
763 NOTREACHED(); | 782 NOTREACHED(); |
764 } | 783 } |
765 } | 784 } |
766 | 785 |
767 //////////////////////////////////////////////////////////////////////////////// | 786 //////////////////////////////////////////////////////////////////////////////// |
768 // ExternalTabContainer, DownloadTabHelperDelegate overrides: | |
769 | |
770 bool ExternalTabContainer::CanDownload(int request_id) { | |
771 if (load_requests_via_automation_) { | |
772 if (automation_) { | |
773 // In case the host needs to show UI that needs to take the focus. | |
774 ::AllowSetForegroundWindow(ASFW_ANY); | |
775 | |
776 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
777 NewRunnableMethod(automation_resource_message_filter_.get(), | |
778 &AutomationResourceMessageFilter::SendDownloadRequestToHost, | |
779 0, tab_handle_, request_id)); | |
780 } | |
781 } else { | |
782 DLOG(WARNING) << "Downloads are only supported with host browser network " | |
783 "stack enabled."; | |
784 } | |
785 | |
786 // Never allow downloads. | |
787 return false; | |
788 } | |
789 | |
790 void ExternalTabContainer::OnStartDownload(DownloadItem* download, | |
791 TabContentsWrapper* tab) { | |
792 } | |
793 | |
794 | |
795 //////////////////////////////////////////////////////////////////////////////// | |
796 // ExternalTabContainer, views::WidgetWin overrides: | 787 // ExternalTabContainer, views::WidgetWin overrides: |
797 | 788 |
798 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { | 789 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { |
799 LRESULT result = views::WidgetWin::OnCreate(create_struct); | 790 LRESULT result = views::WidgetWin::OnCreate(create_struct); |
800 if (result == 0) { | 791 if (result == 0) { |
801 // Grab a reference here which will be released in OnFinalMessage | 792 // Grab a reference here which will be released in OnFinalMessage |
802 AddRef(); | 793 AddRef(); |
803 } | 794 } |
804 return result; | 795 return result; |
805 } | 796 } |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 | 1102 |
1112 if (disposition == CURRENT_TAB) { | 1103 if (disposition == CURRENT_TAB) { |
1113 DCHECK(route_all_top_level_navigations_); | 1104 DCHECK(route_all_top_level_navigations_); |
1114 disposition = NEW_FOREGROUND_TAB; | 1105 disposition = NEW_FOREGROUND_TAB; |
1115 } | 1106 } |
1116 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, | 1107 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, |
1117 transition); | 1108 transition); |
1118 // support only one navigation for a dummy tab before it is killed. | 1109 // support only one navigation for a dummy tab before it is killed. |
1119 ::DestroyWindow(GetNativeView()); | 1110 ::DestroyWindow(GetNativeView()); |
1120 } | 1111 } |
OLD | NEW |