| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } else { | 190 } else { |
| 191 TabContents* new_contents = new TabContents(profile, NULL, MSG_ROUTING_NONE, | 191 TabContents* new_contents = new TabContents(profile, NULL, MSG_ROUTING_NONE, |
| 192 NULL, NULL); | 192 NULL, NULL); |
| 193 tab_contents_.reset(new TabContentsWrapper(new_contents)); | 193 tab_contents_.reset(new TabContentsWrapper(new_contents)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 if (!infobars_enabled) | 196 if (!infobars_enabled) |
| 197 tab_contents_->set_infobars_enabled(false); | 197 tab_contents_->set_infobars_enabled(false); |
| 198 | 198 |
| 199 tab_contents_->tab_contents()->set_delegate(this); | 199 tab_contents_->tab_contents()->set_delegate(this); |
| 200 tab_contents_->download_tab_helper()->set_delegate(this); | |
| 201 | 200 |
| 202 tab_contents_->tab_contents()-> | 201 tab_contents_->tab_contents()-> |
| 203 GetMutableRendererPrefs()->browser_handles_top_level_requests = | 202 GetMutableRendererPrefs()->browser_handles_top_level_requests = |
| 204 handle_top_level_requests; | 203 handle_top_level_requests; |
| 205 | 204 |
| 206 if (!existing_contents) { | 205 if (!existing_contents) { |
| 207 tab_contents_->render_view_host()->AllowBindings( | 206 tab_contents_->render_view_host()->AllowBindings( |
| 208 BindingsPolicy::EXTERNAL_HOST); | 207 BindingsPolicy::EXTERNAL_HOST); |
| 209 } | 208 } |
| 210 | 209 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 552 |
| 554 bool ExternalTabContainer::TakeFocus(bool reverse) { | 553 bool ExternalTabContainer::TakeFocus(bool reverse) { |
| 555 if (automation_) { | 554 if (automation_) { |
| 556 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_, | 555 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_, |
| 557 base::win::IsShiftPressed())); | 556 base::win::IsShiftPressed())); |
| 558 } | 557 } |
| 559 | 558 |
| 560 return true; | 559 return true; |
| 561 } | 560 } |
| 562 | 561 |
| 562 bool ExternalTabContainer::CanDownload(int request_id) { |
| 563 if (load_requests_via_automation_) { |
| 564 if (automation_) { |
| 565 // In case the host needs to show UI that needs to take the focus. |
| 566 ::AllowSetForegroundWindow(ASFW_ANY); |
| 567 |
| 568 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 569 NewRunnableMethod(automation_resource_message_filter_.get(), |
| 570 &AutomationResourceMessageFilter::SendDownloadRequestToHost, |
| 571 0, tab_handle_, request_id)); |
| 572 } |
| 573 } else { |
| 574 DLOG(WARNING) << "Downloads are only supported with host browser network " |
| 575 "stack enabled."; |
| 576 } |
| 577 |
| 578 // Never allow downloads. |
| 579 return false; |
| 580 } |
| 581 |
| 563 void ExternalTabContainer::ShowPageInfo(Profile* profile, | 582 void ExternalTabContainer::ShowPageInfo(Profile* profile, |
| 564 const GURL& url, | 583 const GURL& url, |
| 565 const NavigationEntry::SSLStatus& ssl, | 584 const NavigationEntry::SSLStatus& ssl, |
| 566 bool show_history) { | 585 bool show_history) { |
| 567 POINT cursor_pos = {0}; | 586 POINT cursor_pos = {0}; |
| 568 GetCursorPos(&cursor_pos); | 587 GetCursorPos(&cursor_pos); |
| 569 | 588 |
| 570 gfx::Rect bounds; | 589 gfx::Rect bounds; |
| 571 bounds.set_origin(gfx::Point(cursor_pos)); | 590 bounds.set_origin(gfx::Point(cursor_pos)); |
| 572 | 591 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 UnregisterRenderViewHost(rvh); | 826 UnregisterRenderViewHost(rvh); |
| 808 } | 827 } |
| 809 break; | 828 break; |
| 810 } | 829 } |
| 811 default: | 830 default: |
| 812 NOTREACHED(); | 831 NOTREACHED(); |
| 813 } | 832 } |
| 814 } | 833 } |
| 815 | 834 |
| 816 //////////////////////////////////////////////////////////////////////////////// | 835 //////////////////////////////////////////////////////////////////////////////// |
| 817 // ExternalTabContainer, DownloadTabHelperDelegate overrides: | |
| 818 | |
| 819 bool ExternalTabContainer::CanDownload(int request_id) { | |
| 820 if (load_requests_via_automation_) { | |
| 821 if (automation_) { | |
| 822 // In case the host needs to show UI that needs to take the focus. | |
| 823 ::AllowSetForegroundWindow(ASFW_ANY); | |
| 824 | |
| 825 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
| 826 NewRunnableMethod(automation_resource_message_filter_.get(), | |
| 827 &AutomationResourceMessageFilter::SendDownloadRequestToHost, | |
| 828 0, tab_handle_, request_id)); | |
| 829 } | |
| 830 } else { | |
| 831 DLOG(WARNING) << "Downloads are only supported with host browser network " | |
| 832 "stack enabled."; | |
| 833 } | |
| 834 | |
| 835 // Never allow downloads. | |
| 836 return false; | |
| 837 } | |
| 838 | |
| 839 void ExternalTabContainer::OnStartDownload(DownloadItem* download, | |
| 840 TabContentsWrapper* tab) { | |
| 841 // Downloads are handled by Automation. | |
| 842 } | |
| 843 | |
| 844 | |
| 845 //////////////////////////////////////////////////////////////////////////////// | |
| 846 // ExternalTabContainer, views::NativeWidgetWin overrides: | 836 // ExternalTabContainer, views::NativeWidgetWin overrides: |
| 847 | 837 |
| 848 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { | 838 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { |
| 849 LRESULT result = views::NativeWidgetWin::OnCreate(create_struct); | 839 LRESULT result = views::NativeWidgetWin::OnCreate(create_struct); |
| 850 if (result == 0) { | 840 if (result == 0) { |
| 851 // Grab a reference here which will be released in OnFinalMessage | 841 // Grab a reference here which will be released in OnFinalMessage |
| 852 AddRef(); | 842 AddRef(); |
| 853 } | 843 } |
| 854 return result; | 844 return result; |
| 855 } | 845 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 | 1147 |
| 1158 if (disposition == CURRENT_TAB) { | 1148 if (disposition == CURRENT_TAB) { |
| 1159 DCHECK(route_all_top_level_navigations_); | 1149 DCHECK(route_all_top_level_navigations_); |
| 1160 disposition = NEW_FOREGROUND_TAB; | 1150 disposition = NEW_FOREGROUND_TAB; |
| 1161 } | 1151 } |
| 1162 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, | 1152 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, |
| 1163 transition); | 1153 transition); |
| 1164 // support only one navigation for a dummy tab before it is killed. | 1154 // support only one navigation for a dummy tab before it is killed. |
| 1165 ::DestroyWindow(GetNativeView()); | 1155 ::DestroyWindow(GetNativeView()); |
| 1166 } | 1156 } |
| OLD | NEW |