| 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/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/automation/automation_browser_tracker.h" | 12 #include "chrome/browser/automation/automation_browser_tracker.h" |
| 13 #include "chrome/browser/automation/automation_tab_tracker.h" | 13 #include "chrome/browser/automation/automation_tab_tracker.h" |
| 14 #include "chrome/browser/automation/automation_window_tracker.h" | 14 #include "chrome/browser/automation/automation_window_tracker.h" |
| 15 #include "chrome/browser/external_tab/external_tab_container_win.h" | 15 #include "chrome/browser/external_tab/external_tab_container_win.h" |
| 16 #include "chrome/browser/printing/print_view_manager.h" | 16 #include "chrome/browser/printing/print_view_manager.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/sessions/restore_tab_helper.h" | 18 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
| 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents.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/common/page_zoom.h" | 27 #include "content/public/common/page_zoom.h" |
| 28 #include "ui/base/keycodes/keyboard_codes.h" | 28 #include "ui/base/keycodes/keyboard_codes.h" |
| 29 #include "ui/ui_controls/ui_controls.h" | 29 #include "ui/ui_controls/ui_controls.h" |
| 30 #include "ui/views/focus/accelerator_handler.h" | 30 #include "ui/views/focus/accelerator_handler.h" |
| 31 #include "ui/views/widget/root_view.h" | 31 #include "ui/views/widget/root_view.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 settings.style, settings.load_requests_via_automation, | 188 settings.style, settings.load_requests_via_automation, |
| 189 settings.handle_top_level_requests, NULL, settings.initial_url, | 189 settings.handle_top_level_requests, NULL, settings.initial_url, |
| 190 settings.referrer, settings.infobars_enabled, | 190 settings.referrer, settings.infobars_enabled, |
| 191 settings.route_all_top_level_navigations); | 191 settings.route_all_top_level_navigations); |
| 192 | 192 |
| 193 if (AddExternalTab(external_tab_container)) { | 193 if (AddExternalTab(external_tab_container)) { |
| 194 WebContents* web_contents = external_tab_container->web_contents(); | 194 WebContents* web_contents = external_tab_container->web_contents(); |
| 195 *tab_handle = external_tab_container->tab_handle(); | 195 *tab_handle = external_tab_container->tab_handle(); |
| 196 *tab_container_window = external_tab_container->GetNativeView(); | 196 *tab_container_window = external_tab_container->GetNativeView(); |
| 197 *tab_window = web_contents->GetNativeView(); | 197 *tab_window = web_contents->GetNativeView(); |
| 198 *session_id = external_tab_container->tab_contents_wrapper()-> | 198 *session_id = external_tab_container->tab_contents()-> |
| 199 restore_tab_helper()->session_id().id(); | 199 restore_tab_helper()->session_id().id(); |
| 200 } else { | 200 } else { |
| 201 external_tab_container->Uninitialize(); | 201 external_tab_container->Uninitialize(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, ""); | 204 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, ""); |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { | 207 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { |
| 208 DCHECK(external_tab != NULL); | 208 DCHECK(external_tab != NULL); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 234 external_tab->FocusThroughTabTraversal(reverse, restore_focus_to_view); | 234 external_tab->FocusThroughTabTraversal(reverse, restore_focus_to_view); |
| 235 } | 235 } |
| 236 // This message expects no response. | 236 // This message expects no response. |
| 237 } | 237 } |
| 238 | 238 |
| 239 void AutomationProvider::PrintAsync(int tab_handle) { | 239 void AutomationProvider::PrintAsync(int tab_handle) { |
| 240 WebContents* web_contents = GetWebContentsForHandle(tab_handle, NULL); | 240 WebContents* web_contents = GetWebContentsForHandle(tab_handle, NULL); |
| 241 if (!web_contents) | 241 if (!web_contents) |
| 242 return; | 242 return; |
| 243 | 243 |
| 244 TabContentsWrapper* wrapper = | 244 TabContents* tab_contents = |
| 245 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | 245 TabContents::GetOwningTabContentsForWebContents(web_contents); |
| 246 wrapper->print_view_manager()->PrintNow(); | 246 tab_contents->print_view_manager()->PrintNow(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { | 249 ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { |
| 250 if (tab_tracker_->ContainsHandle(handle)) { | 250 if (tab_tracker_->ContainsHandle(handle)) { |
| 251 NavigationController* tab = tab_tracker_->GetResource(handle); | 251 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 252 return ExternalTabContainer::GetContainerForTab( | 252 return ExternalTabContainer::GetContainerForTab( |
| 253 tab->GetWebContents()->GetNativeView()); | 253 tab->GetWebContents()->GetNativeView()); |
| 254 } | 254 } |
| 255 | 255 |
| 256 return NULL; | 256 return NULL; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 | 329 |
| 330 if (allow && AddExternalTab(external_tab_container)) { | 330 if (allow && AddExternalTab(external_tab_container)) { |
| 331 external_tab_container->Reinitialize(this, | 331 external_tab_container->Reinitialize(this, |
| 332 automation_resource_message_filter_, | 332 automation_resource_message_filter_, |
| 333 parent_window); | 333 parent_window); |
| 334 WebContents* tab_contents = external_tab_container->web_contents(); | 334 WebContents* tab_contents = external_tab_container->web_contents(); |
| 335 *tab_handle = external_tab_container->tab_handle(); | 335 *tab_handle = external_tab_container->tab_handle(); |
| 336 *tab_container_window = external_tab_container->GetNativeView(); | 336 *tab_container_window = external_tab_container->GetNativeView(); |
| 337 *tab_window = tab_contents->GetNativeView(); | 337 *tab_window = tab_contents->GetNativeView(); |
| 338 *session_id = external_tab_container->tab_contents_wrapper()-> | 338 *session_id = external_tab_container->tab_contents()-> |
| 339 restore_tab_helper()->session_id().id(); | 339 restore_tab_helper()->session_id().id(); |
| 340 } else { | 340 } else { |
| 341 external_tab_container->Uninitialize(); | 341 external_tab_container->Uninitialize(); |
| 342 } | 342 } |
| 343 | 343 |
| 344 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, ""); | 344 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, ""); |
| 345 } | 345 } |
| 346 | 346 |
| 347 void AutomationProvider::OnBrowserMoved(int tab_handle) { | 347 void AutomationProvider::OnBrowserMoved(int tab_handle) { |
| 348 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); | 348 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { | 402 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { |
| 403 if (tab_tracker_->ContainsHandle(handle)) { | 403 if (tab_tracker_->ContainsHandle(handle)) { |
| 404 NavigationController* tab = tab_tracker_->GetResource(handle); | 404 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 405 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) { | 405 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) { |
| 406 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost(); | 406 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost(); |
| 407 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level); | 407 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level); |
| 408 host->Zoom(zoom); | 408 host->Zoom(zoom); |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 } | 411 } |
| OLD | NEW |