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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 private: | 81 private: |
82 scoped_refptr<ExternalTabContainer> container_; | 82 scoped_refptr<ExternalTabContainer> container_; |
83 }; | 83 }; |
84 | 84 |
85 base::LazyInstance<ExternalTabContainer::PendingTabs> | 85 base::LazyInstance<ExternalTabContainer::PendingTabs> |
86 ExternalTabContainer::pending_tabs_(base::LINKER_INITIALIZED); | 86 ExternalTabContainer::pending_tabs_(base::LINKER_INITIALIZED); |
87 | 87 |
88 ExternalTabContainer::ExternalTabContainer( | 88 ExternalTabContainer::ExternalTabContainer( |
89 AutomationProvider* automation, AutomationResourceMessageFilter* filter) | 89 AutomationProvider* automation, AutomationResourceMessageFilter* filter) |
90 : automation_(automation), | 90 : views::WidgetWin(new views::Widget), |
| 91 automation_(automation), |
91 tab_contents_container_(NULL), | 92 tab_contents_container_(NULL), |
92 tab_handle_(0), | 93 tab_handle_(0), |
93 ignore_next_load_notification_(false), | 94 ignore_next_load_notification_(false), |
94 automation_resource_message_filter_(filter), | 95 automation_resource_message_filter_(filter), |
95 load_requests_via_automation_(false), | 96 load_requests_via_automation_(false), |
96 handle_top_level_requests_(false), | 97 handle_top_level_requests_(false), |
97 external_method_factory_(this), | 98 external_method_factory_(this), |
98 pending_(false), | 99 pending_(false), |
99 infobars_enabled_(true), | 100 infobars_enabled_(true), |
100 focus_manager_(NULL), | 101 focus_manager_(NULL), |
(...skipping 29 matching lines...) Expand all Loading... |
130 | 131 |
131 load_requests_via_automation_ = load_requests_via_automation; | 132 load_requests_via_automation_ = load_requests_via_automation; |
132 handle_top_level_requests_ = handle_top_level_requests; | 133 handle_top_level_requests_ = handle_top_level_requests; |
133 infobars_enabled_ = infobars_enabled; | 134 infobars_enabled_ = infobars_enabled; |
134 route_all_top_level_navigations_ = route_all_top_level_navigations; | 135 route_all_top_level_navigations_ = route_all_top_level_navigations; |
135 | 136 |
136 set_window_style(WS_POPUP | WS_CLIPCHILDREN); | 137 set_window_style(WS_POPUP | WS_CLIPCHILDREN); |
137 | 138 |
138 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 139 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
139 params.bounds = bounds; | 140 params.bounds = bounds; |
| 141 params.native_widget = this; |
140 GetWidget()->Init(params); | 142 GetWidget()->Init(params); |
141 if (!IsWindow()) { | 143 if (!IsWindow()) { |
142 NOTREACHED(); | 144 NOTREACHED(); |
143 return false; | 145 return false; |
144 } | 146 } |
145 | 147 |
146 // TODO(jcampan): limit focus traversal to contents. | 148 // TODO(jcampan): limit focus traversal to contents. |
147 | 149 |
148 prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this)); | 150 prop_.reset(new ViewProp(GetNativeView(), kWindowObjectKey, this)); |
149 | 151 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 LoadAccelerators(); | 212 LoadAccelerators(); |
211 SetupExternalTabView(); | 213 SetupExternalTabView(); |
212 return true; | 214 return true; |
213 } | 215 } |
214 | 216 |
215 void ExternalTabContainer::Uninitialize() { | 217 void ExternalTabContainer::Uninitialize() { |
216 registrar_.RemoveAll(); | 218 registrar_.RemoveAll(); |
217 if (tab_contents_.get()) { | 219 if (tab_contents_.get()) { |
218 UnregisterRenderViewHost(tab_contents_->render_view_host()); | 220 UnregisterRenderViewHost(tab_contents_->render_view_host()); |
219 | 221 |
220 if (GetRootView()) { | 222 if (GetWidget()->GetRootView()) |
221 GetRootView()->RemoveAllChildViews(true); | 223 GetWidget()->GetRootView()->RemoveAllChildViews(true); |
222 } | |
223 | 224 |
224 NotificationService::current()->Notify( | 225 NotificationService::current()->Notify( |
225 NotificationType::EXTERNAL_TAB_CLOSED, | 226 NotificationType::EXTERNAL_TAB_CLOSED, |
226 Source<NavigationController>(&tab_contents_->controller()), | 227 Source<NavigationController>(&tab_contents_->controller()), |
227 Details<ExternalTabContainer>(this)); | 228 Details<ExternalTabContainer>(this)); |
228 | 229 |
229 tab_contents_.reset(NULL); | 230 tab_contents_.reset(NULL); |
230 } | 231 } |
231 | 232 |
232 if (focus_manager_) { | 233 if (focus_manager_) { |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 bool show_history) { | 565 bool show_history) { |
565 POINT cursor_pos = {0}; | 566 POINT cursor_pos = {0}; |
566 GetCursorPos(&cursor_pos); | 567 GetCursorPos(&cursor_pos); |
567 | 568 |
568 gfx::Rect bounds; | 569 gfx::Rect bounds; |
569 bounds.set_origin(gfx::Point(cursor_pos)); | 570 bounds.set_origin(gfx::Point(cursor_pos)); |
570 | 571 |
571 PageInfoBubbleView* page_info_bubble = | 572 PageInfoBubbleView* page_info_bubble = |
572 new ExternalTabPageInfoBubbleView(this, NULL, profile, url, | 573 new ExternalTabPageInfoBubbleView(this, NULL, profile, url, |
573 ssl, show_history); | 574 ssl, show_history); |
574 Bubble* bubble = Bubble::Show(this, bounds, BubbleBorder::TOP_LEFT, | 575 Bubble* bubble = Bubble::Show(GetWidget(), bounds, BubbleBorder::TOP_LEFT, |
575 page_info_bubble, page_info_bubble); | 576 page_info_bubble, page_info_bubble); |
576 page_info_bubble->set_bubble(bubble); | 577 page_info_bubble->set_bubble(bubble); |
577 } | 578 } |
578 | 579 |
579 void ExternalTabContainer::RegisterRenderViewHostForAutomation( | 580 void ExternalTabContainer::RegisterRenderViewHostForAutomation( |
580 RenderViewHost* render_view_host, bool pending_view) { | 581 RenderViewHost* render_view_host, bool pending_view) { |
581 if (render_view_host) { | 582 if (render_view_host) { |
582 AutomationResourceMessageFilter::RegisterRenderView( | 583 AutomationResourceMessageFilter::RegisterRenderView( |
583 render_view_host->process()->id(), | 584 render_view_host->process()->id(), |
584 render_view_host->routing_id(), | 585 render_view_host->routing_id(), |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 // Nothing to do in that case. | 996 // Nothing to do in that case. |
996 return; | 997 return; |
997 } | 998 } |
998 | 999 |
999 scoped_ptr<ACCEL> scoped_accelerators(new ACCEL[count]); | 1000 scoped_ptr<ACCEL> scoped_accelerators(new ACCEL[count]); |
1000 ACCEL* accelerators = scoped_accelerators.get(); | 1001 ACCEL* accelerators = scoped_accelerators.get(); |
1001 DCHECK(accelerators != NULL); | 1002 DCHECK(accelerators != NULL); |
1002 | 1003 |
1003 CopyAcceleratorTable(accelerator_table, accelerators, count); | 1004 CopyAcceleratorTable(accelerator_table, accelerators, count); |
1004 | 1005 |
1005 focus_manager_ = GetFocusManager(); | 1006 focus_manager_ = GetWidget()->GetFocusManager(); |
1006 DCHECK(focus_manager_); | 1007 DCHECK(focus_manager_); |
1007 | 1008 |
1008 // Let's fill our own accelerator table. | 1009 // Let's fill our own accelerator table. |
1009 for (int i = 0; i < count; ++i) { | 1010 for (int i = 0; i < count; ++i) { |
1010 bool alt_down = (accelerators[i].fVirt & FALT) == FALT; | 1011 bool alt_down = (accelerators[i].fVirt & FALT) == FALT; |
1011 bool ctrl_down = (accelerators[i].fVirt & FCONTROL) == FCONTROL; | 1012 bool ctrl_down = (accelerators[i].fVirt & FCONTROL) == FCONTROL; |
1012 bool shift_down = (accelerators[i].fVirt & FSHIFT) == FSHIFT; | 1013 bool shift_down = (accelerators[i].fVirt & FSHIFT) == FSHIFT; |
1013 views::Accelerator accelerator( | 1014 views::Accelerator accelerator( |
1014 static_cast<ui::KeyboardCode>(accelerators[i].key), | 1015 static_cast<ui::KeyboardCode>(accelerators[i].key), |
1015 shift_down, ctrl_down, alt_down); | 1016 shift_down, ctrl_down, alt_down); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 views::GridLayout::USE_PREF, | 1072 views::GridLayout::USE_PREF, |
1072 0, | 1073 0, |
1073 0); | 1074 0); |
1074 | 1075 |
1075 external_tab_view_->SetLayoutManager(layout); | 1076 external_tab_view_->SetLayoutManager(layout); |
1076 | 1077 |
1077 layout->StartRow(0, 0); | 1078 layout->StartRow(0, 0); |
1078 layout->AddView(info_bar_container); | 1079 layout->AddView(info_bar_container); |
1079 layout->StartRow(1, 0); | 1080 layout->StartRow(1, 0); |
1080 layout->AddView(tab_contents_container_); | 1081 layout->AddView(tab_contents_container_); |
1081 SetContentsView(external_tab_view_); | 1082 GetWidget()->SetContentsView(external_tab_view_); |
1082 // Note that SetTabContents must be called after AddChildView is called | 1083 // Note that SetTabContents must be called after AddChildView is called |
1083 tab_contents_container_->ChangeTabContents(tab_contents()); | 1084 tab_contents_container_->ChangeTabContents(tab_contents()); |
1084 } | 1085 } |
1085 | 1086 |
1086 TemporaryPopupExternalTabContainer::TemporaryPopupExternalTabContainer( | 1087 TemporaryPopupExternalTabContainer::TemporaryPopupExternalTabContainer( |
1087 AutomationProvider* automation, | 1088 AutomationProvider* automation, |
1088 AutomationResourceMessageFilter* filter) | 1089 AutomationResourceMessageFilter* filter) |
1089 : ExternalTabContainer(automation, filter) { | 1090 : ExternalTabContainer(automation, filter) { |
1090 } | 1091 } |
1091 | 1092 |
1092 TemporaryPopupExternalTabContainer::~TemporaryPopupExternalTabContainer() { | 1093 TemporaryPopupExternalTabContainer::~TemporaryPopupExternalTabContainer() { |
1093 DVLOG(1) << __FUNCTION__; | 1094 DVLOG(1) << __FUNCTION__; |
1094 } | 1095 } |
1095 | 1096 |
1096 void TemporaryPopupExternalTabContainer::OpenURLFromTab( | 1097 void TemporaryPopupExternalTabContainer::OpenURLFromTab( |
1097 TabContents* source, const GURL& url, const GURL& referrer, | 1098 TabContents* source, const GURL& url, const GURL& referrer, |
1098 WindowOpenDisposition disposition, PageTransition::Type transition) { | 1099 WindowOpenDisposition disposition, PageTransition::Type transition) { |
1099 if (!automation_) | 1100 if (!automation_) |
1100 return; | 1101 return; |
1101 | 1102 |
1102 if (disposition == CURRENT_TAB) { | 1103 if (disposition == CURRENT_TAB) { |
1103 DCHECK(route_all_top_level_navigations_); | 1104 DCHECK(route_all_top_level_navigations_); |
1104 disposition = NEW_FOREGROUND_TAB; | 1105 disposition = NEW_FOREGROUND_TAB; |
1105 } | 1106 } |
1106 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, | 1107 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, |
1107 transition); | 1108 transition); |
1108 // 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. |
1109 ::DestroyWindow(GetNativeView()); | 1110 ::DestroyWindow(GetNativeView()); |
1110 } | 1111 } |
OLD | NEW |