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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 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 14 matching lines...) Expand all
25 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/download/download_tab_helper.h" 26 #include "chrome/browser/ui/download/download_tab_helper.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 27 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
28 #include "chrome/browser/ui/views/browser_dialogs.h" 28 #include "chrome/browser/ui/views/browser_dialogs.h"
29 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 29 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
30 #include "chrome/browser/ui/views/page_info_bubble_view.h" 30 #include "chrome/browser/ui/views/page_info_bubble_view.h"
31 #include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h" 31 #include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h"
32 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" 32 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h"
33 #include "chrome/common/automation_messages.h" 33 #include "chrome/common/automation_messages.h"
34 #include "chrome/common/chrome_constants.h" 34 #include "chrome/common/chrome_constants.h"
35 #include "chrome/common/chrome_notification_types.h"
35 #include "chrome/common/render_messages.h" 36 #include "chrome/common/render_messages.h"
36 #include "chrome/common/url_constants.h" 37 #include "chrome/common/url_constants.h"
37 #include "content/browser/debugger/devtools_toggle_action.h" 38 #include "content/browser/debugger/devtools_toggle_action.h"
38 #include "content/browser/debugger/devtools_window.h" 39 #include "content/browser/debugger/devtools_window.h"
39 #include "content/browser/load_notification_details.h" 40 #include "content/browser/load_notification_details.h"
40 #include "content/browser/renderer_host/render_process_host.h" 41 #include "content/browser/renderer_host/render_process_host.h"
41 #include "content/browser/renderer_host/render_view_host.h" 42 #include "content/browser/renderer_host/render_view_host.h"
42 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 43 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
43 #include "content/browser/tab_contents/navigation_details.h" 44 #include "content/browser/tab_contents/navigation_details.h"
44 #include "content/browser/tab_contents/provisional_load_details.h" 45 #include "content/browser/tab_contents/provisional_load_details.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 tab_contents_->tab_contents()-> 171 tab_contents_->tab_contents()->
171 GetMutableRendererPrefs()->browser_handles_top_level_requests = 172 GetMutableRendererPrefs()->browser_handles_top_level_requests =
172 handle_top_level_requests; 173 handle_top_level_requests;
173 174
174 if (!existing_contents) { 175 if (!existing_contents) {
175 tab_contents_->render_view_host()->AllowBindings( 176 tab_contents_->render_view_host()->AllowBindings(
176 BindingsPolicy::EXTERNAL_HOST); 177 BindingsPolicy::EXTERNAL_HOST);
177 } 178 }
178 179
179 NavigationController* controller = &tab_contents_->controller(); 180 NavigationController* controller = &tab_contents_->controller();
180 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 181 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
181 Source<NavigationController>(controller)); 182 Source<NavigationController>(controller));
182 registrar_.Add(this, NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, 183 registrar_.Add(this, content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR,
183 Source<NavigationController>(controller)); 184 Source<NavigationController>(controller));
184 registrar_.Add(this, NotificationType::LOAD_STOP, 185 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
185 Source<NavigationController>(controller)); 186 Source<NavigationController>(controller));
186 registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB, 187 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
187 Source<TabContents>(tab_contents_->tab_contents())); 188 Source<TabContents>(tab_contents_->tab_contents()));
188 registrar_.Add(this, NotificationType::RENDER_VIEW_HOST_DELETED, 189 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED,
189 NotificationService::AllSources()); 190 NotificationService::AllSources());
190 191
191 NotificationService::current()->Notify( 192 NotificationService::current()->Notify(
192 NotificationType::EXTERNAL_TAB_CREATED, 193 chrome::NOTIFICATION_EXTERNAL_TAB_CREATED,
193 Source<NavigationController>(controller), 194 Source<NavigationController>(controller),
194 NotificationService::NoDetails()); 195 NotificationService::NoDetails());
195 196
196 TabContentsObserver::Observe(tab_contents_->tab_contents()); 197 TabContentsObserver::Observe(tab_contents_->tab_contents());
197 198
198 // Start loading initial URL 199 // Start loading initial URL
199 if (!initial_url.is_empty()) { 200 if (!initial_url.is_empty()) {
200 // Navigate out of context since we don't have a 'tab_handle_' yet. 201 // Navigate out of context since we don't have a 'tab_handle_' yet.
201 MessageLoop::current()->PostTask( 202 MessageLoop::current()->PostTask(
202 FROM_HERE, 203 FROM_HERE,
(...skipping 23 matching lines...) Expand all
226 227
227 void ExternalTabContainer::Uninitialize() { 228 void ExternalTabContainer::Uninitialize() {
228 registrar_.RemoveAll(); 229 registrar_.RemoveAll();
229 if (tab_contents_.get()) { 230 if (tab_contents_.get()) {
230 UnregisterRenderViewHost(tab_contents_->render_view_host()); 231 UnregisterRenderViewHost(tab_contents_->render_view_host());
231 232
232 if (GetWidget()->GetRootView()) 233 if (GetWidget()->GetRootView())
233 GetWidget()->GetRootView()->RemoveAllChildViews(true); 234 GetWidget()->GetRootView()->RemoveAllChildViews(true);
234 235
235 NotificationService::current()->Notify( 236 NotificationService::current()->Notify(
236 NotificationType::EXTERNAL_TAB_CLOSED, 237 chrome::NOTIFICATION_EXTERNAL_TAB_CLOSED,
237 Source<NavigationController>(&tab_contents_->controller()), 238 Source<NavigationController>(&tab_contents_->controller()),
238 Details<ExternalTabContainer>(this)); 239 Details<ExternalTabContainer>(this));
239 240
240 tab_contents_.reset(NULL); 241 tab_contents_.reset(NULL);
241 } 242 }
242 243
243 if (focus_manager_) { 244 if (focus_manager_) {
244 focus_manager_->UnregisterAccelerators(this); 245 focus_manager_->UnregisterAccelerators(this);
245 focus_manager_ = NULL; 246 focus_manager_ = NULL;
246 } 247 }
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 const std::string& target) { 695 const std::string& target) {
695 if (automation_) { 696 if (automation_) {
696 automation_->Send(new AutomationMsg_ForwardMessageToExternalHost( 697 automation_->Send(new AutomationMsg_ForwardMessageToExternalHost(
697 tab_handle_, message, origin, target)); 698 tab_handle_, message, origin, target));
698 } 699 }
699 } 700 }
700 701
701 //////////////////////////////////////////////////////////////////////////////// 702 ////////////////////////////////////////////////////////////////////////////////
702 // ExternalTabContainer, NotificationObserver implementation: 703 // ExternalTabContainer, NotificationObserver implementation:
703 704
704 void ExternalTabContainer::Observe(NotificationType type, 705 void ExternalTabContainer::Observe(int type,
705 const NotificationSource& source, 706 const NotificationSource& source,
706 const NotificationDetails& details) { 707 const NotificationDetails& details) {
707 if (!automation_) 708 if (!automation_)
708 return; 709 return;
709 710
710 static const int kHttpClientErrorStart = 400; 711 static const int kHttpClientErrorStart = 400;
711 static const int kHttpServerErrorEnd = 510; 712 static const int kHttpServerErrorEnd = 510;
712 713
713 switch (type.value) { 714 switch (type) {
714 case NotificationType::LOAD_STOP: { 715 case content::NOTIFICATION_LOAD_STOP: {
715 const LoadNotificationDetails* load = 716 const LoadNotificationDetails* load =
716 Details<LoadNotificationDetails>(details).ptr(); 717 Details<LoadNotificationDetails>(details).ptr();
717 if (load != NULL && PageTransition::IsMainFrame(load->origin())) { 718 if (load != NULL && PageTransition::IsMainFrame(load->origin())) {
718 TRACE_EVENT_END_ETW("ExternalTabContainer::Navigate", 0, 719 TRACE_EVENT_END_ETW("ExternalTabContainer::Navigate", 0,
719 load->url().spec()); 720 load->url().spec());
720 automation_->Send(new AutomationMsg_TabLoaded(tab_handle_, 721 automation_->Send(new AutomationMsg_TabLoaded(tab_handle_,
721 load->url())); 722 load->url()));
722 } 723 }
723 break; 724 break;
724 } 725 }
725 case NotificationType::NAV_ENTRY_COMMITTED: { 726 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: {
726 if (ignore_next_load_notification_) { 727 if (ignore_next_load_notification_) {
727 ignore_next_load_notification_ = false; 728 ignore_next_load_notification_ = false;
728 return; 729 return;
729 } 730 }
730 731
731 const content::LoadCommittedDetails* commit = 732 const content::LoadCommittedDetails* commit =
732 Details<content::LoadCommittedDetails>(details).ptr(); 733 Details<content::LoadCommittedDetails>(details).ptr();
733 734
734 if (commit->http_status_code >= kHttpClientErrorStart && 735 if (commit->http_status_code >= kHttpClientErrorStart &&
735 commit->http_status_code <= kHttpServerErrorEnd) { 736 commit->http_status_code <= kHttpServerErrorEnd) {
736 automation_->Send(new AutomationMsg_NavigationFailed( 737 automation_->Send(new AutomationMsg_NavigationFailed(
737 tab_handle_, commit->http_status_code, commit->entry->url())); 738 tab_handle_, commit->http_status_code, commit->entry->url()));
738 739
739 ignore_next_load_notification_ = true; 740 ignore_next_load_notification_ = true;
740 } else { 741 } else {
741 NavigationInfo navigation_info; 742 NavigationInfo navigation_info;
742 // When the previous entry index is invalid, it will be -1, which 743 // When the previous entry index is invalid, it will be -1, which
743 // will still make the computation come out right (navigating to the 744 // will still make the computation come out right (navigating to the
744 // 0th entry will be +1). 745 // 0th entry will be +1).
745 if (InitNavigationInfo(&navigation_info, commit->type, 746 if (InitNavigationInfo(&navigation_info, commit->type,
746 commit->previous_entry_index - 747 commit->previous_entry_index -
747 tab_contents_->controller().last_committed_entry_index())) 748 tab_contents_->controller().last_committed_entry_index()))
748 automation_->Send(new AutomationMsg_DidNavigate(tab_handle_, 749 automation_->Send(new AutomationMsg_DidNavigate(tab_handle_,
749 navigation_info)); 750 navigation_info));
750 } 751 }
751 break; 752 break;
752 } 753 }
753 case NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR: { 754 case content::NOTIFICATION_FAIL_PROVISIONAL_LOAD_WITH_ERROR: {
754 const ProvisionalLoadDetails* load_details = 755 const ProvisionalLoadDetails* load_details =
755 Details<ProvisionalLoadDetails>(details).ptr(); 756 Details<ProvisionalLoadDetails>(details).ptr();
756 automation_->Send(new AutomationMsg_NavigationFailed( 757 automation_->Send(new AutomationMsg_NavigationFailed(
757 tab_handle_, load_details->error_code(), load_details->url())); 758 tab_handle_, load_details->error_code(), load_details->url()));
758 759
759 ignore_next_load_notification_ = true; 760 ignore_next_load_notification_ = true;
760 break; 761 break;
761 } 762 }
762 case NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB: { 763 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB: {
763 if (load_requests_via_automation_) { 764 if (load_requests_via_automation_) {
764 RenderViewHost* rvh = Details<RenderViewHost>(details).ptr(); 765 RenderViewHost* rvh = Details<RenderViewHost>(details).ptr();
765 RegisterRenderViewHostForAutomation(rvh, false); 766 RegisterRenderViewHostForAutomation(rvh, false);
766 } 767 }
767 break; 768 break;
768 } 769 }
769 case NotificationType::RENDER_VIEW_HOST_DELETED: { 770 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: {
770 if (load_requests_via_automation_) { 771 if (load_requests_via_automation_) {
771 RenderViewHost* rvh = Source<RenderViewHost>(source).ptr(); 772 RenderViewHost* rvh = Source<RenderViewHost>(source).ptr();
772 UnregisterRenderViewHost(rvh); 773 UnregisterRenderViewHost(rvh);
773 } 774 }
774 break; 775 break;
775 } 776 }
776 default: 777 default:
777 NOTREACHED(); 778 NOTREACHED();
778 } 779 }
779 } 780 }
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 1123
1123 if (disposition == CURRENT_TAB) { 1124 if (disposition == CURRENT_TAB) {
1124 DCHECK(route_all_top_level_navigations_); 1125 DCHECK(route_all_top_level_navigations_);
1125 disposition = NEW_FOREGROUND_TAB; 1126 disposition = NEW_FOREGROUND_TAB;
1126 } 1127 }
1127 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, 1128 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition,
1128 transition); 1129 transition);
1129 // support only one navigation for a dummy tab before it is killed. 1130 // support only one navigation for a dummy tab before it is killed.
1130 ::DestroyWindow(GetNativeView()); 1131 ::DestroyWindow(GetNativeView());
1131 } 1132 }
OLDNEW
« no previous file with comments | « chrome/browser/external_tab_container_win.h ('k') | chrome/browser/favicon/favicon_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698