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/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 bool TestingAutomationProvider::OnMessageReceived( | 337 bool TestingAutomationProvider::OnMessageReceived( |
338 const IPC::Message& message) { | 338 const IPC::Message& message) { |
339 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 339 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
340 bool handled = true; | 340 bool handled = true; |
341 bool deserialize_success = true; | 341 bool deserialize_success = true; |
342 IPC_BEGIN_MESSAGE_MAP_EX(TestingAutomationProvider, | 342 IPC_BEGIN_MESSAGE_MAP_EX(TestingAutomationProvider, |
343 message, | 343 message, |
344 deserialize_success) | 344 deserialize_success) |
345 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseBrowser, CloseBrowser) | 345 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseBrowser, CloseBrowser) |
346 IPC_MESSAGE_HANDLER(AutomationMsg_CloseBrowserRequestAsync, | |
347 CloseBrowserAsync) | |
348 IPC_MESSAGE_HANDLER(AutomationMsg_ActivateTab, ActivateTab) | 346 IPC_MESSAGE_HANDLER(AutomationMsg_ActivateTab, ActivateTab) |
349 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendTab, AppendTab) | 347 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendTab, AppendTab) |
350 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_AppendBackgroundTab, | |
351 AppendBackgroundTab) | |
352 IPC_MESSAGE_HANDLER(AutomationMsg_GetMachPortCount, GetMachPortCount) | 348 IPC_MESSAGE_HANDLER(AutomationMsg_GetMachPortCount, GetMachPortCount) |
353 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveTabIndex, GetActiveTabIndex) | 349 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveTabIndex, GetActiveTabIndex) |
354 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseTab, CloseTab) | 350 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_CloseTab, CloseTab) |
355 IPC_MESSAGE_HANDLER(AutomationMsg_GetCookies, GetCookies) | 351 IPC_MESSAGE_HANDLER(AutomationMsg_GetCookies, GetCookies) |
356 IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) | 352 IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) |
357 IPC_MESSAGE_HANDLER(AutomationMsg_DeleteCookie, DeleteCookie) | |
358 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 353 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
359 AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, | 354 AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, |
360 NavigateToURLBlockUntilNavigationsComplete) | 355 NavigateToURLBlockUntilNavigationsComplete) |
361 IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsync, NavigationAsync) | 356 IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsync, NavigationAsync) |
362 IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsyncWithDisposition, | |
363 NavigationAsyncWithDisposition) | |
364 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) | 357 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_Reload, Reload) |
365 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, GetBrowserWindowCount) | 358 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindowCount, GetBrowserWindowCount) |
366 IPC_MESSAGE_HANDLER(AutomationMsg_NormalBrowserWindowCount, | 359 IPC_MESSAGE_HANDLER(AutomationMsg_NormalBrowserWindowCount, |
367 GetNormalBrowserWindowCount) | 360 GetNormalBrowserWindowCount) |
368 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) | 361 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserWindow, GetBrowserWindow) |
369 IPC_MESSAGE_HANDLER(AutomationMsg_GetBrowserLocale, GetBrowserLocale) | |
370 IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow, | |
371 GetLastActiveBrowserWindow) | |
372 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) | 362 IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) |
373 IPC_MESSAGE_HANDLER(AutomationMsg_FindTabbedBrowserWindow, | 363 IPC_MESSAGE_HANDLER(AutomationMsg_FindTabbedBrowserWindow, |
374 FindTabbedBrowserWindow) | 364 FindTabbedBrowserWindow) |
375 IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) | |
376 IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow) | |
377 IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowMaximized, IsWindowMaximized) | |
378 IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, | 365 IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, |
379 ExecuteBrowserCommandAsync) | 366 ExecuteBrowserCommandAsync) |
380 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, | 367 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, |
381 ExecuteBrowserCommand) | 368 ExecuteBrowserCommand) |
382 IPC_MESSAGE_HANDLER(AutomationMsg_TerminateSession, TerminateSession) | 369 IPC_MESSAGE_HANDLER(AutomationMsg_TerminateSession, TerminateSession) |
383 IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) | 370 IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) |
384 IPC_MESSAGE_HANDLER(AutomationMsg_GetWindowBounds, GetWindowBounds) | |
385 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) | 371 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) |
386 IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible) | |
387 IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) | |
388 IPC_MESSAGE_HANDLER(AutomationMsg_WindowMouseMove, WindowSimulateMouseMove) | 372 IPC_MESSAGE_HANDLER(AutomationMsg_WindowMouseMove, WindowSimulateMouseMove) |
389 IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) | 373 IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) |
390 IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) | 374 IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) |
391 IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) | 375 IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) |
392 IPC_MESSAGE_HANDLER(AutomationMsg_IsBrowserInApplicationMode, | |
393 IsBrowserInApplicationMode) | |
394 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) | 376 IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) |
395 IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessID, GetTabProcessID) | |
396 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) | 377 IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) |
397 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) | 378 IPC_MESSAGE_HANDLER(AutomationMsg_TabIndex, GetTabIndex) |
398 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) | 379 IPC_MESSAGE_HANDLER(AutomationMsg_TabURL, GetTabURL) |
399 IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) | 380 IPC_MESSAGE_HANDLER(AutomationMsg_ShelfVisibility, GetShelfVisibility) |
400 IPC_MESSAGE_HANDLER(AutomationMsg_IsFullscreen, IsFullscreen) | |
401 IPC_MESSAGE_HANDLER(AutomationMsg_IsFullscreenBubbleVisible, | |
402 GetFullscreenBubbleVisibility) | |
403 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, | 381 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_DomOperation, |
404 ExecuteJavascript) | 382 ExecuteJavascript) |
405 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_InspectElement, | |
406 HandleInspectElementRequest) | |
407 IPC_MESSAGE_HANDLER(AutomationMsg_DownloadDirectory, GetDownloadDirectory) | 383 IPC_MESSAGE_HANDLER(AutomationMsg_DownloadDirectory, GetDownloadDirectory) |
408 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType, | 384 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_OpenNewBrowserWindowOfType, |
409 OpenNewBrowserWindowOfType) | 385 OpenNewBrowserWindowOfType) |
410 IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) | 386 IPC_MESSAGE_HANDLER(AutomationMsg_WindowForBrowser, GetWindowForBrowser) |
411 IPC_MESSAGE_HANDLER(AutomationMsg_BrowserForWindow, GetBrowserForWindow) | |
412 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ShowInterstitialPage, | |
413 ShowInterstitialPage) | |
414 IPC_MESSAGE_HANDLER(AutomationMsg_HideInterstitialPage, | |
415 HideInterstitialPage) | |
416 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored, | 387 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabToBeRestored, |
417 WaitForTabToBeRestored) | 388 WaitForTabToBeRestored) |
418 IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState) | 389 IPC_MESSAGE_HANDLER(AutomationMsg_GetSecurityState, GetSecurityState) |
419 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType) | 390 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageType, GetPageType) |
420 IPC_MESSAGE_HANDLER(AutomationMsg_GetMetricEventDuration, | 391 IPC_MESSAGE_HANDLER(AutomationMsg_GetMetricEventDuration, |
421 GetMetricEventDuration) | 392 GetMetricEventDuration) |
422 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ActionOnSSLBlockingPage, | 393 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ActionOnSSLBlockingPage, |
423 ActionOnSSLBlockingPage) | 394 ActionOnSSLBlockingPage) |
424 IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) | 395 IPC_MESSAGE_HANDLER(AutomationMsg_BringBrowserToFront, BringBrowserToFront) |
425 IPC_MESSAGE_HANDLER(AutomationMsg_IsMenuCommandEnabled, | 396 IPC_MESSAGE_HANDLER(AutomationMsg_IsMenuCommandEnabled, |
426 IsMenuCommandEnabled) | 397 IsMenuCommandEnabled) |
427 IPC_MESSAGE_HANDLER(AutomationMsg_SavePage, SavePage) | |
428 IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPage, | 398 IPC_MESSAGE_HANDLER(AutomationMsg_OpenFindInPage, |
429 HandleOpenFindInPageRequest) | 399 HandleOpenFindInPageRequest) |
430 IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibility, | 400 IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowVisibility, |
431 GetFindWindowVisibility) | 401 GetFindWindowVisibility) |
432 IPC_MESSAGE_HANDLER(AutomationMsg_FindWindowLocation, | |
433 HandleFindWindowLocationRequest) | |
434 IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibility, | 402 IPC_MESSAGE_HANDLER(AutomationMsg_BookmarkBarVisibility, |
435 GetBookmarkBarVisibility) | 403 GetBookmarkBarVisibility) |
436 IPC_MESSAGE_HANDLER(AutomationMsg_GetBookmarksAsJSON, | 404 IPC_MESSAGE_HANDLER(AutomationMsg_GetBookmarksAsJSON, |
437 GetBookmarksAsJSON) | 405 GetBookmarksAsJSON) |
438 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForBookmarkModelToLoad, | 406 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForBookmarkModelToLoad, |
439 WaitForBookmarkModelToLoad) | 407 WaitForBookmarkModelToLoad) |
440 IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkGroup, | 408 IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkGroup, |
441 AddBookmarkGroup) | 409 AddBookmarkGroup) |
442 IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkURL, | 410 IPC_MESSAGE_HANDLER(AutomationMsg_AddBookmarkURL, |
443 AddBookmarkURL) | 411 AddBookmarkURL) |
444 IPC_MESSAGE_HANDLER(AutomationMsg_ReparentBookmark, | 412 IPC_MESSAGE_HANDLER(AutomationMsg_ReparentBookmark, |
445 ReparentBookmark) | 413 ReparentBookmark) |
446 IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkTitle, | 414 IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkTitle, |
447 SetBookmarkTitle) | 415 SetBookmarkTitle) |
448 IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkURL, | 416 IPC_MESSAGE_HANDLER(AutomationMsg_SetBookmarkURL, |
449 SetBookmarkURL) | 417 SetBookmarkURL) |
450 IPC_MESSAGE_HANDLER(AutomationMsg_RemoveBookmark, | 418 IPC_MESSAGE_HANDLER(AutomationMsg_RemoveBookmark, |
451 RemoveBookmark) | 419 RemoveBookmark) |
452 IPC_MESSAGE_HANDLER(AutomationMsg_GetInfoBarCount, GetInfoBarCount) | |
453 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_ClickInfoBarAccept, | |
454 ClickInfoBarAccept) | |
455 IPC_MESSAGE_HANDLER(AutomationMsg_GetLastNavigationTime, | |
456 GetLastNavigationTime) | |
457 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForNavigation, | |
458 WaitForNavigation) | |
459 IPC_MESSAGE_HANDLER(AutomationMsg_SetIntPreference, SetIntPreference) | |
460 IPC_MESSAGE_HANDLER(AutomationMsg_ShowingAppModalDialog, | |
461 GetShowingAppModalDialog) | |
462 IPC_MESSAGE_HANDLER(AutomationMsg_ClickAppModalDialogButton, | |
463 ClickAppModalDialogButton) | |
464 IPC_MESSAGE_HANDLER(AutomationMsg_SetStringPreference, SetStringPreference) | |
465 IPC_MESSAGE_HANDLER(AutomationMsg_GetBooleanPreference, | |
466 GetBooleanPreference) | |
467 IPC_MESSAGE_HANDLER(AutomationMsg_SetBooleanPreference, | |
468 SetBooleanPreference) | |
469 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 420 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
470 AutomationMsg_WaitForBrowserWindowCountToBecome, | 421 AutomationMsg_WaitForBrowserWindowCountToBecome, |
471 WaitForBrowserWindowCountToBecome) | 422 WaitForBrowserWindowCountToBecome) |
472 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 423 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
473 AutomationMsg_WaitForAppModalDialogToBeShown, | |
474 WaitForAppModalDialogToBeShown) | |
475 IPC_MESSAGE_HANDLER_DELAY_REPLY( | |
476 AutomationMsg_GoBackBlockUntilNavigationsComplete, | 424 AutomationMsg_GoBackBlockUntilNavigationsComplete, |
477 GoBackBlockUntilNavigationsComplete) | 425 GoBackBlockUntilNavigationsComplete) |
478 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 426 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
479 AutomationMsg_GoForwardBlockUntilNavigationsComplete, | 427 AutomationMsg_GoForwardBlockUntilNavigationsComplete, |
480 GoForwardBlockUntilNavigationsComplete) | 428 GoForwardBlockUntilNavigationsComplete) |
481 IPC_MESSAGE_HANDLER(AutomationMsg_WindowTitle, GetWindowTitle) | |
482 IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) | 429 IPC_MESSAGE_HANDLER(AutomationMsg_SetShelfVisibility, SetShelfVisibility) |
483 IPC_MESSAGE_HANDLER(AutomationMsg_BlockedPopupCount, GetBlockedPopupCount) | |
484 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SendJSONRequest, | 430 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_SendJSONRequest, |
485 SendJSONRequest) | 431 SendJSONRequest) |
486 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabCountToBecome, | 432 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForTabCountToBecome, |
487 WaitForTabCountToBecome) | 433 WaitForTabCountToBecome) |
488 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount, | 434 IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForInfoBarCount, |
489 WaitForInfoBarCount) | 435 WaitForInfoBarCount) |
490 IPC_MESSAGE_HANDLER(AutomationMsg_GetPageCurrentEncoding, | |
491 GetPageCurrentEncoding) | |
492 IPC_MESSAGE_HANDLER(AutomationMsg_ShutdownSessionService, | |
493 ShutdownSessionService) | |
494 IPC_MESSAGE_HANDLER(AutomationMsg_SetContentSetting, SetContentSetting) | |
495 IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) | 436 IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme) |
496 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 437 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
497 AutomationMsg_WaitForProcessLauncherThreadToGoIdle, | 438 AutomationMsg_WaitForProcessLauncherThreadToGoIdle, |
498 WaitForProcessLauncherThreadToGoIdle) | 439 WaitForProcessLauncherThreadToGoIdle) |
499 IPC_MESSAGE_HANDLER(AutomationMsg_GetParentBrowserOfTab, | |
500 GetParentBrowserOfTab) | |
501 | 440 |
502 IPC_MESSAGE_UNHANDLED( | 441 IPC_MESSAGE_UNHANDLED( |
503 handled = AutomationProvider::OnMessageReceived(message)) | 442 handled = AutomationProvider::OnMessageReceived(message)) |
504 IPC_END_MESSAGE_MAP_EX() | 443 IPC_END_MESSAGE_MAP_EX() |
505 if (!deserialize_success) | 444 if (!deserialize_success) |
506 OnMessageDeserializationFailure(); | 445 OnMessageDeserializationFailure(); |
507 return handled; | 446 return handled; |
508 } | 447 } |
509 | 448 |
510 void TestingAutomationProvider::OnChannelError() { | 449 void TestingAutomationProvider::OnChannelError() { |
511 if (!reinitialize_on_channel_error_ && | 450 if (!reinitialize_on_channel_error_ && |
512 browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) | 451 browser_shutdown::GetShutdownType() == browser_shutdown::NOT_VALID) |
513 BrowserList::AttemptExit(); | 452 BrowserList::AttemptExit(); |
514 AutomationProvider::OnChannelError(); | 453 AutomationProvider::OnChannelError(); |
515 } | 454 } |
516 | 455 |
517 void TestingAutomationProvider::CloseBrowser(int browser_handle, | 456 void TestingAutomationProvider::CloseBrowser(int browser_handle, |
518 IPC::Message* reply_message) { | 457 IPC::Message* reply_message) { |
519 if (!browser_tracker_->ContainsHandle(browser_handle)) | 458 if (!browser_tracker_->ContainsHandle(browser_handle)) |
520 return; | 459 return; |
521 | 460 |
522 Browser* browser = browser_tracker_->GetResource(browser_handle); | 461 Browser* browser = browser_tracker_->GetResource(browser_handle); |
523 new BrowserClosedNotificationObserver(browser, this, reply_message); | 462 new BrowserClosedNotificationObserver(browser, this, reply_message); |
524 browser->window()->Close(); | 463 browser->window()->Close(); |
525 } | 464 } |
526 | 465 |
527 void TestingAutomationProvider::CloseBrowserAsync(int browser_handle) { | |
528 if (!browser_tracker_->ContainsHandle(browser_handle)) | |
529 return; | |
530 | |
531 Browser* browser = browser_tracker_->GetResource(browser_handle); | |
532 browser->window()->Close(); | |
533 } | |
534 | |
535 void TestingAutomationProvider::ActivateTab(int handle, | 466 void TestingAutomationProvider::ActivateTab(int handle, |
536 int at_index, | 467 int at_index, |
537 int* status) { | 468 int* status) { |
538 *status = -1; | 469 *status = -1; |
539 if (browser_tracker_->ContainsHandle(handle) && at_index > -1) { | 470 if (browser_tracker_->ContainsHandle(handle) && at_index > -1) { |
540 Browser* browser = browser_tracker_->GetResource(handle); | 471 Browser* browser = browser_tracker_->GetResource(handle); |
541 if (at_index >= 0 && at_index < browser->tab_count()) { | 472 if (at_index >= 0 && at_index < browser->tab_count()) { |
542 browser->ActivateTabAt(at_index, true); | 473 browser->ActivateTabAt(at_index, true); |
543 *status = 0; | 474 *status = 0; |
544 } | 475 } |
(...skipping 23 matching lines...) Expand all Loading... |
568 | 499 |
569 if (observer) | 500 if (observer) |
570 delete observer; | 501 delete observer; |
571 | 502 |
572 AutomationMsg_AppendTab::WriteReplyParams(reply_message, | 503 AutomationMsg_AppendTab::WriteReplyParams(reply_message, |
573 append_tab_response); | 504 append_tab_response); |
574 Send(reply_message); | 505 Send(reply_message); |
575 } | 506 } |
576 } | 507 } |
577 | 508 |
578 void TestingAutomationProvider::AppendBackgroundTab( | |
579 int handle, | |
580 const GURL& url, | |
581 IPC::Message* reply_message) { | |
582 int append_tab_response = -1; // -1 is the error code | |
583 content::NotificationObserver* observer = NULL; | |
584 | |
585 if (browser_tracker_->ContainsHandle(handle)) { | |
586 Browser* browser = browser_tracker_->GetResource(handle); | |
587 observer = new TabAppendedNotificationObserver(browser, this, | |
588 reply_message); | |
589 | |
590 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_LINK); | |
591 params.disposition = NEW_BACKGROUND_TAB; | |
592 browser::Navigate(¶ms); | |
593 TabContentsWrapper* contents = params.target_contents; | |
594 if (contents) { | |
595 append_tab_response = GetIndexForNavigationController( | |
596 &contents->web_contents()->GetController(), browser); | |
597 } | |
598 } | |
599 | |
600 if (append_tab_response < 0) { | |
601 // Appending tab failed. Clean up and send failure response. | |
602 if (observer) | |
603 delete observer; | |
604 | |
605 AutomationMsg_AppendBackgroundTab::WriteReplyParams(reply_message, | |
606 append_tab_response); | |
607 Send(reply_message); | |
608 } | |
609 } | |
610 | |
611 void TestingAutomationProvider::GetMachPortCount(int* port_count) { | 509 void TestingAutomationProvider::GetMachPortCount(int* port_count) { |
612 #if defined(OS_MACOSX) | 510 #if defined(OS_MACOSX) |
613 base::mac::GetNumberOfMachPorts(mach_task_self(), port_count); | 511 base::mac::GetNumberOfMachPorts(mach_task_self(), port_count); |
614 #else | 512 #else |
615 *port_count = 0; | 513 *port_count = 0; |
616 #endif | 514 #endif |
617 } | 515 } |
618 | 516 |
619 void TestingAutomationProvider::GetActiveTabIndex(int handle, | 517 void TestingAutomationProvider::GetActiveTabIndex(int handle, |
620 int* active_tab_index) { | 518 int* active_tab_index) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 550 |
653 void TestingAutomationProvider::SetCookie(const GURL& url, | 551 void TestingAutomationProvider::SetCookie(const GURL& url, |
654 const std::string& value, | 552 const std::string& value, |
655 int handle, | 553 int handle, |
656 int* response_value) { | 554 int* response_value) { |
657 WebContents* contents = tab_tracker_->ContainsHandle(handle) ? | 555 WebContents* contents = tab_tracker_->ContainsHandle(handle) ? |
658 tab_tracker_->GetResource(handle)->GetWebContents() : NULL; | 556 tab_tracker_->GetResource(handle)->GetWebContents() : NULL; |
659 automation_util::SetCookie(url, value, contents, response_value); | 557 automation_util::SetCookie(url, value, contents, response_value); |
660 } | 558 } |
661 | 559 |
662 void TestingAutomationProvider::DeleteCookie(const GURL& url, | |
663 const std::string& cookie_name, | |
664 int handle, bool* success) { | |
665 WebContents* contents = tab_tracker_->ContainsHandle(handle) ? | |
666 tab_tracker_->GetResource(handle)->GetWebContents() : NULL; | |
667 automation_util::DeleteCookie(url, cookie_name, contents, success); | |
668 } | |
669 | |
670 void TestingAutomationProvider::NavigateToURLBlockUntilNavigationsComplete( | 560 void TestingAutomationProvider::NavigateToURLBlockUntilNavigationsComplete( |
671 int handle, const GURL& url, int number_of_navigations, | 561 int handle, const GURL& url, int number_of_navigations, |
672 IPC::Message* reply_message) { | 562 IPC::Message* reply_message) { |
673 if (tab_tracker_->ContainsHandle(handle)) { | 563 if (tab_tracker_->ContainsHandle(handle)) { |
674 NavigationController* tab = tab_tracker_->GetResource(handle); | 564 NavigationController* tab = tab_tracker_->GetResource(handle); |
675 | 565 |
676 // Simulate what a user would do. Activate the tab and then navigate. | 566 // Simulate what a user would do. Activate the tab and then navigate. |
677 // We could allow navigating in a background tab in future. | 567 // We could allow navigating in a background tab in future. |
678 Browser* browser = FindAndActivateTab(tab); | 568 Browser* browser = FindAndActivateTab(tab); |
679 | 569 |
(...skipping 10 matching lines...) Expand all Loading... |
690 } | 580 } |
691 | 581 |
692 AutomationMsg_NavigateToURLBlockUntilNavigationsComplete::WriteReplyParams( | 582 AutomationMsg_NavigateToURLBlockUntilNavigationsComplete::WriteReplyParams( |
693 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); | 583 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); |
694 Send(reply_message); | 584 Send(reply_message); |
695 } | 585 } |
696 | 586 |
697 void TestingAutomationProvider::NavigationAsync(int handle, | 587 void TestingAutomationProvider::NavigationAsync(int handle, |
698 const GURL& url, | 588 const GURL& url, |
699 bool* status) { | 589 bool* status) { |
700 NavigationAsyncWithDisposition(handle, url, CURRENT_TAB, status); | |
701 } | |
702 | |
703 void TestingAutomationProvider::NavigationAsyncWithDisposition( | |
704 int handle, | |
705 const GURL& url, | |
706 WindowOpenDisposition disposition, | |
707 bool* status) { | |
708 *status = false; | 590 *status = false; |
709 | 591 |
710 if (tab_tracker_->ContainsHandle(handle)) { | 592 if (tab_tracker_->ContainsHandle(handle)) { |
711 NavigationController* tab = tab_tracker_->GetResource(handle); | 593 NavigationController* tab = tab_tracker_->GetResource(handle); |
712 | 594 |
713 // Simulate what a user would do. Activate the tab and then navigate. | 595 // Simulate what a user would do. Activate the tab and then navigate. |
714 // We could allow navigating in a background tab in future. | 596 // We could allow navigating in a background tab in future. |
715 Browser* browser = FindAndActivateTab(tab); | 597 Browser* browser = FindAndActivateTab(tab); |
716 | 598 |
717 if (browser) { | 599 if (browser) { |
718 // Don't add any listener unless a callback mechanism is desired. | 600 // Don't add any listener unless a callback mechanism is desired. |
719 // TODO(vibhor): Do this if such a requirement arises in future. | 601 // TODO(vibhor): Do this if such a requirement arises in future. |
720 OpenURLParams params( | 602 OpenURLParams params( |
721 url, Referrer(), disposition, content::PAGE_TRANSITION_TYPED, false); | 603 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false); |
722 browser->OpenURL(params); | 604 browser->OpenURL(params); |
723 *status = true; | 605 *status = true; |
724 } | 606 } |
725 } | 607 } |
726 } | 608 } |
727 | 609 |
728 void TestingAutomationProvider::Reload(int handle, | 610 void TestingAutomationProvider::Reload(int handle, |
729 IPC::Message* reply_message) { | 611 IPC::Message* reply_message) { |
730 if (tab_tracker_->ContainsHandle(handle)) { | 612 if (tab_tracker_->ContainsHandle(handle)) { |
731 NavigationController* tab = tab_tracker_->GetResource(handle); | 613 NavigationController* tab = tab_tracker_->GetResource(handle); |
(...skipping 27 matching lines...) Expand all Loading... |
759 *handle = browser_tracker_->Add(browser); | 641 *handle = browser_tracker_->Add(browser); |
760 } | 642 } |
761 | 643 |
762 void TestingAutomationProvider::FindTabbedBrowserWindow(int* handle) { | 644 void TestingAutomationProvider::FindTabbedBrowserWindow(int* handle) { |
763 *handle = 0; | 645 *handle = 0; |
764 Browser* browser = BrowserList::FindTabbedBrowser(profile_, false); | 646 Browser* browser = BrowserList::FindTabbedBrowser(profile_, false); |
765 if (browser) | 647 if (browser) |
766 *handle = browser_tracker_->Add(browser); | 648 *handle = browser_tracker_->Add(browser); |
767 } | 649 } |
768 | 650 |
769 void TestingAutomationProvider::GetLastActiveBrowserWindow(int* handle) { | |
770 *handle = 0; | |
771 Browser* browser = BrowserList::GetLastActive(); | |
772 if (browser) | |
773 *handle = browser_tracker_->Add(browser); | |
774 } | |
775 | |
776 void TestingAutomationProvider::GetActiveWindow(int* handle) { | 651 void TestingAutomationProvider::GetActiveWindow(int* handle) { |
777 *handle = 0; | 652 *handle = 0; |
778 Browser* browser = BrowserList::GetLastActive(); | 653 Browser* browser = BrowserList::GetLastActive(); |
779 if (browser) { | 654 if (browser) { |
780 gfx::NativeWindow window = browser->window()->GetNativeHandle(); | 655 gfx::NativeWindow window = browser->window()->GetNativeHandle(); |
781 *handle = window_tracker_->Add(window); | 656 *handle = window_tracker_->Add(window); |
782 } | 657 } |
783 } | 658 } |
784 | 659 |
785 void TestingAutomationProvider::ExecuteBrowserCommandAsync(int handle, | 660 void TestingAutomationProvider::ExecuteBrowserCommandAsync(int handle, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 this, browser, command, reply_message)) { | 708 this, browser, command, reply_message)) { |
834 browser->ExecuteCommand(command); | 709 browser->ExecuteCommand(command); |
835 return; | 710 return; |
836 } | 711 } |
837 } | 712 } |
838 } | 713 } |
839 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message, false); | 714 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message, false); |
840 Send(reply_message); | 715 Send(reply_message); |
841 } | 716 } |
842 | 717 |
843 void TestingAutomationProvider::GetBrowserLocale(string16* locale) { | |
844 *locale = ASCIIToUTF16(g_browser_process->GetApplicationLocale()); | |
845 } | |
846 | |
847 void TestingAutomationProvider::IsWindowActive(int handle, | |
848 bool* success, | |
849 bool* is_active) { | |
850 if (window_tracker_->ContainsHandle(handle)) { | |
851 *is_active = | |
852 platform_util::IsWindowActive(window_tracker_->GetResource(handle)); | |
853 *success = true; | |
854 } else { | |
855 *success = false; | |
856 *is_active = false; | |
857 } | |
858 } | |
859 | |
860 void TestingAutomationProvider::WindowSimulateClick(const IPC::Message& message, | |
861 int handle, | |
862 const gfx::Point& click, | |
863 int flags) { | |
864 if (window_tracker_->ContainsHandle(handle)) { | |
865 // TODO(phajdan.jr): This is flaky. We should wait for the final click. | |
866 ui_controls::SendMouseMoveNotifyWhenDone( | |
867 click.x(), click.y(), base::Bind(&SendMouseClick, flags)); | |
868 } | |
869 } | |
870 | |
871 void TestingAutomationProvider::WindowSimulateMouseMove( | 718 void TestingAutomationProvider::WindowSimulateMouseMove( |
872 const IPC::Message& message, | 719 const IPC::Message& message, |
873 int handle, | 720 int handle, |
874 const gfx::Point& location) { | 721 const gfx::Point& location) { |
875 if (window_tracker_->ContainsHandle(handle)) | 722 if (window_tracker_->ContainsHandle(handle)) |
876 ui_controls::SendMouseMove(location.x(), location.y()); | 723 ui_controls::SendMouseMove(location.x(), location.y()); |
877 } | 724 } |
878 | 725 |
879 void TestingAutomationProvider::WindowSimulateKeyPress( | 726 void TestingAutomationProvider::WindowSimulateKeyPress( |
880 const IPC::Message& message, | 727 const IPC::Message& message, |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 | 1031 |
1185 void TestingAutomationProvider::GetType(int handle, int* type_as_int) { | 1032 void TestingAutomationProvider::GetType(int handle, int* type_as_int) { |
1186 *type_as_int = -1; // -1 is the error code | 1033 *type_as_int = -1; // -1 is the error code |
1187 | 1034 |
1188 if (browser_tracker_->ContainsHandle(handle)) { | 1035 if (browser_tracker_->ContainsHandle(handle)) { |
1189 Browser* browser = browser_tracker_->GetResource(handle); | 1036 Browser* browser = browser_tracker_->GetResource(handle); |
1190 *type_as_int = static_cast<int>(browser->type()); | 1037 *type_as_int = static_cast<int>(browser->type()); |
1191 } | 1038 } |
1192 } | 1039 } |
1193 | 1040 |
1194 void TestingAutomationProvider::IsBrowserInApplicationMode(int handle, | |
1195 bool* is_application, | |
1196 bool* success) { | |
1197 *is_application = false; | |
1198 *success = false; | |
1199 | |
1200 if (browser_tracker_->ContainsHandle(handle)) { | |
1201 Browser* browser = browser_tracker_->GetResource(handle); | |
1202 if (browser) { | |
1203 *success = true; | |
1204 *is_application = browser->is_app(); | |
1205 } | |
1206 } | |
1207 } | |
1208 | |
1209 void TestingAutomationProvider::GetTab(int win_handle, | 1041 void TestingAutomationProvider::GetTab(int win_handle, |
1210 int tab_index, | 1042 int tab_index, |
1211 int* tab_handle) { | 1043 int* tab_handle) { |
1212 *tab_handle = 0; | 1044 *tab_handle = 0; |
1213 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { | 1045 if (browser_tracker_->ContainsHandle(win_handle) && (tab_index >= 0)) { |
1214 Browser* browser = browser_tracker_->GetResource(win_handle); | 1046 Browser* browser = browser_tracker_->GetResource(win_handle); |
1215 if (tab_index < browser->tab_count()) { | 1047 if (tab_index < browser->tab_count()) { |
1216 WebContents* web_contents = browser->GetWebContentsAt(tab_index); | 1048 WebContents* web_contents = browser->GetWebContentsAt(tab_index); |
1217 *tab_handle = tab_tracker_->Add(&web_contents->GetController()); | 1049 *tab_handle = tab_tracker_->Add(&web_contents->GetController()); |
1218 } | 1050 } |
1219 } | 1051 } |
1220 } | 1052 } |
1221 | 1053 |
1222 void TestingAutomationProvider::GetTabProcessID(int handle, int* process_id) { | |
1223 *process_id = -1; | |
1224 | |
1225 if (tab_tracker_->ContainsHandle(handle)) { | |
1226 *process_id = 0; | |
1227 WebContents* web_contents = | |
1228 tab_tracker_->GetResource(handle)->GetWebContents(); | |
1229 content::RenderProcessHost* rph = web_contents->GetRenderProcessHost(); | |
1230 if (rph) | |
1231 *process_id = base::GetProcId(rph->GetHandle()); | |
1232 } | |
1233 } | |
1234 | |
1235 void TestingAutomationProvider::GetTabTitle(int handle, | 1054 void TestingAutomationProvider::GetTabTitle(int handle, |
1236 int* title_string_size, | 1055 int* title_string_size, |
1237 std::wstring* title) { | 1056 std::wstring* title) { |
1238 *title_string_size = -1; // -1 is the error code | 1057 *title_string_size = -1; // -1 is the error code |
1239 if (tab_tracker_->ContainsHandle(handle)) { | 1058 if (tab_tracker_->ContainsHandle(handle)) { |
1240 NavigationController* tab = tab_tracker_->GetResource(handle); | 1059 NavigationController* tab = tab_tracker_->GetResource(handle); |
1241 NavigationEntry* entry = tab->GetActiveEntry(); | 1060 NavigationEntry* entry = tab->GetActiveEntry(); |
1242 if (entry != NULL) { | 1061 if (entry != NULL) { |
1243 *title = UTF16ToWideHack(entry->GetTitleForDisplay("")); | 1062 *title = UTF16ToWideHack(entry->GetTitleForDisplay("")); |
1244 } else { | 1063 } else { |
(...skipping 29 matching lines...) Expand all Loading... |
1274 *visible = false; | 1093 *visible = false; |
1275 | 1094 |
1276 if (browser_tracker_->ContainsHandle(handle)) { | 1095 if (browser_tracker_->ContainsHandle(handle)) { |
1277 Browser* browser = browser_tracker_->GetResource(handle); | 1096 Browser* browser = browser_tracker_->GetResource(handle); |
1278 if (browser) { | 1097 if (browser) { |
1279 *visible = browser->window()->IsDownloadShelfVisible(); | 1098 *visible = browser->window()->IsDownloadShelfVisible(); |
1280 } | 1099 } |
1281 } | 1100 } |
1282 } | 1101 } |
1283 | 1102 |
1284 void TestingAutomationProvider::IsFullscreen(int handle, bool* visible) { | |
1285 *visible = false; | |
1286 | |
1287 if (browser_tracker_->ContainsHandle(handle)) { | |
1288 Browser* browser = browser_tracker_->GetResource(handle); | |
1289 if (browser) | |
1290 *visible = browser->window()->IsFullscreen(); | |
1291 } | |
1292 } | |
1293 | |
1294 void TestingAutomationProvider::GetFullscreenBubbleVisibility(int handle, | |
1295 bool* visible) { | |
1296 *visible = false; | |
1297 | |
1298 if (browser_tracker_->ContainsHandle(handle)) { | |
1299 Browser* browser = browser_tracker_->GetResource(handle); | |
1300 if (browser) | |
1301 *visible = browser->window()->IsFullscreenBubbleVisible(); | |
1302 } | |
1303 } | |
1304 | |
1305 void TestingAutomationProvider::ExecuteJavascriptInRenderViewFrame( | 1103 void TestingAutomationProvider::ExecuteJavascriptInRenderViewFrame( |
1306 const string16& frame_xpath, | 1104 const string16& frame_xpath, |
1307 const string16& script, | 1105 const string16& script, |
1308 IPC::Message* reply_message, | 1106 IPC::Message* reply_message, |
1309 RenderViewHost* render_view_host) { | 1107 RenderViewHost* render_view_host) { |
1310 // Set the routing id of this message with the controller. | 1108 // Set the routing id of this message with the controller. |
1311 // This routing id needs to be remembered for the reverse | 1109 // This routing id needs to be remembered for the reverse |
1312 // communication while sending back the response of | 1110 // communication while sending back the response of |
1313 // this javascript execution. | 1111 // this javascript execution. |
1314 render_view_host->ExecuteJavascriptInWebFrame( | 1112 render_view_host->ExecuteJavascriptInWebFrame( |
(...skipping 14 matching lines...) Expand all Loading... |
1329 Send(reply_message); | 1127 Send(reply_message); |
1330 return; | 1128 return; |
1331 } | 1129 } |
1332 | 1130 |
1333 new DomOperationMessageSender(this, reply_message, false); | 1131 new DomOperationMessageSender(this, reply_message, false); |
1334 ExecuteJavascriptInRenderViewFrame(WideToUTF16Hack(frame_xpath), | 1132 ExecuteJavascriptInRenderViewFrame(WideToUTF16Hack(frame_xpath), |
1335 WideToUTF16Hack(script), reply_message, | 1133 WideToUTF16Hack(script), reply_message, |
1336 web_contents->GetRenderViewHost()); | 1134 web_contents->GetRenderViewHost()); |
1337 } | 1135 } |
1338 | 1136 |
1339 void TestingAutomationProvider::HandleInspectElementRequest( | |
1340 int handle, int x, int y, IPC::Message* reply_message) { | |
1341 WebContents* web_contents = GetWebContentsForHandle(handle, NULL); | |
1342 if (web_contents) { | |
1343 DCHECK(!reply_message_); | |
1344 reply_message_ = reply_message; | |
1345 | |
1346 DevToolsWindow::InspectElement(web_contents->GetRenderViewHost(), x, y); | |
1347 } else { | |
1348 AutomationMsg_InspectElement::WriteReplyParams(reply_message, -1); | |
1349 Send(reply_message); | |
1350 } | |
1351 } | |
1352 | |
1353 void TestingAutomationProvider::GetDownloadDirectory( | 1137 void TestingAutomationProvider::GetDownloadDirectory( |
1354 int handle, FilePath* download_directory) { | 1138 int handle, FilePath* download_directory) { |
1355 if (tab_tracker_->ContainsHandle(handle)) { | 1139 if (tab_tracker_->ContainsHandle(handle)) { |
1356 NavigationController* tab = tab_tracker_->GetResource(handle); | 1140 NavigationController* tab = tab_tracker_->GetResource(handle); |
1357 DownloadManager* dlm = tab->GetBrowserContext()->GetDownloadManager(); | 1141 DownloadManager* dlm = tab->GetBrowserContext()->GetDownloadManager(); |
1358 *download_directory = | 1142 *download_directory = |
1359 DownloadPrefs::FromDownloadManager(dlm)->download_path(); | 1143 DownloadPrefs::FromDownloadManager(dlm)->download_path(); |
1360 } | 1144 } |
1361 } | 1145 } |
1362 | 1146 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 | 1197 |
1414 if (browser_tracker_->ContainsHandle(browser_handle)) { | 1198 if (browser_tracker_->ContainsHandle(browser_handle)) { |
1415 Browser* browser = browser_tracker_->GetResource(browser_handle); | 1199 Browser* browser = browser_tracker_->GetResource(browser_handle); |
1416 gfx::NativeWindow win = browser->window()->GetNativeHandle(); | 1200 gfx::NativeWindow win = browser->window()->GetNativeHandle(); |
1417 // Add() returns the existing handle for the resource if any. | 1201 // Add() returns the existing handle for the resource if any. |
1418 *handle = window_tracker_->Add(win); | 1202 *handle = window_tracker_->Add(win); |
1419 *success = true; | 1203 *success = true; |
1420 } | 1204 } |
1421 } | 1205 } |
1422 | 1206 |
1423 void TestingAutomationProvider::GetBrowserForWindow(int window_handle, | |
1424 bool* success, | |
1425 int* browser_handle) { | |
1426 *success = false; | |
1427 *browser_handle = 0; | |
1428 | |
1429 gfx::NativeWindow window = window_tracker_->GetResource(window_handle); | |
1430 if (!window) | |
1431 return; | |
1432 | |
1433 BrowserList::const_iterator iter = BrowserList::begin(); | |
1434 for (; iter != BrowserList::end(); ++iter) { | |
1435 gfx::NativeWindow this_window = (*iter)->window()->GetNativeHandle(); | |
1436 if (window == this_window) { | |
1437 // Add() returns the existing handle for the resource if any. | |
1438 *browser_handle = browser_tracker_->Add(*iter); | |
1439 *success = true; | |
1440 return; | |
1441 } | |
1442 } | |
1443 } | |
1444 | |
1445 void TestingAutomationProvider::ShowInterstitialPage( | |
1446 int tab_handle, | |
1447 const std::string& html_text, | |
1448 IPC::Message* reply_message) { | |
1449 if (tab_tracker_->ContainsHandle(tab_handle)) { | |
1450 NavigationController* controller = tab_tracker_->GetResource(tab_handle); | |
1451 WebContents* web_contents = controller->GetWebContents(); | |
1452 | |
1453 new NavigationNotificationObserver(controller, this, reply_message, 1, | |
1454 false, false); | |
1455 | |
1456 new AutomationInterstitialPage( | |
1457 web_contents, GURL("about:interstitial"), html_text); | |
1458 return; | |
1459 } | |
1460 | |
1461 AutomationMsg_ShowInterstitialPage::WriteReplyParams( | |
1462 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); | |
1463 Send(reply_message); | |
1464 } | |
1465 | |
1466 void TestingAutomationProvider::HideInterstitialPage(int tab_handle, | |
1467 bool* success) { | |
1468 *success = false; | |
1469 WebContents* web_contents = GetWebContentsForHandle(tab_handle, NULL); | |
1470 if (web_contents && web_contents->GetInterstitialPage()) { | |
1471 web_contents->GetInterstitialPage()->DontProceed(); | |
1472 *success = true; | |
1473 } | |
1474 } | |
1475 | |
1476 void TestingAutomationProvider::WaitForTabToBeRestored( | 1207 void TestingAutomationProvider::WaitForTabToBeRestored( |
1477 int tab_handle, | 1208 int tab_handle, |
1478 IPC::Message* reply_message) { | 1209 IPC::Message* reply_message) { |
1479 if (tab_tracker_->ContainsHandle(tab_handle)) { | 1210 if (tab_tracker_->ContainsHandle(tab_handle)) { |
1480 NavigationController* tab = tab_tracker_->GetResource(tab_handle); | 1211 NavigationController* tab = tab_tracker_->GetResource(tab_handle); |
1481 restore_tracker_.reset( | 1212 restore_tracker_.reset( |
1482 new NavigationControllerRestoredObserver(this, tab, reply_message)); | 1213 new NavigationControllerRestoredObserver(this, tab, reply_message)); |
1483 } else { | 1214 } else { |
1484 AutomationMsg_WaitForTabToBeRestored::WriteReplyParams( | 1215 AutomationMsg_WaitForTabToBeRestored::WriteReplyParams( |
1485 reply_message, false); | 1216 reply_message, false); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 int message_num, | 1312 int message_num, |
1582 bool* menu_item_enabled) { | 1313 bool* menu_item_enabled) { |
1583 *menu_item_enabled = false; | 1314 *menu_item_enabled = false; |
1584 if (browser_tracker_->ContainsHandle(browser_handle)) { | 1315 if (browser_tracker_->ContainsHandle(browser_handle)) { |
1585 Browser* browser = browser_tracker_->GetResource(browser_handle); | 1316 Browser* browser = browser_tracker_->GetResource(browser_handle); |
1586 *menu_item_enabled = | 1317 *menu_item_enabled = |
1587 browser->command_updater()->IsCommandEnabled(message_num); | 1318 browser->command_updater()->IsCommandEnabled(message_num); |
1588 } | 1319 } |
1589 } | 1320 } |
1590 | 1321 |
1591 void TestingAutomationProvider::SavePage(int tab_handle, | |
1592 const FilePath& file_name, | |
1593 const FilePath& dir_path, | |
1594 int type, | |
1595 bool* success) { | |
1596 content::SavePageType save_type = | |
1597 static_cast<content::SavePageType>(type); | |
1598 if (save_type < content::SAVE_PAGE_TYPE_AS_ONLY_HTML || | |
1599 save_type > content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML) { | |
1600 *success = false; | |
1601 return; | |
1602 } | |
1603 | |
1604 if (!tab_tracker_->ContainsHandle(tab_handle)) { | |
1605 *success = false; | |
1606 return; | |
1607 } | |
1608 | |
1609 NavigationController* nav = tab_tracker_->GetResource(tab_handle); | |
1610 Browser* browser = FindAndActivateTab(nav); | |
1611 if (!browser->command_updater()->IsCommandEnabled(IDC_SAVE_PAGE)) { | |
1612 *success = false; | |
1613 return; | |
1614 } | |
1615 | |
1616 nav->GetWebContents()->SavePage(file_name, dir_path, save_type); | |
1617 *success = true; | |
1618 } | |
1619 | |
1620 void TestingAutomationProvider::HandleOpenFindInPageRequest( | 1322 void TestingAutomationProvider::HandleOpenFindInPageRequest( |
1621 const IPC::Message& message, int handle) { | 1323 const IPC::Message& message, int handle) { |
1622 if (browser_tracker_->ContainsHandle(handle)) { | 1324 if (browser_tracker_->ContainsHandle(handle)) { |
1623 Browser* browser = browser_tracker_->GetResource(handle); | 1325 Browser* browser = browser_tracker_->GetResource(handle); |
1624 browser->FindInPage(false, false); | 1326 browser->FindInPage(false, false); |
1625 } | 1327 } |
1626 } | 1328 } |
1627 | 1329 |
1628 void TestingAutomationProvider::GetFindWindowVisibility(int handle, | 1330 void TestingAutomationProvider::GetFindWindowVisibility(int handle, |
1629 bool* visible) { | 1331 bool* visible) { |
1630 *visible = false; | 1332 *visible = false; |
1631 Browser* browser = browser_tracker_->GetResource(handle); | 1333 Browser* browser = browser_tracker_->GetResource(handle); |
1632 if (browser) { | 1334 if (browser) { |
1633 FindBarTesting* find_bar = | 1335 FindBarTesting* find_bar = |
1634 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); | 1336 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); |
1635 find_bar->GetFindBarWindowInfo(NULL, visible); | 1337 find_bar->GetFindBarWindowInfo(NULL, visible); |
1636 } | 1338 } |
1637 } | 1339 } |
1638 | 1340 |
1639 void TestingAutomationProvider::HandleFindWindowLocationRequest(int handle, | |
1640 int* x, | |
1641 int* y) { | |
1642 gfx::Point position(0, 0); | |
1643 bool visible = false; | |
1644 if (browser_tracker_->ContainsHandle(handle)) { | |
1645 Browser* browser = browser_tracker_->GetResource(handle); | |
1646 FindBarTesting* find_bar = | |
1647 browser->GetFindBarController()->find_bar()->GetFindBarTesting(); | |
1648 find_bar->GetFindBarWindowInfo(&position, &visible); | |
1649 } | |
1650 | |
1651 *x = position.x(); | |
1652 *y = position.y(); | |
1653 } | |
1654 | |
1655 // Bookmark bar visibility is based on the pref (e.g. is it in the toolbar). | 1341 // Bookmark bar visibility is based on the pref (e.g. is it in the toolbar). |
1656 // Presence in the NTP is signalled in |detached|. | 1342 // Presence in the NTP is signalled in |detached|. |
1657 void TestingAutomationProvider::GetBookmarkBarVisibility(int handle, | 1343 void TestingAutomationProvider::GetBookmarkBarVisibility(int handle, |
1658 bool* visible, | 1344 bool* visible, |
1659 bool* animating, | 1345 bool* animating, |
1660 bool* detached) { | 1346 bool* detached) { |
1661 *visible = false; | 1347 *visible = false; |
1662 *animating = false; | 1348 *animating = false; |
1663 | 1349 |
1664 if (browser_tracker_->ContainsHandle(handle)) { | 1350 if (browser_tracker_->ContainsHandle(handle)) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 const BookmarkNode* parent = node->parent(); | 1541 const BookmarkNode* parent = node->parent(); |
1856 DCHECK(parent); | 1542 DCHECK(parent); |
1857 model->Remove(parent, parent->GetIndexOf(node)); | 1543 model->Remove(parent, parent->GetIndexOf(node)); |
1858 *success = true; | 1544 *success = true; |
1859 } | 1545 } |
1860 } | 1546 } |
1861 } | 1547 } |
1862 *success = false; | 1548 *success = false; |
1863 } | 1549 } |
1864 | 1550 |
1865 void TestingAutomationProvider::GetInfoBarCount(int handle, size_t* count) { | |
1866 *count = static_cast<size_t>(-1); // -1 means error. | |
1867 if (tab_tracker_->ContainsHandle(handle)) { | |
1868 NavigationController* nav_controller = tab_tracker_->GetResource(handle); | |
1869 if (nav_controller) { | |
1870 TabContentsWrapper* wrapper = | |
1871 TabContentsWrapper::GetCurrentWrapperForContents( | |
1872 nav_controller->GetWebContents()); | |
1873 *count = wrapper->infobar_tab_helper()->infobar_count(); | |
1874 } | |
1875 } | |
1876 } | |
1877 | |
1878 void TestingAutomationProvider::ClickInfoBarAccept( | |
1879 int handle, | |
1880 size_t info_bar_index, | |
1881 bool wait_for_navigation, | |
1882 IPC::Message* reply_message) { | |
1883 bool success = false; | |
1884 if (tab_tracker_->ContainsHandle(handle)) { | |
1885 NavigationController* nav_controller = tab_tracker_->GetResource(handle); | |
1886 if (nav_controller) { | |
1887 InfoBarTabHelper* infobar_helper = | |
1888 TabContentsWrapper::GetCurrentWrapperForContents( | |
1889 nav_controller->GetWebContents())->infobar_tab_helper(); | |
1890 if (info_bar_index < infobar_helper->infobar_count()) { | |
1891 if (wait_for_navigation) { | |
1892 new NavigationNotificationObserver(nav_controller, this, | |
1893 reply_message, 1, false, false); | |
1894 } | |
1895 InfoBarDelegate* delegate = | |
1896 infobar_helper->GetInfoBarDelegateAt(info_bar_index); | |
1897 if (delegate->AsConfirmInfoBarDelegate()) | |
1898 delegate->AsConfirmInfoBarDelegate()->Accept(); | |
1899 success = true; | |
1900 } | |
1901 } | |
1902 } | |
1903 | |
1904 // This "!wait_for_navigation || !success condition" logic looks suspicious. | |
1905 // It will send a failure message when success is true but | |
1906 // |wait_for_navigation| is false. | |
1907 // TODO(phajdan.jr): investgate whether the reply param (currently | |
1908 // AUTOMATION_MSG_NAVIGATION_ERROR) should depend on success. | |
1909 if (!wait_for_navigation || !success) | |
1910 AutomationMsg_ClickInfoBarAccept::WriteReplyParams( | |
1911 reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); | |
1912 } | |
1913 | |
1914 void TestingAutomationProvider::GetLastNavigationTime( | |
1915 int handle, | |
1916 int64* last_navigation_time) { | |
1917 base::Time time(tab_tracker_->GetLastNavigationTime(handle)); | |
1918 *last_navigation_time = time.ToInternalValue(); | |
1919 } | |
1920 | |
1921 void TestingAutomationProvider::WaitForNavigation(int handle, | |
1922 int64 last_navigation_time, | |
1923 IPC::Message* reply_message) { | |
1924 NavigationController* controller = tab_tracker_->GetResource(handle); | |
1925 base::Time time(tab_tracker_->GetLastNavigationTime(handle)); | |
1926 | |
1927 if (time.ToInternalValue() > last_navigation_time || !controller) { | |
1928 AutomationMsg_WaitForNavigation::WriteReplyParams(reply_message, | |
1929 controller == NULL ? AUTOMATION_MSG_NAVIGATION_ERROR : | |
1930 AUTOMATION_MSG_NAVIGATION_SUCCESS); | |
1931 Send(reply_message); | |
1932 return; | |
1933 } | |
1934 | |
1935 new NavigationNotificationObserver( | |
1936 controller, this, reply_message, 1, true, false); | |
1937 } | |
1938 | |
1939 void TestingAutomationProvider::SetIntPreference(int handle, | |
1940 const std::string& name, | |
1941 int value, | |
1942 bool* success) { | |
1943 *success = false; | |
1944 if (browser_tracker_->ContainsHandle(handle)) { | |
1945 Browser* browser = browser_tracker_->GetResource(handle); | |
1946 browser->profile()->GetPrefs()->SetInteger(name.c_str(), value); | |
1947 *success = true; | |
1948 } | |
1949 } | |
1950 | |
1951 void TestingAutomationProvider::SetStringPreference(int handle, | |
1952 const std::string& name, | |
1953 const std::string& value, | |
1954 bool* success) { | |
1955 *success = false; | |
1956 if (browser_tracker_->ContainsHandle(handle)) { | |
1957 Browser* browser = browser_tracker_->GetResource(handle); | |
1958 browser->profile()->GetPrefs()->SetString(name.c_str(), value); | |
1959 *success = true; | |
1960 } | |
1961 } | |
1962 | |
1963 void TestingAutomationProvider::GetBooleanPreference(int handle, | |
1964 const std::string& name, | |
1965 bool* success, | |
1966 bool* value) { | |
1967 *success = false; | |
1968 *value = false; | |
1969 if (browser_tracker_->ContainsHandle(handle)) { | |
1970 Browser* browser = browser_tracker_->GetResource(handle); | |
1971 *value = browser->profile()->GetPrefs()->GetBoolean(name.c_str()); | |
1972 *success = true; | |
1973 } | |
1974 } | |
1975 | |
1976 void TestingAutomationProvider::SetBooleanPreference(int handle, | |
1977 const std::string& name, | |
1978 bool value, | |
1979 bool* success) { | |
1980 *success = false; | |
1981 if (browser_tracker_->ContainsHandle(handle)) { | |
1982 Browser* browser = browser_tracker_->GetResource(handle); | |
1983 browser->profile()->GetPrefs()->SetBoolean(name.c_str(), value); | |
1984 *success = true; | |
1985 } | |
1986 } | |
1987 | |
1988 void TestingAutomationProvider::GetShowingAppModalDialog(bool* showing_dialog, | |
1989 int* dialog_button) { | |
1990 AppModalDialog* active_dialog = | |
1991 AppModalDialogQueue::GetInstance()->active_dialog(); | |
1992 if (!active_dialog) { | |
1993 *showing_dialog = false; | |
1994 *dialog_button = ui::DIALOG_BUTTON_NONE; | |
1995 return; | |
1996 } | |
1997 NativeAppModalDialog* native_dialog = active_dialog->native_dialog(); | |
1998 *showing_dialog = (native_dialog != NULL); | |
1999 if (*showing_dialog) | |
2000 *dialog_button = native_dialog->GetAppModalDialogButtons(); | |
2001 else | |
2002 *dialog_button = ui::DIALOG_BUTTON_NONE; | |
2003 } | |
2004 | |
2005 void TestingAutomationProvider::ClickAppModalDialogButton(int button, | |
2006 bool* success) { | |
2007 *success = false; | |
2008 | |
2009 NativeAppModalDialog* native_dialog = | |
2010 AppModalDialogQueue::GetInstance()->active_dialog()->native_dialog(); | |
2011 if (native_dialog && | |
2012 (native_dialog->GetAppModalDialogButtons() & button) == button) { | |
2013 if ((button & ui::DIALOG_BUTTON_OK) == ui::DIALOG_BUTTON_OK) { | |
2014 native_dialog->AcceptAppModalDialog(); | |
2015 *success = true; | |
2016 } | |
2017 if ((button & ui::DIALOG_BUTTON_CANCEL) == ui::DIALOG_BUTTON_CANCEL) { | |
2018 DCHECK(!*success) << "invalid param, OK and CANCEL specified"; | |
2019 native_dialog->CancelAppModalDialog(); | |
2020 *success = true; | |
2021 } | |
2022 } | |
2023 } | |
2024 | |
2025 void TestingAutomationProvider::WaitForBrowserWindowCountToBecome( | 1551 void TestingAutomationProvider::WaitForBrowserWindowCountToBecome( |
2026 int target_count, | 1552 int target_count, |
2027 IPC::Message* reply_message) { | 1553 IPC::Message* reply_message) { |
2028 if (static_cast<int>(BrowserList::size()) == target_count) { | 1554 if (static_cast<int>(BrowserList::size()) == target_count) { |
2029 AutomationMsg_WaitForBrowserWindowCountToBecome::WriteReplyParams( | 1555 AutomationMsg_WaitForBrowserWindowCountToBecome::WriteReplyParams( |
2030 reply_message, true); | 1556 reply_message, true); |
2031 Send(reply_message); | 1557 Send(reply_message); |
2032 return; | 1558 return; |
2033 } | 1559 } |
2034 | 1560 |
2035 // Set up an observer (it will delete itself). | 1561 // Set up an observer (it will delete itself). |
2036 new BrowserCountChangeNotificationObserver(target_count, this, reply_message); | 1562 new BrowserCountChangeNotificationObserver(target_count, this, reply_message); |
2037 } | 1563 } |
2038 | 1564 |
2039 void TestingAutomationProvider::WaitForAppModalDialogToBeShown( | |
2040 IPC::Message* reply_message) { | |
2041 if (AppModalDialogQueue::GetInstance()->HasActiveDialog()) { | |
2042 AutomationMsg_WaitForAppModalDialogToBeShown::WriteReplyParams( | |
2043 reply_message, true); | |
2044 Send(reply_message); | |
2045 return; | |
2046 } | |
2047 | |
2048 // Set up an observer (it will delete itself). | |
2049 new AppModalDialogShownObserver(this, reply_message); | |
2050 } | |
2051 | |
2052 void TestingAutomationProvider::GoBackBlockUntilNavigationsComplete( | 1565 void TestingAutomationProvider::GoBackBlockUntilNavigationsComplete( |
2053 int handle, int number_of_navigations, IPC::Message* reply_message) { | 1566 int handle, int number_of_navigations, IPC::Message* reply_message) { |
2054 if (tab_tracker_->ContainsHandle(handle)) { | 1567 if (tab_tracker_->ContainsHandle(handle)) { |
2055 NavigationController* tab = tab_tracker_->GetResource(handle); | 1568 NavigationController* tab = tab_tracker_->GetResource(handle); |
2056 Browser* browser = FindAndActivateTab(tab); | 1569 Browser* browser = FindAndActivateTab(tab); |
2057 if (browser && browser->command_updater()->IsCommandEnabled(IDC_BACK)) { | 1570 if (browser && browser->command_updater()->IsCommandEnabled(IDC_BACK)) { |
2058 new NavigationNotificationObserver(tab, this, reply_message, | 1571 new NavigationNotificationObserver(tab, this, reply_message, |
2059 number_of_navigations, false, false); | 1572 number_of_navigations, false, false); |
2060 browser->GoBack(CURRENT_TAB); | 1573 browser->GoBack(CURRENT_TAB); |
2061 return; | 1574 return; |
(...skipping 28 matching lines...) Expand all Loading... |
2090 Browser* browser = browser_tracker_->GetResource(handle); | 1603 Browser* browser = browser_tracker_->GetResource(handle); |
2091 if (browser) { | 1604 if (browser) { |
2092 if (visible) | 1605 if (visible) |
2093 browser->window()->GetDownloadShelf()->Show(); | 1606 browser->window()->GetDownloadShelf()->Show(); |
2094 else | 1607 else |
2095 browser->window()->GetDownloadShelf()->Close(); | 1608 browser->window()->GetDownloadShelf()->Close(); |
2096 } | 1609 } |
2097 } | 1610 } |
2098 } | 1611 } |
2099 | 1612 |
2100 void TestingAutomationProvider::GetBlockedPopupCount(int handle, int* count) { | |
2101 *count = -1; // -1 is the error code | |
2102 if (tab_tracker_->ContainsHandle(handle)) { | |
2103 NavigationController* nav_controller = tab_tracker_->GetResource(handle); | |
2104 TabContentsWrapper* tab_contents = | |
2105 TabContentsWrapper::GetCurrentWrapperForContents( | |
2106 nav_controller->GetWebContents()); | |
2107 if (tab_contents) { | |
2108 BlockedContentTabHelper* blocked_content = | |
2109 tab_contents->blocked_content_tab_helper(); | |
2110 *count = static_cast<int>(blocked_content->GetBlockedContentsCount()); | |
2111 } | |
2112 } | |
2113 } | |
2114 | |
2115 void TestingAutomationProvider::SendJSONRequest(int handle, | 1613 void TestingAutomationProvider::SendJSONRequest(int handle, |
2116 const std::string& json_request, | 1614 const std::string& json_request, |
2117 IPC::Message* reply_message) { | 1615 IPC::Message* reply_message) { |
2118 std::string error; | 1616 std::string error; |
2119 scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError(json_request, | 1617 scoped_ptr<Value> values(base::JSONReader::ReadAndReturnError(json_request, |
2120 base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error)); | 1618 base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error)); |
2121 if (!error.empty()) { | 1619 if (!error.empty()) { |
2122 AutomationJSONReply(this, reply_message).SendError(error); | 1620 AutomationJSONReply(this, reply_message).SendError(error); |
2123 return; | 1621 return; |
2124 } | 1622 } |
(...skipping 4913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7038 Send(reply_message_); | 6536 Send(reply_message_); |
7039 return; | 6537 return; |
7040 } | 6538 } |
7041 | 6539 |
7042 // The delegate will delete itself. | 6540 // The delegate will delete itself. |
7043 new InfoBarCountObserver(this, reply_message, | 6541 new InfoBarCountObserver(this, reply_message, |
7044 TabContentsWrapper::GetCurrentWrapperForContents( | 6542 TabContentsWrapper::GetCurrentWrapperForContents( |
7045 controller->GetWebContents()), target_count); | 6543 controller->GetWebContents()), target_count); |
7046 } | 6544 } |
7047 | 6545 |
7048 // Gets the current used encoding name of the page in the specified tab. | |
7049 void TestingAutomationProvider::GetPageCurrentEncoding( | |
7050 int tab_handle, std::string* current_encoding) { | |
7051 if (tab_tracker_->ContainsHandle(tab_handle)) { | |
7052 NavigationController* nav = tab_tracker_->GetResource(tab_handle); | |
7053 Browser* browser = FindAndActivateTab(nav); | |
7054 if (browser->command_updater()->IsCommandEnabled(IDC_ENCODING_MENU)) | |
7055 *current_encoding = nav->GetWebContents()->GetEncoding(); | |
7056 } | |
7057 } | |
7058 | |
7059 void TestingAutomationProvider::ShutdownSessionService(int handle, | |
7060 bool* result) { | |
7061 if (browser_tracker_->ContainsHandle(handle)) { | |
7062 Browser* browser = browser_tracker_->GetResource(handle); | |
7063 SessionServiceFactory::ShutdownForProfile(browser->profile()); | |
7064 *result = true; | |
7065 } else { | |
7066 *result = false; | |
7067 } | |
7068 } | |
7069 | |
7070 void TestingAutomationProvider::SetContentSetting( | |
7071 int handle, | |
7072 const std::string& host, | |
7073 ContentSettingsType content_type, | |
7074 ContentSetting setting, | |
7075 bool* success) { | |
7076 *success = false; | |
7077 if (browser_tracker_->ContainsHandle(handle)) { | |
7078 Browser* browser = browser_tracker_->GetResource(handle); | |
7079 HostContentSettingsMap* map = | |
7080 browser->profile()->GetHostContentSettingsMap(); | |
7081 if (host.empty()) { | |
7082 map->SetDefaultContentSetting(content_type, setting); | |
7083 } else { | |
7084 map->SetContentSetting(ContentSettingsPattern::FromString(host), | |
7085 ContentSettingsPattern::Wildcard(), | |
7086 content_type, | |
7087 std::string(), | |
7088 setting); | |
7089 } | |
7090 *success = true; | |
7091 } | |
7092 } | |
7093 | |
7094 void TestingAutomationProvider::ResetToDefaultTheme() { | 6546 void TestingAutomationProvider::ResetToDefaultTheme() { |
7095 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); | 6547 ThemeServiceFactory::GetForProfile(profile_)->UseDefaultTheme(); |
7096 } | 6548 } |
7097 | 6549 |
7098 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( | 6550 void TestingAutomationProvider::WaitForProcessLauncherThreadToGoIdle( |
7099 IPC::Message* reply_message) { | 6551 IPC::Message* reply_message) { |
7100 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); | 6552 new WaitForProcessLauncherThreadToGoIdleObserver(this, reply_message); |
7101 } | 6553 } |
7102 | 6554 |
7103 void TestingAutomationProvider::GetParentBrowserOfTab(int tab_handle, | |
7104 int* browser_handle, | |
7105 bool* success) { | |
7106 *success = false; | |
7107 if (tab_tracker_->ContainsHandle(tab_handle)) { | |
7108 NavigationController* controller = tab_tracker_->GetResource(tab_handle); | |
7109 int index; | |
7110 Browser* browser = Browser::GetBrowserForController(controller, &index); | |
7111 if (browser) { | |
7112 *browser_handle = browser_tracker_->Add(browser); | |
7113 *success = true; | |
7114 } | |
7115 } | |
7116 } | |
7117 | |
7118 void TestingAutomationProvider::OnRemoveProvider() { | 6555 void TestingAutomationProvider::OnRemoveProvider() { |
7119 if (g_browser_process) | 6556 if (g_browser_process) |
7120 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); | 6557 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); |
7121 } | 6558 } |
OLD | NEW |