| 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/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/automation/automation_browser_tracker.h" | 10 #include "chrome/browser/automation/automation_browser_tracker.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } else { | 226 } else { |
| 227 AutomationMsg_WindowDrag::WriteReplyParams(reply_message, false); | 227 AutomationMsg_WindowDrag::WriteReplyParams(reply_message, false); |
| 228 Send(reply_message); | 228 Send(reply_message); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 void AutomationProvider::CreateExternalTab( | 232 void AutomationProvider::CreateExternalTab( |
| 233 const ExternalTabSettings& settings, | 233 const ExternalTabSettings& settings, |
| 234 gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, | 234 gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, |
| 235 int* tab_handle, int* session_id) { | 235 int* tab_handle, int* session_id) { |
| 236 TRACE_EVENT_BEGIN("AutomationProvider::CreateExternalTab", 0, ""); | 236 TRACE_EVENT_BEGIN_LEGACY("AutomationProvider::CreateExternalTab", 0, ""); |
| 237 | 237 |
| 238 *tab_handle = 0; | 238 *tab_handle = 0; |
| 239 *tab_container_window = NULL; | 239 *tab_container_window = NULL; |
| 240 *tab_window = NULL; | 240 *tab_window = NULL; |
| 241 *session_id = -1; | 241 *session_id = -1; |
| 242 scoped_refptr<ExternalTabContainer> external_tab_container = | 242 scoped_refptr<ExternalTabContainer> external_tab_container = |
| 243 new ExternalTabContainer(this, automation_resource_message_filter_); | 243 new ExternalTabContainer(this, automation_resource_message_filter_); |
| 244 | 244 |
| 245 Profile* profile = settings.is_off_the_record ? | 245 Profile* profile = settings.is_off_the_record ? |
| 246 profile_->GetOffTheRecordProfile() : profile_; | 246 profile_->GetOffTheRecordProfile() : profile_; |
| 247 | 247 |
| 248 // When the ExternalTabContainer window is created we grab a reference on it | 248 // When the ExternalTabContainer window is created we grab a reference on it |
| 249 // which is released when the window is destroyed. | 249 // which is released when the window is destroyed. |
| 250 external_tab_container->Init(profile, settings.parent, settings.dimensions, | 250 external_tab_container->Init(profile, settings.parent, settings.dimensions, |
| 251 settings.style, settings.load_requests_via_automation, | 251 settings.style, settings.load_requests_via_automation, |
| 252 settings.handle_top_level_requests, NULL, settings.initial_url, | 252 settings.handle_top_level_requests, NULL, settings.initial_url, |
| 253 settings.referrer, settings.infobars_enabled, | 253 settings.referrer, settings.infobars_enabled, |
| 254 settings.route_all_top_level_navigations); | 254 settings.route_all_top_level_navigations); |
| 255 | 255 |
| 256 if (AddExternalTab(external_tab_container)) { | 256 if (AddExternalTab(external_tab_container)) { |
| 257 TabContents* tab_contents = external_tab_container->tab_contents(); | 257 TabContents* tab_contents = external_tab_container->tab_contents(); |
| 258 *tab_handle = external_tab_container->tab_handle(); | 258 *tab_handle = external_tab_container->tab_handle(); |
| 259 *tab_container_window = external_tab_container->GetNativeView(); | 259 *tab_container_window = external_tab_container->GetNativeView(); |
| 260 *tab_window = tab_contents->GetNativeView(); | 260 *tab_window = tab_contents->GetNativeView(); |
| 261 *session_id = tab_contents->controller().session_id().id(); | 261 *session_id = tab_contents->controller().session_id().id(); |
| 262 } else { | 262 } else { |
| 263 external_tab_container->Uninitialize(); | 263 external_tab_container->Uninitialize(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 TRACE_EVENT_END("AutomationProvider::CreateExternalTab", 0, ""); | 266 TRACE_EVENT_END_LEGACY("AutomationProvider::CreateExternalTab", 0, ""); |
| 267 } | 267 } |
| 268 | 268 |
| 269 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { | 269 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { |
| 270 DCHECK(external_tab != NULL); | 270 DCHECK(external_tab != NULL); |
| 271 | 271 |
| 272 TabContents* tab_contents = external_tab->tab_contents(); | 272 TabContents* tab_contents = external_tab->tab_contents(); |
| 273 if (tab_contents) { | 273 if (tab_contents) { |
| 274 int tab_handle = tab_tracker_->Add(&tab_contents->controller()); | 274 int tab_handle = tab_tracker_->Add(&tab_contents->controller()); |
| 275 external_tab->SetTabHandle(tab_handle); | 275 external_tab->SetTabHandle(tab_handle); |
| 276 return true; | 276 return true; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 } | 366 } |
| 367 | 367 |
| 368 void AutomationProvider::ConnectExternalTab( | 368 void AutomationProvider::ConnectExternalTab( |
| 369 uint64 cookie, | 369 uint64 cookie, |
| 370 bool allow, | 370 bool allow, |
| 371 gfx::NativeWindow parent_window, | 371 gfx::NativeWindow parent_window, |
| 372 gfx::NativeWindow* tab_container_window, | 372 gfx::NativeWindow* tab_container_window, |
| 373 gfx::NativeWindow* tab_window, | 373 gfx::NativeWindow* tab_window, |
| 374 int* tab_handle, | 374 int* tab_handle, |
| 375 int* session_id) { | 375 int* session_id) { |
| 376 TRACE_EVENT_BEGIN("AutomationProvider::ConnectExternalTab", 0, ""); | 376 TRACE_EVENT_BEGIN_LEGACY("AutomationProvider::ConnectExternalTab", 0, ""); |
| 377 | 377 |
| 378 *tab_handle = 0; | 378 *tab_handle = 0; |
| 379 *tab_container_window = NULL; | 379 *tab_container_window = NULL; |
| 380 *tab_window = NULL; | 380 *tab_window = NULL; |
| 381 *session_id = -1; | 381 *session_id = -1; |
| 382 | 382 |
| 383 scoped_refptr<ExternalTabContainer> external_tab_container = | 383 scoped_refptr<ExternalTabContainer> external_tab_container = |
| 384 ExternalTabContainer::RemovePendingTab(static_cast<uintptr_t>(cookie)); | 384 ExternalTabContainer::RemovePendingTab(static_cast<uintptr_t>(cookie)); |
| 385 if (!external_tab_container.get()) { | 385 if (!external_tab_container.get()) { |
| 386 NOTREACHED(); | 386 NOTREACHED(); |
| 387 return; | 387 return; |
| 388 } | 388 } |
| 389 | 389 |
| 390 if (allow && AddExternalTab(external_tab_container)) { | 390 if (allow && AddExternalTab(external_tab_container)) { |
| 391 external_tab_container->Reinitialize(this, | 391 external_tab_container->Reinitialize(this, |
| 392 automation_resource_message_filter_, | 392 automation_resource_message_filter_, |
| 393 parent_window); | 393 parent_window); |
| 394 TabContents* tab_contents = external_tab_container->tab_contents(); | 394 TabContents* tab_contents = external_tab_container->tab_contents(); |
| 395 *tab_handle = external_tab_container->tab_handle(); | 395 *tab_handle = external_tab_container->tab_handle(); |
| 396 *tab_container_window = external_tab_container->GetNativeView(); | 396 *tab_container_window = external_tab_container->GetNativeView(); |
| 397 *tab_window = tab_contents->GetNativeView(); | 397 *tab_window = tab_contents->GetNativeView(); |
| 398 *session_id = tab_contents->controller().session_id().id(); | 398 *session_id = tab_contents->controller().session_id().id(); |
| 399 } else { | 399 } else { |
| 400 external_tab_container->Uninitialize(); | 400 external_tab_container->Uninitialize(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 TRACE_EVENT_END("AutomationProvider::ConnectExternalTab", 0, ""); | 403 TRACE_EVENT_END_LEGACY("AutomationProvider::ConnectExternalTab", 0, ""); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void AutomationProvider::SetEnableExtensionAutomation( | 406 void AutomationProvider::SetEnableExtensionAutomation( |
| 407 int tab_handle, | 407 int tab_handle, |
| 408 const std::vector<std::string>& functions_enabled) { | 408 const std::vector<std::string>& functions_enabled) { |
| 409 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); | 409 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); |
| 410 if (external_tab) { | 410 if (external_tab) { |
| 411 external_tab->SetEnableExtensionAutomation(functions_enabled); | 411 external_tab->SetEnableExtensionAutomation(functions_enabled); |
| 412 } else { | 412 } else { |
| 413 // Tab must exist, and must be an external tab so that its | 413 // Tab must exist, and must be an external tab so that its |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 | 533 |
| 534 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { | 534 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { |
| 535 if (tab_tracker_->ContainsHandle(handle)) { | 535 if (tab_tracker_->ContainsHandle(handle)) { |
| 536 NavigationController* tab = tab_tracker_->GetResource(handle); | 536 NavigationController* tab = tab_tracker_->GetResource(handle); |
| 537 if (tab->tab_contents() && tab->tab_contents()->render_view_host()) { | 537 if (tab->tab_contents() && tab->tab_contents()->render_view_host()) { |
| 538 tab->tab_contents()->render_view_host()->Zoom( | 538 tab->tab_contents()->render_view_host()->Zoom( |
| 539 static_cast<PageZoom::Function>(zoom_level)); | 539 static_cast<PageZoom::Function>(zoom_level)); |
| 540 } | 540 } |
| 541 } | 541 } |
| 542 } | 542 } |
| OLD | NEW |