| 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); |
| 162 | 163 |
| 163 tab_contents_->tab_contents()-> | 164 tab_contents_->tab_contents()-> |
| 164 GetMutableRendererPrefs()->browser_handles_top_level_requests = | 165 GetMutableRendererPrefs()->browser_handles_top_level_requests = |
| 165 handle_top_level_requests; | 166 handle_top_level_requests; |
| 166 | 167 |
| 167 if (!existing_contents) { | 168 if (!existing_contents) { |
| 168 tab_contents_->render_view_host()->AllowBindings( | 169 tab_contents_->render_view_host()->AllowBindings( |
| 169 BindingsPolicy::EXTERNAL_HOST); | 170 BindingsPolicy::EXTERNAL_HOST); |
| 170 } | 171 } |
| 171 | 172 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 533 |
| 533 bool ExternalTabContainer::TakeFocus(bool reverse) { | 534 bool ExternalTabContainer::TakeFocus(bool reverse) { |
| 534 if (automation_) { | 535 if (automation_) { |
| 535 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_, | 536 automation_->Send(new AutomationMsg_TabbedOut(tab_handle_, |
| 536 base::win::IsShiftPressed())); | 537 base::win::IsShiftPressed())); |
| 537 } | 538 } |
| 538 | 539 |
| 539 return true; | 540 return true; |
| 540 } | 541 } |
| 541 | 542 |
| 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 | |
| 562 void ExternalTabContainer::ShowPageInfo(Profile* profile, | 543 void ExternalTabContainer::ShowPageInfo(Profile* profile, |
| 563 const GURL& url, | 544 const GURL& url, |
| 564 const NavigationEntry::SSLStatus& ssl, | 545 const NavigationEntry::SSLStatus& ssl, |
| 565 bool show_history) { | 546 bool show_history) { |
| 566 POINT cursor_pos = {0}; | 547 POINT cursor_pos = {0}; |
| 567 GetCursorPos(&cursor_pos); | 548 GetCursorPos(&cursor_pos); |
| 568 | 549 |
| 569 gfx::Rect bounds; | 550 gfx::Rect bounds; |
| 570 bounds.set_origin(gfx::Point(cursor_pos)); | 551 bounds.set_origin(gfx::Point(cursor_pos)); |
| 571 | 552 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 UnregisterRenderViewHost(rvh); | 758 UnregisterRenderViewHost(rvh); |
| 778 } | 759 } |
| 779 break; | 760 break; |
| 780 } | 761 } |
| 781 default: | 762 default: |
| 782 NOTREACHED(); | 763 NOTREACHED(); |
| 783 } | 764 } |
| 784 } | 765 } |
| 785 | 766 |
| 786 //////////////////////////////////////////////////////////////////////////////// | 767 //////////////////////////////////////////////////////////////////////////////// |
| 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 //////////////////////////////////////////////////////////////////////////////// |
| 787 // ExternalTabContainer, views::WidgetWin overrides: | 796 // ExternalTabContainer, views::WidgetWin overrides: |
| 788 | 797 |
| 789 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { | 798 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { |
| 790 LRESULT result = views::WidgetWin::OnCreate(create_struct); | 799 LRESULT result = views::WidgetWin::OnCreate(create_struct); |
| 791 if (result == 0) { | 800 if (result == 0) { |
| 792 // Grab a reference here which will be released in OnFinalMessage | 801 // Grab a reference here which will be released in OnFinalMessage |
| 793 AddRef(); | 802 AddRef(); |
| 794 } | 803 } |
| 795 return result; | 804 return result; |
| 796 } | 805 } |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 | 1111 |
| 1103 if (disposition == CURRENT_TAB) { | 1112 if (disposition == CURRENT_TAB) { |
| 1104 DCHECK(route_all_top_level_navigations_); | 1113 DCHECK(route_all_top_level_navigations_); |
| 1105 disposition = NEW_FOREGROUND_TAB; | 1114 disposition = NEW_FOREGROUND_TAB; |
| 1106 } | 1115 } |
| 1107 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, | 1116 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, |
| 1108 transition); | 1117 transition); |
| 1109 // support only one navigation for a dummy tab before it is killed. | 1118 // support only one navigation for a dummy tab before it is killed. |
| 1110 ::DestroyWindow(GetNativeView()); | 1119 ::DestroyWindow(GetNativeView()); |
| 1111 } | 1120 } |
| OLD | NEW |