testing_automation_provider.h revision 201ade2fbba22bfb27ae029f4d23fca6ded109a0
1// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ 6#define CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ 7#pragma once 8 9#include "base/basictypes.h" 10#include "base/scoped_ptr.h" 11#include "chrome/browser/automation/automation_provider.h" 12#include "chrome/browser/browser_list.h" 13#include "chrome/browser/history/history.h" 14#include "chrome/browser/sync/profile_sync_service_harness.h" 15#include "chrome/common/notification_registrar.h" 16#include "chrome/common/page_type.h" 17 18class DictionaryValue; 19class TemplateURLModel; 20 21// This is an automation provider containing testing calls. 22class TestingAutomationProvider : public AutomationProvider, 23 public BrowserList::Observer, 24 public NotificationObserver { 25 public: 26 explicit TestingAutomationProvider(Profile* profile); 27 28 // BrowserList::Observer implementation 29 virtual void OnBrowserAdded(const Browser* browser); 30 virtual void OnBrowserRemoved(const Browser* browser); 31 32 // IPC implementations 33 virtual void OnMessageReceived(const IPC::Message& msg); 34 virtual void OnChannelError(); 35 36 private: 37 class PopupMenuWaiter; 38 39 virtual ~TestingAutomationProvider(); 40 41 // IPC Message callbacks. 42 void CloseBrowser(int handle, IPC::Message* reply_message); 43 void CloseBrowserAsync(int browser_handle); 44 void ActivateTab(int handle, int at_index, int* status); 45 void AppendTab(int handle, const GURL& url, IPC::Message* reply_message); 46 void GetActiveTabIndex(int handle, int* active_tab_index); 47 void CloseTab(int tab_handle, bool wait_until_closed, 48 IPC::Message* reply_message); 49 void GetCookies(const GURL& url, int handle, int* value_size, 50 std::string* value); 51 void SetCookie(const GURL& url, 52 const std::string value, 53 int handle, 54 int* response_value); 55 void DeleteCookie(const GURL& url, const std::string& cookie_name, 56 int handle, bool* success); 57 void ShowCollectedCookiesDialog(int handle, bool* success); 58 void NavigateToURL(int handle, const GURL& url, IPC::Message* reply_message); 59 void NavigateToURLBlockUntilNavigationsComplete(int handle, const GURL& url, 60 int number_of_navigations, 61 IPC::Message* reply_message); 62 void NavigationAsync(int handle, const GURL& url, bool* status); 63 void NavigationAsyncWithDisposition(int handle, 64 const GURL& url, 65 WindowOpenDisposition disposition, 66 bool* status); 67 void GoBack(int handle, IPC::Message* reply_message); 68 void GoForward(int handle, IPC::Message* reply_message); 69 void Reload(int handle, IPC::Message* reply_message); 70 void SetAuth(int tab_handle, const std::wstring& username, 71 const std::wstring& password, IPC::Message* reply_message); 72 void CancelAuth(int tab_handle, IPC::Message* reply_message); 73 void NeedsAuth(int tab_handle, bool* needs_auth); 74 void GetRedirectsFrom(int tab_handle, 75 const GURL& source_url, 76 IPC::Message* reply_message); 77 void GetBrowserWindowCount(int* window_count); 78 void GetNormalBrowserWindowCount(int* window_count); 79 // Be aware that the browser window returned might be of non TYPE_NORMAL 80 // or in incognito mode. 81 void GetBrowserWindow(int index, int* handle); 82 void FindNormalBrowserWindow(int* handle); 83 void GetLastActiveBrowserWindow(int* handle); 84 void GetActiveWindow(int* handle); 85 void ExecuteBrowserCommandAsync(int handle, int command, bool* success); 86 void ExecuteBrowserCommand(int handle, int command, 87 IPC::Message* reply_message); 88 void GetBrowserLocale(string16* locale); 89 void IsWindowActive(int handle, bool* success, bool* is_active); 90 void ActivateWindow(int handle); 91 void IsWindowMaximized(int handle, bool* is_maximized, bool* success); 92 void TerminateSession(int handle, bool* success); 93 void WindowGetViewBounds(int handle, int view_id, bool screen_coordinates, 94 bool* success, gfx::Rect* bounds); 95 void GetWindowBounds(int handle, gfx::Rect* bounds, bool* result); 96 void SetWindowBounds(int handle, const gfx::Rect& bounds, bool* result); 97 void SetWindowVisible(int handle, bool visible, bool* result); 98 void WindowSimulateClick(const IPC::Message& message, 99 int handle, 100 const gfx::Point& click, 101 int flags); 102 void WindowSimulateMouseMove(const IPC::Message& message, 103 int handle, 104 const gfx::Point& location); 105 void WindowSimulateKeyPress(const IPC::Message& message, 106 int handle, 107 int key, 108 int flags); 109 void GetTabCount(int handle, int* tab_count); 110 void GetType(int handle, int* type_as_int); 111 void GetTab(int win_handle, int tab_index, int* tab_handle); 112 void GetTabProcessID(int handle, int* process_id); 113 void GetTabTitle(int handle, int* title_string_size, std::wstring* title); 114 void GetTabIndex(int handle, int* tabstrip_index); 115 void GetTabURL(int handle, bool* success, GURL* url); 116 void GetShelfVisibility(int handle, bool* visible); 117 void IsFullscreen(int handle, bool* is_fullscreen); 118 void GetFullscreenBubbleVisibility(int handle, bool* is_visible); 119 void GetAutocompleteEditForBrowser(int browser_handle, bool* success, 120 int* autocomplete_edit_handle); 121 122 // Retrieves the visible text from the autocomplete edit. 123 void GetAutocompleteEditText(int autocomplete_edit_handle, 124 bool* success, std::wstring* text); 125 126 // Sets the visible text from the autocomplete edit. 127 void SetAutocompleteEditText(int autocomplete_edit_handle, 128 const std::wstring& text, 129 bool* success); 130 131 // Retrieves if a query to an autocomplete provider is in progress. 132 void AutocompleteEditIsQueryInProgress(int autocomplete_edit_handle, 133 bool* success, 134 bool* query_in_progress); 135 136 // Retrieves the individual autocomplete matches displayed by the popup. 137 void AutocompleteEditGetMatches(int autocomplete_edit_handle, 138 bool* success, 139 std::vector<AutocompleteMatchData>* matches); 140 141 // Waits for the autocomplete edit to receive focus 142 void WaitForAutocompleteEditFocus(int autocomplete_edit_handle, 143 IPC::Message* reply_message); 144 145 // Deprecated. 146 void ApplyAccelerator(int handle, int id); 147 148 void ExecuteJavascript(int handle, 149 const std::wstring& frame_xpath, 150 const std::wstring& script, 151 IPC::Message* reply_message); 152 153 void GetConstrainedWindowCount(int handle, int* count); 154 155#if defined(TOOLKIT_VIEWS) 156 void GetFocusedViewID(int handle, int* view_id); 157 158 // Block until the focused view ID changes to something other than 159 // previous_view_id. 160 void WaitForFocusedViewIDToChange(int handle, 161 int previous_view_id, 162 IPC::Message* reply_message); 163 164 // Start tracking popup menus. Must be called before executing the 165 // command that might open the popup menu; then call WaitForPopupMenuToOpen. 166 void StartTrackingPopupMenus(int browser_handle, bool* success); 167 168 // Wait until a popup menu has opened. 169 void WaitForPopupMenuToOpen(IPC::Message* reply_message); 170#endif // defined(TOOLKIT_VIEWS) 171 172 void HandleInspectElementRequest(int handle, 173 int x, 174 int y, 175 IPC::Message* reply_message); 176 177 void GetDownloadDirectory(int handle, FilePath* download_directory); 178 179 // If |show| is true, call Show() on the new window after creating it. 180 void OpenNewBrowserWindow(bool show, IPC::Message* reply_message); 181 void OpenNewBrowserWindowOfType(int type, 182 bool show, 183 IPC::Message* reply_message); 184 185 // Retrieves a Browser from a Window and vice-versa. 186 void GetWindowForBrowser(int window_handle, bool* success, int* handle); 187 void GetBrowserForWindow(int window_handle, bool* success, 188 int* browser_handle); 189 190 void ShowInterstitialPage(int tab_handle, 191 const std::string& html_text, 192 IPC::Message* reply_message); 193 void HideInterstitialPage(int tab_handle, bool* success); 194 195 void WaitForTabToBeRestored(int tab_handle, IPC::Message* reply_message); 196 197 // Gets the security state for the tab associated to the specified |handle|. 198 void GetSecurityState(int handle, bool* success, 199 SecurityStyle* security_style, int* ssl_cert_status, 200 int* insecure_content_status); 201 202 // Gets the page type for the tab associated to the specified |handle|. 203 void GetPageType(int handle, bool* success, PageType* page_type); 204 205 // Gets the duration in ms of the last event matching |event_name|. 206 // |duration_ms| is -1 if the event hasn't occurred yet. 207 void GetMetricEventDuration(const std::string& event_name, int* duration_ms); 208 209 // Simulates an action on the SSL blocking page at the tab specified by 210 // |handle|. If |proceed| is true, it is equivalent to the user pressing the 211 // 'Proceed' button, if false the 'Get me out of there button'. 212 // Not that this fails if the tab is not displaying a SSL blocking page. 213 void ActionOnSSLBlockingPage(int handle, 214 bool proceed, 215 IPC::Message* reply_message); 216 217 // Brings the browser window to the front and activates it. 218 void BringBrowserToFront(int browser_handle, bool* success); 219 220 // Checks to see if a command on the browser's CommandController is enabled. 221 void IsMenuCommandEnabled(int browser_handle, 222 int message_num, 223 bool* menu_item_enabled); 224 225 // Prints the current tab immediately. 226 void PrintNow(int tab_handle, IPC::Message* reply_message); 227 228 // Save the current web page. 229 void SavePage(int tab_handle, 230 const FilePath& file_name, 231 const FilePath& dir_path, 232 int type, 233 bool* success); 234 235 // Responds to requests to open the FindInPage window. 236 void HandleOpenFindInPageRequest(const IPC::Message& message, 237 int handle); 238 239 // Get the visibility state of the Find window. 240 void GetFindWindowVisibility(int handle, bool* visible); 241 242 // Responds to requests to find the location of the Find window. 243 void HandleFindWindowLocationRequest(int handle, int* x, int* y); 244 245 // Get the visibility state of the Bookmark bar. 246 void GetBookmarkBarVisibility(int handle, bool* visible, bool* animating); 247 248 // Get the bookmarks as a JSON string. 249 void GetBookmarksAsJSON(int handle, std::string* bookmarks_as_json, 250 bool *success); 251 252 // Wait for the bookmark model to load. 253 void WaitForBookmarkModelToLoad(int handle, IPC::Message* reply_message); 254 255 // Set |loaded| to true if the bookmark model has loaded, else false. 256 void BookmarkModelHasLoaded(int handle, bool* loaded); 257 258 // Editing, modification, and removal of bookmarks. 259 // Bookmarks are referenced by id. 260 void AddBookmarkGroup(int handle, 261 int64 parent_id, int index, std::wstring title, 262 bool* success); 263 void AddBookmarkURL(int handle, 264 int64 parent_id, int index, 265 std::wstring title, const GURL& url, 266 bool* success); 267 void ReparentBookmark(int handle, 268 int64 id, int64 new_parent_id, int index, 269 bool* success); 270 void SetBookmarkTitle(int handle, 271 int64 id, std::wstring title, 272 bool* success); 273 void SetBookmarkURL(int handle, 274 int64 id, const GURL& url, 275 bool* success); 276 void RemoveBookmark(int handle, 277 int64 id, 278 bool* success); 279 280 // Retrieves the number of info-bars currently showing in |count|. 281 void GetInfoBarCount(int handle, int* count); 282 283 // Causes a click on the "accept" button of the info-bar at |info_bar_index|. 284 // If |wait_for_navigation| is true, it sends the reply after a navigation has 285 // occurred. 286 void ClickInfoBarAccept(int handle, int info_bar_index, 287 bool wait_for_navigation, 288 IPC::Message* reply_message); 289 290 // Retrieves the last time a navigation occurred for the tab. 291 void GetLastNavigationTime(int handle, int64* last_navigation_time); 292 293 // Waits for a new navigation in the tab if none has happened since 294 // |last_navigation_time|. 295 void WaitForNavigation(int handle, 296 int64 last_navigation_time, 297 IPC::Message* reply_message); 298 299 // Sets the int value for preference with name |name|. 300 void SetIntPreference(int handle, 301 const std::string& name, 302 int value, 303 bool* success); 304 305 // Sets the string value for preference with name |name|. 306 void SetStringPreference(int handle, 307 const std::string& name, 308 const std::string& value, 309 bool* success); 310 311 // Gets the bool value for preference with name |name|. 312 void GetBooleanPreference(int handle, 313 const std::string& name, 314 bool* success, 315 bool* value); 316 317 // Sets the bool value for preference with name |name|. 318 void SetBooleanPreference(int handle, 319 const std::string& name, 320 bool value, 321 bool* success); 322 323 void GetShowingAppModalDialog(bool* showing_dialog, int* dialog_button); 324 void ClickAppModalDialogButton(int button, bool* success); 325 326 void WaitForBrowserWindowCountToBecome(int target_count, 327 IPC::Message* reply_message); 328 329 void WaitForAppModalDialogToBeShown(IPC::Message* reply_message); 330 331 void GoBackBlockUntilNavigationsComplete(int handle, 332 int number_of_navigations, 333 IPC::Message* reply_message); 334 335 void GoForwardBlockUntilNavigationsComplete(int handle, 336 int number_of_navigations, 337 IPC::Message* reply_message); 338 339 void SavePackageShouldPromptUser(bool should_prompt); 340 341 void GetWindowTitle(int handle, string16* text); 342 343 void SetShelfVisibility(int handle, bool visible); 344 345 // Returns the number of blocked popups in the tab |handle|. 346 void GetBlockedPopupCount(int handle, int* count); 347 348 // Captures the entire page for the given tab and saves it as PNG at the 349 // given path. 350 void CaptureEntirePageAsPNG(int tab_handle, const FilePath& path, 351 IPC::Message* reply_message); 352 353 // Generic pattern for pyautolib 354 // Uses the JSON interface for input/output. 355 void SendJSONRequest(int handle, 356 std::string json_request, 357 IPC::Message* reply_message); 358 359 // Method ptr for json handlers. 360 // Uses the JSON interface for input/output. 361 typedef void (TestingAutomationProvider::*JsonHandler)( 362 Browser* browser, 363 DictionaryValue*, 364 IPC::Message*); 365 366 // Set window dimensions. 367 // Uses the JSON interface for input/output. 368 void SetWindowDimensions(Browser* browser, 369 DictionaryValue* args, 370 IPC::Message* reply_message); 371 372 // Get info about infobars in the given TabContents object. 373 // This includes info about the type of infobars, the message text, 374 // buttons, etc. 375 // Caller owns the returned object. 376 ListValue* GetInfobarsInfo(TabContents* tc); 377 378 // Perform actions on an infobar like dismiss, accept, cancel. 379 // Uses the JSON interface for input/output. 380 void PerformActionOnInfobar(Browser* browser, 381 DictionaryValue* args, 382 IPC::Message* reply_message); 383 384 // Get info about the chromium/chrome in use. 385 // This includes things like version, executable name, executable path. 386 // Uses the JSON interface for input/output. 387 void GetBrowserInfo(Browser* browser, 388 DictionaryValue* args, 389 IPC::Message* reply_message); 390 391 // Get info about the state of navigation in a given tab. 392 // This includes ssl info. 393 // Uses the JSON interface for input/output. 394 void GetNavigationInfo(Browser* browser, 395 DictionaryValue* args, 396 IPC::Message* reply_message); 397 398 // Get info about downloads. This includes only ones that have been 399 // registered by the history system. 400 // Uses the JSON interface for input/output. 401 void GetDownloadsInfo(Browser* browser, 402 DictionaryValue* args, 403 IPC::Message* reply_message); 404 405 // Wait for all downloads to complete. 406 // Uses the JSON interface for input/output. 407 void WaitForDownloadsToComplete(Browser* browser, 408 DictionaryValue* args, 409 IPC::Message* reply_message); 410 411 // Performs the given action on the specified download. 412 // Uses the JSON interface for input/output. 413 void PerformActionOnDownload(Browser* browser, 414 DictionaryValue* args, 415 IPC::Message* reply_message); 416 417 // Get info about history. 418 // Uses the JSON interface for input/output. 419 void GetHistoryInfo(Browser* browser, 420 DictionaryValue* args, 421 IPC::Message* reply_message); 422 423 // Add an item to the history service. 424 // Uses the JSON interface for input/output. 425 void AddHistoryItem(Browser* browser, 426 DictionaryValue* args, 427 IPC::Message* reply_message); 428 429 // Invoke loading of template url model. 430 // Uses the JSON interface for input/output. 431 void LoadSearchEngineInfo(Browser* browser, 432 DictionaryValue* args, 433 IPC::Message* reply_message); 434 435 // Get search engines list. 436 // Assumes that the profile's template url model is loaded. 437 // Uses the JSON interface for input/output. 438 void GetSearchEngineInfo(Browser* browser, 439 DictionaryValue* args, 440 IPC::Message* reply_message); 441 442 // Add or edit search engine. 443 // Assumes that the profile's template url model is loaded. 444 // Uses the JSON interface for input/output. 445 void AddOrEditSearchEngine(Browser* browser, 446 DictionaryValue* args, 447 IPC::Message* reply_message); 448 449 // Perform a given action on an existing search engine. 450 // Assumes that the profile's template url model is loaded. 451 // Uses the JSON interface for input/output. 452 void PerformActionOnSearchEngine(Browser* browser, 453 DictionaryValue* args, 454 IPC::Message* reply_message); 455 456 // Get info about preferences. 457 // Uses the JSON interface for input/output. 458 void GetPrefsInfo(Browser* browser, 459 DictionaryValue* args, 460 IPC::Message* reply_message); 461 462 // Set prefs. 463 // Uses the JSON interface for input/output. 464 void SetPrefs(Browser* browser, 465 DictionaryValue* args, 466 IPC::Message* reply_message); 467 468 // Return load times of initial tabs. 469 // Uses the JSON interface for input/output. 470 // Only includes tabs from command line arguments or session restore. 471 // See declaration of InitialLoadObserver in automation_provider_observers.h 472 // for example response. 473 void GetInitialLoadTimes(Browser* browser, 474 DictionaryValue* args, 475 IPC::Message* reply_message); 476 477 // Get info about plugins. 478 // Uses the JSON interface for input/output. 479 void GetPluginsInfo(Browser* browser, 480 DictionaryValue* args, 481 IPC::Message* reply_message); 482 483 // Enable a plugin. 484 // Uses the JSON interface for input/output. 485 void EnablePlugin(Browser* browser, 486 DictionaryValue* args, 487 IPC::Message* reply_message); 488 489 // Disable a plugin. 490 // Uses the JSON interface for input/output. 491 void DisablePlugin(Browser* browser, 492 DictionaryValue* args, 493 IPC::Message* reply_message); 494 495 // Get info about omnibox. 496 // Contains data about the matches (url, content, description) 497 // in the omnibox popup, the text in the omnibox. 498 // Uses the JSON interface for input/output. 499 void GetOmniboxInfo(Browser* browser, 500 DictionaryValue* args, 501 IPC::Message* reply_message); 502 503 // Set text in the omnibox. This sets focus to the omnibox. 504 // Uses the JSON interface for input/output. 505 void SetOmniboxText(Browser* browser, 506 DictionaryValue* args, 507 IPC::Message* reply_message); 508 509 // Move omnibox popup selection up or down. 510 // Uses the JSON interface for input/output. 511 void OmniboxMovePopupSelection(Browser* browser, 512 DictionaryValue* args, 513 IPC::Message* reply_message); 514 515 // Accept the current string of text in the omnibox. 516 // This is equivalent to clicking or hiting enter on a popup selection. 517 // Blocks until the page loads. 518 // Uses the JSON interface for input/output. 519 void OmniboxAcceptInput(Browser* browser, 520 DictionaryValue* args, 521 IPC::Message* reply_message); 522 523 // Save the contents of a tab into a file. 524 // Uses the JSON interface for input/output. 525 void SaveTabContents(Browser* browser, 526 DictionaryValue* args, 527 IPC::Message* reply_message); 528 529 // Import the given settings from the given browser. 530 // Uses the JSON interface for input/output. 531 void ImportSettings(Browser* browser, 532 DictionaryValue* args, 533 IPC::Message* reply_message); 534 535 // Add a new entry to the password store based on the password information 536 // provided. This method can also be used to add a blacklisted site (which 537 // will never fill in the password). 538 // Uses the JSON interface for input/output. 539 void AddSavedPassword(Browser* browser, 540 DictionaryValue* args, 541 IPC::Message* reply_message); 542 543 // Removes the password matching the information provided. This method can 544 // also be used to remove a blacklisted site. 545 // Uses the JSON interface for input/output. 546 void RemoveSavedPassword(Browser* browser, 547 DictionaryValue* args, 548 IPC::Message* reply_message); 549 550 // Return the saved username/password combinations. 551 // Uses the JSON interface for input/output. 552 void GetSavedPasswords(Browser* browser, 553 DictionaryValue* args, 554 IPC::Message* reply_message); 555 556 // Clear the specified browsing data. This call provides similar 557 // functionality to RemoveBrowsingData but is synchronous. 558 // Uses the JSON interface for input/output. 559 void ClearBrowsingData(Browser* browser, 560 DictionaryValue* args, 561 IPC::Message* reply_message); 562 563 // Get info about blocked popups in a tab. 564 // Uses the JSON interface for input/output. 565 void GetBlockedPopupsInfo(Browser* browser, 566 DictionaryValue* args, 567 IPC::Message* reply_message); 568 569 // Launch a blocked popup. 570 // Uses the JSON interface for input/output. 571 void UnblockAndLaunchBlockedPopup(Browser* browser, 572 DictionaryValue* args, 573 IPC::Message* reply_message); 574 575 // Get info about theme. 576 // Uses the JSON interface for input/output. 577 void GetThemeInfo(Browser* browser, 578 DictionaryValue* args, 579 IPC::Message* reply_message); 580 581 // Get info about all intalled extensions. 582 // Uses the JSON interface for input/output. 583 void GetExtensionsInfo(Browser* browser, 584 DictionaryValue* args, 585 IPC::Message* reply_message); 586 587 // Uninstalls the extension with the given id. 588 // Uses the JSON interface for input/output. 589 void UninstallExtensionById(Browser* browser, 590 DictionaryValue* args, 591 IPC::Message* reply_message); 592 593 // Responds to the Find request and returns the match count. 594 void FindInPage(Browser* browser, 595 DictionaryValue* args, 596 IPC::Message* reply_message); 597 598 // Returns information about translation for a given tab. Includes 599 // information about the translate bar if it is showing. 600 void GetTranslateInfo(Browser* browser, 601 DictionaryValue* args, 602 IPC::Message* reply_message); 603 604 // Takes the specified action on the translate bar. 605 // Uses the JSON interface for input/output. 606 void SelectTranslateOption(Browser* browser, 607 DictionaryValue* args, 608 IPC::Message* reply_message); 609 610 // Get the profiles that are currently saved to the DB. 611 // Uses the JSON interface for input/output. 612 void GetAutoFillProfile(Browser* browser, 613 DictionaryValue* args, 614 IPC::Message* reply_message); 615 616 // Fill in an AutoFillProfile with the given profile information. 617 // Uses the JSON interface for input/output. 618 void FillAutoFillProfile(Browser* browser, 619 DictionaryValue* args, 620 IPC::Message* reply_message); 621 622 // Signs in to sync using the given username and password. 623 // Uses the JSON interface for input/output. 624 void SignInToSync(Browser* browser, 625 DictionaryValue* args, 626 IPC::Message* reply_message); 627 628 // Returns info about sync. 629 // Uses the JSON interface for input/output. 630 void GetSyncInfo(Browser* browser, 631 DictionaryValue* args, 632 IPC::Message* reply_message); 633 634 // Waits for the ongoing sync cycle to complete. 635 // Uses the JSON interface for input/output. 636 void AwaitSyncCycleCompletion(Browser* browser, 637 DictionaryValue* args, 638 IPC::Message* reply_message); 639 640 // Enables sync for one or more sync datatypes. 641 // Uses the JSON interface for input/output. 642 void EnableSyncForDatatypes(Browser* browser, 643 DictionaryValue* args, 644 IPC::Message* reply_message); 645 646 // Disables sync for one or more sync datatypes. 647 // Uses the JSON interface for input/output. 648 void DisableSyncForDatatypes(Browser* browser, 649 DictionaryValue* args, 650 IPC::Message* reply_message); 651 652 // Translate DictionaryValues of autofill profiles and credit cards to the 653 // data structure used in the browser. 654 // Args: 655 // profiles/cards: the ListValue of profiles/credit cards to translate. 656 // error_message: a pointer to the return string in case of error. 657 static std::vector<AutoFillProfile> GetAutoFillProfilesFromList( 658 const ListValue& profiles, std::string* error_message); 659 static std::vector<CreditCard> GetCreditCardsFromList( 660 const ListValue& cards, std::string* error_message); 661 662 // The opposite of the above: translates from the internal data structure 663 // for profiles and credit cards to a ListValue of DictionaryValues. The 664 // caller owns the returned object. 665 static ListValue* GetListFromAutoFillProfiles( 666 const std::vector<AutoFillProfile*>& autofill_profiles); 667 static ListValue* GetListFromCreditCards( 668 const std::vector<CreditCard*>& credit_cards); 669 670 // Return the map from the internal data representation to the string value 671 // of auto fill fields and credit card fields. 672 static std::map<AutoFillFieldType, std::wstring> 673 GetAutoFillFieldToStringMap(); 674 static std::map<AutoFillFieldType, std::wstring> 675 GetCreditCardFieldToStringMap(); 676 677 // Get a list of active HTML5 notifications. 678 // Uses the JSON interface for input/output. 679 void GetActiveNotifications(Browser* browser, 680 DictionaryValue* args, 681 IPC::Message* reply_message); 682 683 // Close an active HTML5 notification. 684 // Uses the JSON interface for input/output. 685 void CloseNotification(Browser* browser, 686 DictionaryValue* args, 687 IPC::Message* reply_message); 688 689 // Waits for the number of active HTML5 notifications to reach a given count. 690 // Uses the JSON interface for input/output. 691 void WaitForNotificationCount(Browser* browser, 692 DictionaryValue* args, 693 IPC::Message* reply_message); 694 695 // Gets info about the elements in the NTP. 696 // Uses the JSON interface for input/output. 697 void GetNTPInfo(Browser* browser, 698 DictionaryValue* args, 699 IPC::Message* reply_message); 700 701 // Moves a thumbnail in the NTP's Most Visited sites section to a different 702 // index. 703 // Uses the JSON interface for input/output. 704 void MoveNTPMostVisitedThumbnail(Browser* browser, 705 DictionaryValue* args, 706 IPC::Message* reply_message); 707 708 // Removes a thumbnail from the NTP's Most Visited sites section. 709 // Uses the JSON interface for input/output. 710 void RemoveNTPMostVisitedThumbnail(Browser* browser, 711 DictionaryValue* args, 712 IPC::Message* reply_message); 713 714 // Unpins a thumbnail in the NTP's Most Visited sites section. 715 // Uses the JSON interface for input/output. 716 void UnpinNTPMostVisitedThumbnail(Browser* browser, 717 DictionaryValue* args, 718 IPC::Message* reply_message); 719 720 // Restores all thumbnails that have been removed (i.e., blacklisted) from the 721 // NTP's Most Visited sites section. 722 // Uses the JSON interface for input/output. 723 void RestoreAllNTPMostVisitedThumbnails(Browser* browser, 724 DictionaryValue* args, 725 IPC::Message* reply_message); 726 727 void WaitForTabCountToBecome(int browser_handle, 728 int target_tab_count, 729 IPC::Message* reply_message); 730 731 void WaitForInfoBarCount(int tab_handle, 732 int target_count, 733 IPC::Message* reply_message); 734 735 // Gets the current used encoding name of the page in the specified tab. 736 void GetPageCurrentEncoding(int tab_handle, std::string* current_encoding); 737 738 void ShutdownSessionService(int handle, bool* result); 739 740 void SetContentSetting(int handle, 741 const std::string& host, 742 ContentSettingsType content_type, 743 ContentSetting setting, 744 bool* success); 745 746 // Load all plug-ins on the page. 747 void LoadBlockedPlugins(int tab_handle, bool* success); 748 749 // Resets to the default theme. 750 void ResetToDefaultTheme(); 751 752 // Callback for history redirect queries. 753 virtual void OnRedirectQueryComplete( 754 HistoryService::Handle request_handle, 755 GURL from_url, 756 bool success, 757 history::RedirectList* redirects); 758 759 virtual void Observe(NotificationType type, 760 const NotificationSource& source, 761 const NotificationDetails& details); 762 763 void OnRemoveProvider(); // Called via PostTask 764 765#if defined(TOOLKIT_VIEWS) 766 // Keep track of whether a popup menu has been opened since the last time 767 // that StartTrackingPopupMenus has been called. 768 bool popup_menu_opened_; 769 770 // A temporary object that receives a notification when a popup menu opens. 771 PopupMenuWaiter* popup_menu_waiter_; 772#endif // defined(TOOLKIT_VIEWS) 773 774 // Used to wait on various browser sync events. 775 scoped_ptr<ProfileSyncServiceHarness> sync_waiter_; 776 777 // Handle for an in-process redirect query. We expect only one redirect query 778 // at a time (we should have only one caller, and it will block while waiting 779 // for the results) so there is only one handle. When non-0, indicates a 780 // query in progress. 781 HistoryService::Handle redirect_query_; 782 783 NotificationRegistrar registrar_; 784 785 DISALLOW_COPY_AND_ASSIGN(TestingAutomationProvider); 786}; 787 788#endif // CHROME_BROWSER_AUTOMATION_TESTING_AUTOMATION_PROVIDER_H_ 789