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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 212 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
213 content::Source<NavigationController>(controller)); | 213 content::Source<NavigationController>(controller)); |
214 registrar_.Add(this, content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, | 214 registrar_.Add(this, content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR, |
215 content::Source<NavigationController>(controller)); | 215 content::Source<NavigationController>(controller)); |
216 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 216 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
217 content::Source<NavigationController>(controller)); | 217 content::Source<NavigationController>(controller)); |
218 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, | 218 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, |
219 content::Source<TabContents>(tab_contents_->tab_contents())); | 219 content::Source<TabContents>(tab_contents_->tab_contents())); |
220 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, | 220 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, |
221 content::NotificationService::AllSources()); | 221 content::NotificationService::AllSources()); |
| 222 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, |
| 223 content::NotificationService::AllSources()); |
222 | 224 |
223 TabContentsObserver::Observe(tab_contents_->tab_contents()); | 225 TabContentsObserver::Observe(tab_contents_->tab_contents()); |
224 | 226 |
225 // Start loading initial URL | 227 // Start loading initial URL |
226 if (!initial_url.is_empty()) { | 228 if (!initial_url.is_empty()) { |
227 // Navigate out of context since we don't have a 'tab_handle_' yet. | 229 // Navigate out of context since we don't have a 'tab_handle_' yet. |
228 MessageLoop::current()->PostTask( | 230 MessageLoop::current()->PostTask( |
229 FROM_HERE, | 231 FROM_HERE, |
230 external_method_factory_.NewRunnableMethod( | 232 external_method_factory_.NewRunnableMethod( |
231 &ExternalTabContainer::Navigate, initial_url, referrer)); | 233 &ExternalTabContainer::Navigate, initial_url, referrer)); |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 if (load != NULL && | 833 if (load != NULL && |
832 content::PageTransitionIsMainFrame(load->origin())) { | 834 content::PageTransitionIsMainFrame(load->origin())) { |
833 TRACE_EVENT_END_ETW("ExternalTabContainer::Navigate", 0, | 835 TRACE_EVENT_END_ETW("ExternalTabContainer::Navigate", 0, |
834 load->url().spec()); | 836 load->url().spec()); |
835 automation_->Send(new AutomationMsg_TabLoaded(tab_handle_, | 837 automation_->Send(new AutomationMsg_TabLoaded(tab_handle_, |
836 load->url())); | 838 load->url())); |
837 } | 839 } |
838 break; | 840 break; |
839 } | 841 } |
840 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { | 842 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { |
841 if (ignore_next_load_notification_) { | 843 if (ignore_next_load_notification_) { |
842 ignore_next_load_notification_ = false; | 844 ignore_next_load_notification_ = false; |
843 return; | 845 return; |
844 } | 846 } |
845 | 847 |
846 const content::LoadCommittedDetails* commit = | 848 const content::LoadCommittedDetails* commit = |
847 content::Details<content::LoadCommittedDetails>(details).ptr(); | 849 content::Details<content::LoadCommittedDetails>(details).ptr(); |
848 | 850 |
849 if (commit->http_status_code >= kHttpClientErrorStart && | 851 if (commit->http_status_code >= kHttpClientErrorStart && |
850 commit->http_status_code <= kHttpServerErrorEnd) { | 852 commit->http_status_code <= kHttpServerErrorEnd) { |
851 automation_->Send(new AutomationMsg_NavigationFailed( | 853 automation_->Send(new AutomationMsg_NavigationFailed( |
852 tab_handle_, commit->http_status_code, commit->entry->url())); | 854 tab_handle_, commit->http_status_code, commit->entry->url())); |
853 | 855 |
854 ignore_next_load_notification_ = true; | 856 ignore_next_load_notification_ = true; |
855 } else { | 857 } else { |
856 NavigationInfo navigation_info; | 858 NavigationInfo navigation_info; |
857 // When the previous entry index is invalid, it will be -1, which | 859 // When the previous entry index is invalid, it will be -1, which |
858 // will still make the computation come out right (navigating to the | 860 // will still make the computation come out right (navigating to the |
859 // 0th entry will be +1). | 861 // 0th entry will be +1). |
860 if (InitNavigationInfo(&navigation_info, commit->type, | 862 if (InitNavigationInfo(&navigation_info, commit->type, |
861 commit->previous_entry_index - | 863 commit->previous_entry_index - |
862 tab_contents_->controller().last_committed_entry_index())) | 864 tab_contents_->controller().last_committed_entry_index())) |
863 automation_->Send(new AutomationMsg_DidNavigate(tab_handle_, | 865 automation_->Send(new AutomationMsg_DidNavigate(tab_handle_, |
864 navigation_info)); | 866 navigation_info)); |
865 } | |
866 break; | |
867 } | 867 } |
| 868 break; |
| 869 } |
868 case content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR: { | 870 case content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR: { |
869 const ProvisionalLoadDetails* load_details = | 871 const ProvisionalLoadDetails* load_details = |
870 content::Details<ProvisionalLoadDetails>(details).ptr(); | 872 content::Details<ProvisionalLoadDetails>(details).ptr(); |
871 automation_->Send(new AutomationMsg_NavigationFailed( | 873 automation_->Send(new AutomationMsg_NavigationFailed( |
872 tab_handle_, load_details->error_code(), load_details->url())); | 874 tab_handle_, load_details->error_code(), load_details->url())); |
873 | 875 |
874 ignore_next_load_notification_ = true; | 876 ignore_next_load_notification_ = true; |
875 break; | 877 break; |
876 } | 878 } |
877 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { | 879 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: { |
878 if (load_requests_via_automation_) { | 880 if (load_requests_via_automation_) { |
879 RenderViewHost* rvh = content::Details<RenderViewHost>(details).ptr(); | 881 RenderViewHost* rvh = content::Details<RenderViewHost>(details).ptr(); |
880 RegisterRenderViewHostForAutomation(rvh, false); | 882 RegisterRenderViewHostForAutomation(rvh, false); |
881 } | 883 } |
882 break; | 884 break; |
883 } | 885 } |
884 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: { | 886 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: { |
885 if (load_requests_via_automation_) { | 887 if (load_requests_via_automation_) { |
886 RenderViewHost* rvh = content::Source<RenderViewHost>(source).ptr(); | 888 RenderViewHost* rvh = content::Source<RenderViewHost>(source).ptr(); |
887 UnregisterRenderViewHost(rvh); | 889 UnregisterRenderViewHost(rvh); |
888 } | 890 } |
889 break; | 891 break; |
890 } | 892 } |
| 893 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: { |
| 894 if (load_requests_via_automation_) { |
| 895 RenderViewHost* rvh = content::Source<RenderViewHost>(source).ptr(); |
| 896 RegisterRenderViewHostForAutomation(rvh, false); |
| 897 } |
| 898 break; |
| 899 } |
891 default: | 900 default: |
892 NOTREACHED(); | 901 NOTREACHED(); |
893 } | 902 } |
894 } | 903 } |
895 | 904 |
896 //////////////////////////////////////////////////////////////////////////////// | 905 //////////////////////////////////////////////////////////////////////////////// |
897 // ExternalTabContainer, views::NativeWidgetWin overrides: | 906 // ExternalTabContainer, views::NativeWidgetWin overrides: |
898 | 907 |
899 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { | 908 LRESULT ExternalTabContainer::OnCreate(LPCREATESTRUCT create_struct) { |
900 LRESULT result = views::NativeWidgetWin::OnCreate(create_struct); | 909 LRESULT result = views::NativeWidgetWin::OnCreate(create_struct); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 if (params.disposition == CURRENT_TAB) { | 1223 if (params.disposition == CURRENT_TAB) { |
1215 DCHECK(route_all_top_level_navigations_); | 1224 DCHECK(route_all_top_level_navigations_); |
1216 forward_params.disposition = NEW_FOREGROUND_TAB; | 1225 forward_params.disposition = NEW_FOREGROUND_TAB; |
1217 } | 1226 } |
1218 TabContents* new_contents = | 1227 TabContents* new_contents = |
1219 ExternalTabContainer::OpenURLFromTab(source, forward_params); | 1228 ExternalTabContainer::OpenURLFromTab(source, forward_params); |
1220 // support only one navigation for a dummy tab before it is killed. | 1229 // support only one navigation for a dummy tab before it is killed. |
1221 ::DestroyWindow(GetNativeView()); | 1230 ::DestroyWindow(GetNativeView()); |
1222 return new_contents; | 1231 return new_contents; |
1223 } | 1232 } |
OLD | NEW |