OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/automation/automation_browser_tracker.h" | 13 #include "chrome/browser/automation/automation_browser_tracker.h" |
14 #include "chrome/browser/automation/automation_tab_tracker.h" | 14 #include "chrome/browser/automation/automation_tab_tracker.h" |
15 #include "chrome/browser/automation/automation_window_tracker.h" | 15 #include "chrome/browser/automation/automation_window_tracker.h" |
16 #include "chrome/browser/external_tab/external_tab_container.h" | 16 #include "chrome/browser/external_tab/external_tab_container.h" |
17 #include "chrome/browser/printing/print_view_manager.h" | 17 #include "chrome/browser/printing/print_view_manager.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/sessions/session_tab_helper.h" | 19 #include "chrome/browser/sessions/session_tab_helper.h" |
20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
22 #include "chrome/common/automation_messages.h" | 22 #include "chrome/common/automation_messages.h" |
23 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
24 #include "content/public/browser/navigation_controller.h" | 24 #include "content/public/browser/navigation_controller.h" |
25 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_contents_view.h" |
27 #include "content/public/common/page_zoom.h" | 28 #include "content/public/common/page_zoom.h" |
28 #include "ui/base/keycodes/keyboard_codes.h" | 29 #include "ui/base/keycodes/keyboard_codes.h" |
29 #include "ui/views/focus/accelerator_handler.h" | 30 #include "ui/views/focus/accelerator_handler.h" |
30 #include "ui/views/widget/root_view.h" | 31 #include "ui/views/widget/root_view.h" |
31 | 32 |
32 using content::NavigationController; | 33 using content::NavigationController; |
33 using content::RenderViewHost; | 34 using content::RenderViewHost; |
34 using content::WebContents; | 35 using content::WebContents; |
35 | 36 |
36 void AutomationProvider::CreateExternalTab( | 37 void AutomationProvider::CreateExternalTab( |
(...skipping 19 matching lines...) Expand all Loading... |
56 settings.handle_top_level_requests, NULL, settings.initial_url, | 57 settings.handle_top_level_requests, NULL, settings.initial_url, |
57 settings.referrer, settings.infobars_enabled, | 58 settings.referrer, settings.infobars_enabled, |
58 settings.route_all_top_level_navigations); | 59 settings.route_all_top_level_navigations); |
59 | 60 |
60 if (AddExternalTab(external_tab_container)) { | 61 if (AddExternalTab(external_tab_container)) { |
61 WebContents* web_contents = external_tab_container->GetWebContents(); | 62 WebContents* web_contents = external_tab_container->GetWebContents(); |
62 SessionTabHelper* session_tab_helper = | 63 SessionTabHelper* session_tab_helper = |
63 SessionTabHelper::FromWebContents(web_contents); | 64 SessionTabHelper::FromWebContents(web_contents); |
64 *tab_handle = external_tab_container->GetTabHandle(); | 65 *tab_handle = external_tab_container->GetTabHandle(); |
65 *tab_container_window = external_tab_container->GetExternalTabNativeView(); | 66 *tab_container_window = external_tab_container->GetExternalTabNativeView(); |
66 *tab_window = web_contents->GetNativeView(); | 67 *tab_window = web_contents->GetView()->GetNativeView(); |
67 *session_id = session_tab_helper->session_id().id(); | 68 *session_id = session_tab_helper->session_id().id(); |
68 } else { | 69 } else { |
69 external_tab_container->Uninitialize(); | 70 external_tab_container->Uninitialize(); |
70 } | 71 } |
71 | 72 |
72 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, ""); | 73 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, ""); |
73 } | 74 } |
74 | 75 |
75 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { | 76 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { |
76 DCHECK(external_tab != NULL); | 77 DCHECK(external_tab != NULL); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 112 |
112 printing::PrintViewManager* print_view_manager = | 113 printing::PrintViewManager* print_view_manager = |
113 printing::PrintViewManager::FromWebContents(web_contents); | 114 printing::PrintViewManager::FromWebContents(web_contents); |
114 print_view_manager->PrintNow(); | 115 print_view_manager->PrintNow(); |
115 } | 116 } |
116 | 117 |
117 ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { | 118 ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { |
118 if (tab_tracker_->ContainsHandle(handle)) { | 119 if (tab_tracker_->ContainsHandle(handle)) { |
119 NavigationController* tab = tab_tracker_->GetResource(handle); | 120 NavigationController* tab = tab_tracker_->GetResource(handle); |
120 return ExternalTabContainer::GetContainerForTab( | 121 return ExternalTabContainer::GetContainerForTab( |
121 tab->GetWebContents()->GetNativeView()); | 122 tab->GetWebContents()->GetView()->GetNativeView()); |
122 } | 123 } |
123 | 124 |
124 return NULL; | 125 return NULL; |
125 } | 126 } |
126 | 127 |
127 void AutomationProvider::OnTabReposition( | 128 void AutomationProvider::OnTabReposition( |
128 int tab_handle, const Reposition_Params& params) { | 129 int tab_handle, const Reposition_Params& params) { |
129 if (!tab_tracker_->ContainsHandle(tab_handle)) | 130 if (!tab_tracker_->ContainsHandle(tab_handle)) |
130 return; | 131 return; |
131 | 132 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 185 |
185 if (allow && AddExternalTab(external_tab_container)) { | 186 if (allow && AddExternalTab(external_tab_container)) { |
186 external_tab_container->Reinitialize(this, | 187 external_tab_container->Reinitialize(this, |
187 automation_resource_message_filter_, | 188 automation_resource_message_filter_, |
188 parent_window); | 189 parent_window); |
189 WebContents* web_contents = external_tab_container->GetWebContents(); | 190 WebContents* web_contents = external_tab_container->GetWebContents(); |
190 SessionTabHelper* session_tab_helper = | 191 SessionTabHelper* session_tab_helper = |
191 SessionTabHelper::FromWebContents(web_contents); | 192 SessionTabHelper::FromWebContents(web_contents); |
192 *tab_handle = external_tab_container->GetTabHandle(); | 193 *tab_handle = external_tab_container->GetTabHandle(); |
193 *tab_container_window = external_tab_container->GetExternalTabNativeView(); | 194 *tab_container_window = external_tab_container->GetExternalTabNativeView(); |
194 *tab_window = web_contents->GetNativeView(); | 195 *tab_window = web_contents->GetView()->GetNativeView(); |
195 *session_id = session_tab_helper->session_id().id(); | 196 *session_id = session_tab_helper->session_id().id(); |
196 } else { | 197 } else { |
197 external_tab_container->Uninitialize(); | 198 external_tab_container->Uninitialize(); |
198 } | 199 } |
199 | 200 |
200 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, ""); | 201 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, ""); |
201 } | 202 } |
202 | 203 |
203 void AutomationProvider::OnBrowserMoved(int tab_handle) { | 204 void AutomationProvider::OnBrowserMoved(int tab_handle) { |
204 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); | 205 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { | 259 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { |
259 if (tab_tracker_->ContainsHandle(handle)) { | 260 if (tab_tracker_->ContainsHandle(handle)) { |
260 NavigationController* tab = tab_tracker_->GetResource(handle); | 261 NavigationController* tab = tab_tracker_->GetResource(handle); |
261 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) { | 262 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) { |
262 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost(); | 263 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost(); |
263 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level); | 264 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level); |
264 host->Zoom(zoom); | 265 host->Zoom(zoom); |
265 } | 266 } |
266 } | 267 } |
267 } | 268 } |
OLD | NEW |