| 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/restore_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/browser/ui/tab_contents/tab_contents.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 23 #include "chrome/common/automation_messages.h" | 23 #include "chrome/common/automation_messages.h" |
| 24 #include "chrome/common/render_messages.h" | 24 #include "chrome/common/render_messages.h" |
| 25 #include "content/public/browser/navigation_controller.h" | 25 #include "content/public/browser/navigation_controller.h" |
| 26 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/common/page_zoom.h" | 28 #include "content/public/common/page_zoom.h" |
| 29 #include "ui/base/keycodes/keyboard_codes.h" | 29 #include "ui/base/keycodes/keyboard_codes.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 settings.handle_top_level_requests, NULL, settings.initial_url, | 206 settings.handle_top_level_requests, NULL, settings.initial_url, |
| 207 settings.referrer, settings.infobars_enabled, | 207 settings.referrer, settings.infobars_enabled, |
| 208 settings.route_all_top_level_navigations); | 208 settings.route_all_top_level_navigations); |
| 209 | 209 |
| 210 if (AddExternalTab(external_tab_container)) { | 210 if (AddExternalTab(external_tab_container)) { |
| 211 WebContents* web_contents = external_tab_container->GetWebContents(); | 211 WebContents* web_contents = external_tab_container->GetWebContents(); |
| 212 *tab_handle = external_tab_container->GetTabHandle(); | 212 *tab_handle = external_tab_container->GetTabHandle(); |
| 213 *tab_container_window = external_tab_container->GetExternalTabNativeView(); | 213 *tab_container_window = external_tab_container->GetExternalTabNativeView(); |
| 214 *tab_window = web_contents->GetNativeView(); | 214 *tab_window = web_contents->GetNativeView(); |
| 215 *session_id = external_tab_container->GetTabContents()-> | 215 *session_id = external_tab_container->GetTabContents()-> |
| 216 restore_tab_helper()->session_id().id(); | 216 session_tab_helper()->session_id().id(); |
| 217 } else { | 217 } else { |
| 218 external_tab_container->Uninitialize(); | 218 external_tab_container->Uninitialize(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, ""); | 221 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, ""); |
| 222 } | 222 } |
| 223 | 223 |
| 224 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { | 224 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { |
| 225 DCHECK(external_tab != NULL); | 225 DCHECK(external_tab != NULL); |
| 226 | 226 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 345 |
| 346 if (allow && AddExternalTab(external_tab_container)) { | 346 if (allow && AddExternalTab(external_tab_container)) { |
| 347 external_tab_container->Reinitialize(this, | 347 external_tab_container->Reinitialize(this, |
| 348 automation_resource_message_filter_, | 348 automation_resource_message_filter_, |
| 349 parent_window); | 349 parent_window); |
| 350 WebContents* tab_contents = external_tab_container->GetWebContents(); | 350 WebContents* tab_contents = external_tab_container->GetWebContents(); |
| 351 *tab_handle = external_tab_container->GetTabHandle(); | 351 *tab_handle = external_tab_container->GetTabHandle(); |
| 352 *tab_container_window = external_tab_container->GetExternalTabNativeView(); | 352 *tab_container_window = external_tab_container->GetExternalTabNativeView(); |
| 353 *tab_window = tab_contents->GetNativeView(); | 353 *tab_window = tab_contents->GetNativeView(); |
| 354 *session_id = external_tab_container->GetTabContents()-> | 354 *session_id = external_tab_container->GetTabContents()-> |
| 355 restore_tab_helper()->session_id().id(); | 355 session_tab_helper()->session_id().id(); |
| 356 } else { | 356 } else { |
| 357 external_tab_container->Uninitialize(); | 357 external_tab_container->Uninitialize(); |
| 358 } | 358 } |
| 359 | 359 |
| 360 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, ""); | 360 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, ""); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void AutomationProvider::OnBrowserMoved(int tab_handle) { | 363 void AutomationProvider::OnBrowserMoved(int tab_handle) { |
| 364 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); | 364 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); |
| 365 if (!external_tab) { | 365 if (!external_tab) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { | 418 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { |
| 419 if (tab_tracker_->ContainsHandle(handle)) { | 419 if (tab_tracker_->ContainsHandle(handle)) { |
| 420 NavigationController* tab = tab_tracker_->GetResource(handle); | 420 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 421 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) { | 421 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) { |
| 422 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost(); | 422 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost(); |
| 423 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level); | 423 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level); |
| 424 host->Zoom(zoom); | 424 host->Zoom(zoom); |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 } | 427 } |
| OLD | NEW |