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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/win/win_util.h" | 13 #include "base/win/win_util.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/app/chrome_dll_resource.h" | 15 #include "chrome/app/chrome_dll_resource.h" |
16 #include "chrome/browser/automation/automation_extension_function.h" | |
17 #include "chrome/browser/automation/automation_provider.h" | 16 #include "chrome/browser/automation/automation_provider.h" |
18 #include "chrome/browser/browser_window.h" | 17 #include "chrome/browser/browser_window.h" |
19 #include "chrome/browser/debugger/devtools_manager.h" | 18 #include "chrome/browser/debugger/devtools_manager.h" |
20 #include "chrome/browser/debugger/devtools_toggle_action.h" | 19 #include "chrome/browser/debugger/devtools_toggle_action.h" |
21 #include "chrome/browser/google/google_util.h" | 20 #include "chrome/browser/google/google_util.h" |
22 #include "chrome/browser/history/history_types.h" | 21 #include "chrome/browser/history/history_types.h" |
23 #include "chrome/browser/load_notification_details.h" | 22 #include "chrome/browser/load_notification_details.h" |
24 #include "chrome/browser/page_info_window.h" | 23 #include "chrome/browser/page_info_window.h" |
25 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 ExternalTabContainer::ExternalTabContainer( | 87 ExternalTabContainer::ExternalTabContainer( |
89 AutomationProvider* automation, AutomationResourceMessageFilter* filter) | 88 AutomationProvider* automation, AutomationResourceMessageFilter* filter) |
90 : automation_(automation), | 89 : automation_(automation), |
91 tab_contents_container_(NULL), | 90 tab_contents_container_(NULL), |
92 tab_handle_(0), | 91 tab_handle_(0), |
93 ignore_next_load_notification_(false), | 92 ignore_next_load_notification_(false), |
94 automation_resource_message_filter_(filter), | 93 automation_resource_message_filter_(filter), |
95 load_requests_via_automation_(false), | 94 load_requests_via_automation_(false), |
96 handle_top_level_requests_(false), | 95 handle_top_level_requests_(false), |
97 external_method_factory_(this), | 96 external_method_factory_(this), |
98 enabled_extension_automation_(false), | |
99 pending_(false), | 97 pending_(false), |
100 infobars_enabled_(true), | 98 infobars_enabled_(true), |
101 focus_manager_(NULL), | 99 focus_manager_(NULL), |
102 external_tab_view_(NULL), | 100 external_tab_view_(NULL), |
103 unload_reply_message_(NULL), | 101 unload_reply_message_(NULL), |
104 route_all_top_level_navigations_(false), | 102 route_all_top_level_navigations_(false), |
105 is_popup_window_(false) { | 103 is_popup_window_(false) { |
106 } | 104 } |
107 | 105 |
108 ExternalTabContainer::~ExternalTabContainer() { | 106 ExternalTabContainer::~ExternalTabContainer() { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 SetParent(GetNativeView(), parent); | 202 SetParent(GetNativeView(), parent); |
205 | 203 |
206 ::ShowWindow(tab_contents_->tab_contents()->GetNativeView(), SW_SHOWNA); | 204 ::ShowWindow(tab_contents_->tab_contents()->GetNativeView(), SW_SHOWNA); |
207 | 205 |
208 LoadAccelerators(); | 206 LoadAccelerators(); |
209 SetupExternalTabView(); | 207 SetupExternalTabView(); |
210 return true; | 208 return true; |
211 } | 209 } |
212 | 210 |
213 void ExternalTabContainer::Uninitialize() { | 211 void ExternalTabContainer::Uninitialize() { |
214 if (enabled_extension_automation_) { | |
215 AutomationExtensionFunction::Disable(); | |
216 } | |
217 | |
218 registrar_.RemoveAll(); | 212 registrar_.RemoveAll(); |
219 if (tab_contents_.get()) { | 213 if (tab_contents_.get()) { |
220 UnregisterRenderViewHost(tab_contents_->render_view_host()); | 214 UnregisterRenderViewHost(tab_contents_->render_view_host()); |
221 | 215 |
222 if (GetRootView()) { | 216 if (GetRootView()) { |
223 GetRootView()->RemoveAllChildViews(true); | 217 GetRootView()->RemoveAllChildViews(true); |
224 } | 218 } |
225 | 219 |
226 NotificationService::current()->Notify( | 220 NotificationService::current()->Notify( |
227 NotificationType::EXTERNAL_TAB_CLOSED, | 221 NotificationType::EXTERNAL_TAB_CLOSED, |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 scoped_refptr<ExternalTabContainer> container = (*index).second; | 909 scoped_refptr<ExternalTabContainer> container = (*index).second; |
916 pending_tabs.erase(index); | 910 pending_tabs.erase(index); |
917 return container; | 911 return container; |
918 } | 912 } |
919 | 913 |
920 NOTREACHED() << "Failed to find ExternalTabContainer for cookie: " | 914 NOTREACHED() << "Failed to find ExternalTabContainer for cookie: " |
921 << cookie; | 915 << cookie; |
922 return NULL; | 916 return NULL; |
923 } | 917 } |
924 | 918 |
925 void ExternalTabContainer::SetEnableExtensionAutomation( | |
926 const std::vector<std::string>& functions_enabled) { | |
927 if (!functions_enabled.empty()) { | |
928 if (!tab_contents_.get()) { | |
929 NOTREACHED() << "Being invoked via tab so should have TabContents"; | |
930 return; | |
931 } | |
932 | |
933 AutomationExtensionFunction::Enable(tab_contents_->tab_contents(), | |
934 functions_enabled); | |
935 enabled_extension_automation_ = true; | |
936 } else { | |
937 AutomationExtensionFunction::Disable(); | |
938 enabled_extension_automation_ = false; | |
939 } | |
940 } | |
941 | |
942 void ExternalTabContainer::InfoBarContainerHeightChanged(bool is_animating) { | 919 void ExternalTabContainer::InfoBarContainerHeightChanged(bool is_animating) { |
943 if (external_tab_view_) | 920 if (external_tab_view_) |
944 external_tab_view_->Layout(); | 921 external_tab_view_->Layout(); |
945 } | 922 } |
946 | 923 |
947 // ExternalTabContainer instances do not have a window. | 924 // ExternalTabContainer instances do not have a window. |
948 views::Window* ExternalTabContainer::GetWindow() { | 925 views::Window* ExternalTabContainer::GetWindow() { |
949 return NULL; | 926 return NULL; |
950 } | 927 } |
951 | 928 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 | 1107 |
1131 if (disposition == CURRENT_TAB) { | 1108 if (disposition == CURRENT_TAB) { |
1132 DCHECK(route_all_top_level_navigations_); | 1109 DCHECK(route_all_top_level_navigations_); |
1133 disposition = NEW_FOREGROUND_TAB; | 1110 disposition = NEW_FOREGROUND_TAB; |
1134 } | 1111 } |
1135 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, | 1112 ExternalTabContainer::OpenURLFromTab(source, url, referrer, disposition, |
1136 transition); | 1113 transition); |
1137 // support only one navigation for a dummy tab before it is killed. | 1114 // support only one navigation for a dummy tab before it is killed. |
1138 ::DestroyWindow(GetNativeView()); | 1115 ::DestroyWindow(GetNativeView()); |
1139 } | 1116 } |
OLD | NEW |