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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_ 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_ 7 8 #include <memory> 9 #include <string> 10 #include <vector> 11 12 #include "ash/display/screen_orientation_controller.h" 13 #include "ash/public/cpp/assistant/assistant_state.h" 14 #include "ash/rotator/screen_rotation_animator_observer.h" 15 #include "base/compiler_specific.h" 16 #include "base/optional.h" 17 #include "base/scoped_observer.h" 18 #include "base/timer/timer.h" 19 #include "chrome/browser/chromeos/printing/cups_printers_manager.h" 20 #include "chrome/browser/chromeos/settings/stats_reporting_controller.h" 21 #include "chrome/browser/web_applications/components/web_app_id.h" 22 #include "chromeos/services/machine_learning/public/mojom/machine_learning_service.mojom-forward.h" 23 #include "chromeos/services/machine_learning/public/mojom/model.mojom.h" 24 #include "chromeos/ui/base/window_state_type.h" 25 #include "extensions/browser/browser_context_keyed_api_factory.h" 26 #include "extensions/browser/extension_function.h" 27 #include "mojo/public/cpp/bindings/remote.h" 28 #include "ui/base/clipboard/clipboard_monitor.h" 29 #include "ui/base/clipboard/clipboard_observer.h" 30 #include "ui/display/display.h" 31 #include "ui/snapshot/screenshot_grabber.h" 32 33 namespace crostini { 34 enum class CrostiniResult; 35 } 36 37 namespace extensions { 38 39 class AssistantInteractionHelper; 40 class WindowStateChangeObserver; 41 class WindowBoundsChangeObserver; 42 class EventGenerator; 43 44 class AutotestPrivateInitializeEventsFunction : public ExtensionFunction { 45 public: 46 DECLARE_EXTENSION_FUNCTION("autotestPrivate.initializeEvents", 47 AUTOTESTPRIVATE_INITIALIZEEVENTS) 48 49 private: 50 ~AutotestPrivateInitializeEventsFunction() override; 51 ResponseAction Run() override; 52 }; 53 54 class AutotestPrivateLogoutFunction : public ExtensionFunction { 55 public: 56 DECLARE_EXTENSION_FUNCTION("autotestPrivate.logout", AUTOTESTPRIVATE_LOGOUT) 57 58 private: 59 ~AutotestPrivateLogoutFunction() override; 60 ResponseAction Run() override; 61 }; 62 63 class AutotestPrivateRestartFunction : public ExtensionFunction { 64 public: 65 DECLARE_EXTENSION_FUNCTION("autotestPrivate.restart", AUTOTESTPRIVATE_RESTART) 66 67 private: 68 ~AutotestPrivateRestartFunction() override; 69 ResponseAction Run() override; 70 }; 71 72 class AutotestPrivateShutdownFunction : public ExtensionFunction { 73 public: 74 DECLARE_EXTENSION_FUNCTION("autotestPrivate.shutdown", 75 AUTOTESTPRIVATE_SHUTDOWN) 76 77 private: 78 ~AutotestPrivateShutdownFunction() override; 79 ResponseAction Run() override; 80 }; 81 82 class AutotestPrivateLoginStatusFunction : public ExtensionFunction { 83 public: 84 DECLARE_EXTENSION_FUNCTION("autotestPrivate.loginStatus", 85 AUTOTESTPRIVATE_LOGINSTATUS) 86 87 private: 88 ~AutotestPrivateLoginStatusFunction() override; 89 ResponseAction Run() override; 90 }; 91 92 class AutotestPrivateLockScreenFunction : public ExtensionFunction { 93 public: 94 DECLARE_EXTENSION_FUNCTION("autotestPrivate.lockScreen", 95 AUTOTESTPRIVATE_LOCKSCREEN) 96 97 private: 98 ~AutotestPrivateLockScreenFunction() override; 99 ResponseAction Run() override; 100 }; 101 102 class AutotestPrivateGetExtensionsInfoFunction : public ExtensionFunction { 103 public: 104 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getExtensionsInfo", 105 AUTOTESTPRIVATE_GETEXTENSIONSINFO) 106 107 private: 108 ~AutotestPrivateGetExtensionsInfoFunction() override; 109 ResponseAction Run() override; 110 }; 111 112 class AutotestPrivateSimulateAsanMemoryBugFunction : public ExtensionFunction { 113 public: 114 DECLARE_EXTENSION_FUNCTION("autotestPrivate.simulateAsanMemoryBug", 115 AUTOTESTPRIVATE_SIMULATEASANMEMORYBUG) 116 117 private: 118 ~AutotestPrivateSimulateAsanMemoryBugFunction() override; 119 ResponseAction Run() override; 120 }; 121 122 class AutotestPrivateSetTouchpadSensitivityFunction : public ExtensionFunction { 123 public: 124 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTouchpadSensitivity", 125 AUTOTESTPRIVATE_SETTOUCHPADSENSITIVITY) 126 127 private: 128 ~AutotestPrivateSetTouchpadSensitivityFunction() override; 129 ResponseAction Run() override; 130 }; 131 132 class AutotestPrivateSetTapToClickFunction : public ExtensionFunction { 133 public: 134 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTapToClick", 135 AUTOTESTPRIVATE_SETTAPTOCLICK) 136 137 private: 138 ~AutotestPrivateSetTapToClickFunction() override; 139 ResponseAction Run() override; 140 }; 141 142 class AutotestPrivateSetThreeFingerClickFunction : public ExtensionFunction { 143 public: 144 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setThreeFingerClick", 145 AUTOTESTPRIVATE_SETTHREEFINGERCLICK) 146 147 private: 148 ~AutotestPrivateSetThreeFingerClickFunction() override; 149 ResponseAction Run() override; 150 }; 151 152 class AutotestPrivateSetTapDraggingFunction : public ExtensionFunction { 153 public: 154 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTapDragging", 155 AUTOTESTPRIVATE_SETTAPDRAGGING) 156 157 private: 158 ~AutotestPrivateSetTapDraggingFunction() override; 159 ResponseAction Run() override; 160 }; 161 162 class AutotestPrivateSetNaturalScrollFunction : public ExtensionFunction { 163 public: 164 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setNaturalScroll", 165 AUTOTESTPRIVATE_SETNATURALSCROLL) 166 167 private: 168 ~AutotestPrivateSetNaturalScrollFunction() override; 169 ResponseAction Run() override; 170 }; 171 172 class AutotestPrivateSetMouseSensitivityFunction : public ExtensionFunction { 173 public: 174 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setMouseSensitivity", 175 AUTOTESTPRIVATE_SETMOUSESENSITIVITY) 176 177 private: 178 ~AutotestPrivateSetMouseSensitivityFunction() override; 179 ResponseAction Run() override; 180 }; 181 182 class AutotestPrivateSetPrimaryButtonRightFunction : public ExtensionFunction { 183 public: 184 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setPrimaryButtonRight", 185 AUTOTESTPRIVATE_SETPRIMARYBUTTONRIGHT) 186 187 private: 188 ~AutotestPrivateSetPrimaryButtonRightFunction() override; 189 ResponseAction Run() override; 190 }; 191 192 class AutotestPrivateSetMouseReverseScrollFunction : public ExtensionFunction { 193 public: 194 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setMouseReverseScroll", 195 AUTOTESTPRIVATE_SETMOUSEREVERSESCROLL) 196 197 private: 198 ~AutotestPrivateSetMouseReverseScrollFunction() override; 199 ResponseAction Run() override; 200 }; 201 202 class AutotestPrivateGetVisibleNotificationsFunction 203 : public ExtensionFunction { 204 public: 205 AutotestPrivateGetVisibleNotificationsFunction(); 206 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getVisibleNotifications", 207 AUTOTESTPRIVATE_GETVISIBLENOTIFICATIONS) 208 209 private: 210 ~AutotestPrivateGetVisibleNotificationsFunction() override; 211 ResponseAction Run() override; 212 }; 213 214 class AutotestPrivateRemoveAllNotificationsFunction : public ExtensionFunction { 215 public: 216 AutotestPrivateRemoveAllNotificationsFunction(); 217 DECLARE_EXTENSION_FUNCTION("autotestPrivate.removeAllNotifications", 218 AUTOTESTPRIVATE_REMOVEALLNOTIFICATIONS) 219 220 private: 221 ~AutotestPrivateRemoveAllNotificationsFunction() override; 222 ResponseAction Run() override; 223 }; 224 225 class AutotestPrivateGetPlayStoreStateFunction : public ExtensionFunction { 226 public: 227 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getPlayStoreState", 228 AUTOTESTPRIVATE_GETPLAYSTORESTATE) 229 230 private: 231 ~AutotestPrivateGetPlayStoreStateFunction() override; 232 ResponseAction Run() override; 233 }; 234 235 class AutotestPrivateGetArcStartTimeFunction : public ExtensionFunction { 236 public: 237 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getArcStartTime", 238 AUTOTESTPRIVATE_GETARCSTARTTIME) 239 240 private: 241 ~AutotestPrivateGetArcStartTimeFunction() override; 242 ResponseAction Run() override; 243 }; 244 245 class AutotestPrivateGetArcStateFunction : public ExtensionFunction { 246 public: 247 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getArcState", 248 AUTOTESTPRIVATE_GETARCSTATE) 249 250 private: 251 ~AutotestPrivateGetArcStateFunction() override; 252 ResponseAction Run() override; 253 }; 254 255 class AutotestPrivateSetPlayStoreEnabledFunction : public ExtensionFunction { 256 public: 257 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setPlayStoreEnabled", 258 AUTOTESTPRIVATE_SETPLAYSTOREENABLED) 259 260 private: 261 ~AutotestPrivateSetPlayStoreEnabledFunction() override; 262 ResponseAction Run() override; 263 }; 264 265 class AutotestPrivateIsAppShownFunction : public ExtensionFunction { 266 public: 267 DECLARE_EXTENSION_FUNCTION("autotestPrivate.isAppShown", 268 AUTOTESTPRIVATE_ISAPPSHOWN) 269 270 private: 271 ~AutotestPrivateIsAppShownFunction() override; 272 ResponseAction Run() override; 273 }; 274 275 // Deprecated, use GetArcState instead. 276 class AutotestPrivateIsArcProvisionedFunction : public ExtensionFunction { 277 public: 278 DECLARE_EXTENSION_FUNCTION("autotestPrivate.isArcProvisioned", 279 AUTOTESTPRIVATE_ISARCPROVISIONED) 280 281 private: 282 ~AutotestPrivateIsArcProvisionedFunction() override; 283 ResponseAction Run() override; 284 }; 285 286 class AutotestPrivateGetArcAppFunction : public ExtensionFunction { 287 public: 288 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getArcApp", 289 AUTOTESTPRIVATE_GETARCAPP) 290 291 private: 292 ~AutotestPrivateGetArcAppFunction() override; 293 ResponseAction Run() override; 294 }; 295 296 class AutotestPrivateGetArcPackageFunction : public ExtensionFunction { 297 public: 298 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getArcPackage", 299 AUTOTESTPRIVATE_GETARCPACKAGE) 300 301 private: 302 ~AutotestPrivateGetArcPackageFunction() override; 303 ResponseAction Run() override; 304 }; 305 306 class AutotestPrivateWaitForSystemWebAppsInstallFunction 307 : public ExtensionFunction { 308 public: 309 AutotestPrivateWaitForSystemWebAppsInstallFunction(); 310 DECLARE_EXTENSION_FUNCTION( 311 "autotestPrivate.waitForSystemWebAppsInstall", 312 AUTOTESTPRIVATE_WAITFORSYSTEMWEBAPPSINSTALLFUNCTION) 313 314 private: 315 ~AutotestPrivateWaitForSystemWebAppsInstallFunction() override; 316 ResponseAction Run() override; 317 }; 318 319 class AutotestPrivateGetRegisteredSystemWebAppsFunction 320 : public ExtensionFunction { 321 public: 322 AutotestPrivateGetRegisteredSystemWebAppsFunction(); 323 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getRegisteredSystemWebApps", 324 AUTOTESTPRIVATE_GETREGISTEREDSYSTEMWEBAPPSFUNCTION) 325 326 private: 327 ~AutotestPrivateGetRegisteredSystemWebAppsFunction() override; 328 ResponseAction Run() override; 329 }; 330 331 class AutotestPrivateLaunchArcAppFunction : public ExtensionFunction { 332 public: 333 DECLARE_EXTENSION_FUNCTION("autotestPrivate.launchArcApp", 334 AUTOTESTPRIVATE_LAUNCHARCAPP) 335 336 private: 337 ~AutotestPrivateLaunchArcAppFunction() override; 338 ResponseAction Run() override; 339 }; 340 341 class AutotestPrivateLaunchAppFunction : public ExtensionFunction { 342 public: 343 DECLARE_EXTENSION_FUNCTION("autotestPrivate.launchApp", 344 AUTOTESTPRIVATE_LAUNCHAPP) 345 346 private: 347 ~AutotestPrivateLaunchAppFunction() override; 348 ResponseAction Run() override; 349 }; 350 351 class AutotestPrivateLaunchSystemWebAppFunction : public ExtensionFunction { 352 public: 353 DECLARE_EXTENSION_FUNCTION("autotestPrivate.launchSystemWebApp", 354 AUTOTESTPRIVATE_LAUNCHSYSTEMWEBAPP) 355 356 private: 357 ~AutotestPrivateLaunchSystemWebAppFunction() override; 358 ResponseAction Run() override; 359 }; 360 361 class AutotestPrivateCloseAppFunction : public ExtensionFunction { 362 public: 363 DECLARE_EXTENSION_FUNCTION("autotestPrivate.closeApp", 364 AUTOTESTPRIVATE_CLOSEAPP) 365 366 private: 367 ~AutotestPrivateCloseAppFunction() override; 368 ResponseAction Run() override; 369 }; 370 371 class AutotestPrivateGetClipboardTextDataFunction : public ExtensionFunction { 372 public: 373 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getClipboardTextData", 374 AUTOTESTPRIVATE_GETCLIPBOARDTEXTDATA) 375 376 private: 377 ~AutotestPrivateGetClipboardTextDataFunction() override; 378 ResponseAction Run() override; 379 }; 380 381 class AutotestPrivateSetClipboardTextDataFunction : public ExtensionFunction { 382 public: 383 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setClipboardTextData", 384 AUTOTESTPRIVATE_SETCLIPBOARDTEXTDATA) 385 386 private: 387 ~AutotestPrivateSetClipboardTextDataFunction() override; 388 ResponseAction Run() override; 389 }; 390 391 class AutotestPrivateSetCrostiniEnabledFunction : public ExtensionFunction { 392 public: 393 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setCrostiniEnabled", 394 AUTOTESTPRIVATE_SETCROSTINIENABLED) 395 396 private: 397 ~AutotestPrivateSetCrostiniEnabledFunction() override; 398 ResponseAction Run() override; 399 }; 400 401 class AutotestPrivateRunCrostiniInstallerFunction : public ExtensionFunction { 402 public: 403 DECLARE_EXTENSION_FUNCTION("autotestPrivate.runCrostiniInstaller", 404 AUTOTESTPRIVATE_RUNCROSTINIINSTALLER) 405 406 private: 407 ~AutotestPrivateRunCrostiniInstallerFunction() override; 408 ResponseAction Run() override; 409 410 void CrostiniRestarted(crostini::CrostiniResult); 411 }; 412 413 class AutotestPrivateRunCrostiniUninstallerFunction : public ExtensionFunction { 414 public: 415 DECLARE_EXTENSION_FUNCTION("autotestPrivate.runCrostiniUninstaller", 416 AUTOTESTPRIVATE_RUNCROSTINIUNINSTALLER) 417 418 private: 419 ~AutotestPrivateRunCrostiniUninstallerFunction() override; 420 ResponseAction Run() override; 421 422 void CrostiniRemoved(crostini::CrostiniResult); 423 }; 424 425 class AutotestPrivateExportCrostiniFunction : public ExtensionFunction { 426 public: 427 DECLARE_EXTENSION_FUNCTION("autotestPrivate.exportCrostini", 428 AUTOTESTPRIVATE_EXPORTCROSTINI) 429 430 private: 431 ~AutotestPrivateExportCrostiniFunction() override; 432 ResponseAction Run() override; 433 434 void CrostiniExported(crostini::CrostiniResult); 435 }; 436 437 class AutotestPrivateImportCrostiniFunction : public ExtensionFunction { 438 public: 439 DECLARE_EXTENSION_FUNCTION("autotestPrivate.importCrostini", 440 AUTOTESTPRIVATE_IMPORTCROSTINI) 441 442 private: 443 ~AutotestPrivateImportCrostiniFunction() override; 444 ResponseAction Run() override; 445 446 void CrostiniImported(crostini::CrostiniResult); 447 }; 448 449 class AutotestPrivateSetPluginVMPolicyFunction : public ExtensionFunction { 450 public: 451 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setPluginVMPolicy", 452 AUTOTESTPRIVATE_SETPLUGINVMPOLICY) 453 454 private: 455 ~AutotestPrivateSetPluginVMPolicyFunction() override; 456 ResponseAction Run() override; 457 }; 458 459 class AutotestPrivateShowPluginVMInstallerFunction : public ExtensionFunction { 460 public: 461 DECLARE_EXTENSION_FUNCTION("autotestPrivate.showPluginVMInstaller", 462 AUTOTESTPRIVATE_SHOWPLUGINVMINSTALLER) 463 464 private: 465 ~AutotestPrivateShowPluginVMInstallerFunction() override; 466 ResponseAction Run() override; 467 }; 468 469 class AutotestPrivateRegisterComponentFunction : public ExtensionFunction { 470 public: 471 DECLARE_EXTENSION_FUNCTION("autotestPrivate.registerComponent", 472 AUTOTESTPRIVATE_REGISTERCOMPONENT) 473 474 private: 475 ~AutotestPrivateRegisterComponentFunction() override; 476 ResponseAction Run() override; 477 }; 478 479 class AutotestPrivateTakeScreenshotFunction : public ExtensionFunction { 480 public: 481 DECLARE_EXTENSION_FUNCTION("autotestPrivate.takeScreenshot", 482 AUTOTESTPRIVATE_TAKESCREENSHOT) 483 484 private: 485 ~AutotestPrivateTakeScreenshotFunction() override; 486 ResponseAction Run() override; 487 488 void ScreenshotTaken(std::unique_ptr<ui::ScreenshotGrabber> grabber, 489 ui::ScreenshotResult screenshot_result, 490 scoped_refptr<base::RefCountedMemory> png_data); 491 }; 492 493 class AutotestPrivateTakeScreenshotForDisplayFunction 494 : public ExtensionFunction { 495 public: 496 DECLARE_EXTENSION_FUNCTION("autotestPrivate.takeScreenshotForDisplay", 497 AUTOTESTPRIVATE_TAKESCREENSHOTFORDISPLAY) 498 499 private: 500 ~AutotestPrivateTakeScreenshotForDisplayFunction() override; 501 ResponseAction Run() override; 502 503 void ScreenshotTaken(std::unique_ptr<ui::ScreenshotGrabber> grabber, 504 ui::ScreenshotResult screenshot_result, 505 scoped_refptr<base::RefCountedMemory> png_data); 506 }; 507 508 class AutotestPrivateGetPrinterListFunction 509 : public ExtensionFunction, 510 public chromeos::CupsPrintersManager::Observer { 511 public: 512 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getPrinterList", 513 AUTOTESTPRIVATE_GETPRINTERLIST) 514 AutotestPrivateGetPrinterListFunction(); 515 516 private: 517 ~AutotestPrivateGetPrinterListFunction() override; 518 ResponseAction Run() override; 519 520 void DestroyPrintersManager(); 521 void RespondWithTimeoutError(); 522 void RespondWithSuccess(); 523 524 // chromeos::CupsPrintersManager::Observer 525 void OnEnterprisePrintersInitialized() override; 526 527 std::unique_ptr<base::Value> results_; 528 std::unique_ptr<chromeos::CupsPrintersManager> printers_manager_; 529 base::OneShotTimer timeout_timer_; 530 }; 531 532 class AutotestPrivateUpdatePrinterFunction : public ExtensionFunction { 533 public: 534 DECLARE_EXTENSION_FUNCTION("autotestPrivate.updatePrinter", 535 AUTOTESTPRIVATE_UPDATEPRINTER) 536 537 private: 538 ~AutotestPrivateUpdatePrinterFunction() override; 539 ResponseAction Run() override; 540 }; 541 542 class AutotestPrivateRemovePrinterFunction : public ExtensionFunction { 543 public: 544 DECLARE_EXTENSION_FUNCTION("autotestPrivate.removePrinter", 545 AUTOTESTPRIVATE_REMOVEPRINTER) 546 547 private: 548 ~AutotestPrivateRemovePrinterFunction() override; 549 ResponseAction Run() override; 550 }; 551 552 class AutotestPrivateGetAllEnterprisePoliciesFunction 553 : public ExtensionFunction { 554 public: 555 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getAllEnterprisePolicies", 556 AUTOTESTPRIVATE_GETALLENTERPRISEPOLICIES) 557 558 private: 559 ~AutotestPrivateGetAllEnterprisePoliciesFunction() override; 560 ResponseAction Run() override; 561 }; 562 563 class AutotestPrivateRefreshEnterprisePoliciesFunction 564 : public ExtensionFunction { 565 public: 566 DECLARE_EXTENSION_FUNCTION("autotestPrivate.refreshEnterprisePolicies", 567 AUTOTESTPRIVATE_REFRESHENTERPRISEPOLICIES) 568 569 private: 570 ~AutotestPrivateRefreshEnterprisePoliciesFunction() override; 571 ResponseAction Run() override; 572 573 // Called once all the policies have been refreshed. 574 void RefreshDone(); 575 }; 576 577 class AutotestPrivateBootstrapMachineLearningServiceFunction 578 : public ExtensionFunction { 579 public: 580 AutotestPrivateBootstrapMachineLearningServiceFunction(); 581 DECLARE_EXTENSION_FUNCTION("autotestPrivate.bootstrapMachineLearningService", 582 AUTOTESTPRIVATE_BOOTSTRAPMACHINELEARNINGSERVICE) 583 584 private: 585 ~AutotestPrivateBootstrapMachineLearningServiceFunction() override; 586 ResponseAction Run() override; 587 588 // Callbacks for a basic Mojo call to MachineLearningService.LoadModel. 589 void ModelLoaded(chromeos::machine_learning::mojom::LoadModelResult result); 590 void OnMojoDisconnect(); 591 592 mojo::Remote<chromeos::machine_learning::mojom::Model> model_; 593 }; 594 595 // Enable/disable the Google Assistant feature. This toggles the Assistant user 596 // pref which will indirectly bring up or shut down the Assistant service. 597 class AutotestPrivateSetAssistantEnabledFunction 598 : public ExtensionFunction, 599 public ash::AssistantStateObserver { 600 public: 601 AutotestPrivateSetAssistantEnabledFunction(); 602 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setAssistantEnabled", 603 AUTOTESTPRIVATE_SETASSISTANTENABLED) 604 605 private: 606 ~AutotestPrivateSetAssistantEnabledFunction() override; 607 ResponseAction Run() override; 608 609 // ash::AssistantStateObserver overrides: 610 void OnAssistantStatusChanged( 611 chromeos::assistant::AssistantStatus status) override; 612 613 // Called when the Assistant service does not respond in a timely fashion. We 614 // will respond with an error. 615 void Timeout(); 616 617 base::Optional<bool> enabled_; 618 base::OneShotTimer timeout_timer_; 619 }; 620 621 // Bring up the Assistant service, and wait until the ready signal is received. 622 class AutotestPrivateEnableAssistantAndWaitForReadyFunction 623 : public ExtensionFunction, 624 public ash::AssistantStateObserver { 625 public: 626 AutotestPrivateEnableAssistantAndWaitForReadyFunction(); 627 DECLARE_EXTENSION_FUNCTION("autotestPrivate.enableAssistantAndWaitForReady", 628 AUTOTESTPRIVATE_ENABLEASSISTANTANDWAITFORREADY) 629 630 private: 631 ~AutotestPrivateEnableAssistantAndWaitForReadyFunction() override; 632 ResponseAction Run() override; 633 634 void SubscribeToStatusChanges(); 635 636 // ash::AssistantStateObserver overrides: 637 void OnAssistantStatusChanged( 638 chromeos::assistant::AssistantStatus status) override; 639 640 // A reference to keep |this| alive while waiting for the Assistant to 641 // respond. 642 scoped_refptr<ExtensionFunction> self_; 643 }; 644 645 // Send text query to Assistant and return response. 646 class AutotestPrivateSendAssistantTextQueryFunction : public ExtensionFunction { 647 public: 648 AutotestPrivateSendAssistantTextQueryFunction(); 649 DECLARE_EXTENSION_FUNCTION("autotestPrivate.sendAssistantTextQuery", 650 AUTOTESTPRIVATE_SENDASSISTANTTEXTQUERY) 651 652 private: 653 ~AutotestPrivateSendAssistantTextQueryFunction() override; 654 ResponseAction Run() override; 655 656 // Called when the interaction finished with non-empty response. 657 void OnInteractionFinishedCallback(const base::Optional<std::string>& error); 658 659 // Called when Assistant service fails to respond in a certain amount of 660 // time. We will respond with an error. 661 void Timeout(); 662 663 std::unique_ptr<AssistantInteractionHelper> interaction_helper_; 664 base::OneShotTimer timeout_timer_; 665 }; 666 667 // Wait for the next text/voice query interaction completed and respond with 668 // the query status if any valid response was caught before time out. 669 class AutotestPrivateWaitForAssistantQueryStatusFunction 670 : public ExtensionFunction { 671 public: 672 AutotestPrivateWaitForAssistantQueryStatusFunction(); 673 DECLARE_EXTENSION_FUNCTION("autotestPrivate.waitForAssistantQueryStatus", 674 AUTOTESTPRIVATE_WAITFORASSISTANTQUERYSTATUS) 675 676 private: 677 ~AutotestPrivateWaitForAssistantQueryStatusFunction() override; 678 ResponseAction Run() override; 679 680 // Called when the current interaction finished with non-empty response. 681 void OnInteractionFinishedCallback(const base::Optional<std::string>& error); 682 683 // Called when Assistant service fails to respond in a certain amount of 684 // time. We will respond with an error. 685 void Timeout(); 686 687 std::unique_ptr<AssistantInteractionHelper> interaction_helper_; 688 base::OneShotTimer timeout_timer_; 689 }; 690 691 class AutotestPrivateIsArcPackageListInitialRefreshedFunction 692 : public ExtensionFunction { 693 public: 694 AutotestPrivateIsArcPackageListInitialRefreshedFunction(); 695 DECLARE_EXTENSION_FUNCTION("autotestPrivate.isArcPackageListInitialRefreshed", 696 AUTOTESTPRIVATE_ISARCPACKAGELISTINITIALREFRESHED) 697 698 private: 699 ~AutotestPrivateIsArcPackageListInitialRefreshedFunction() override; 700 ResponseAction Run() override; 701 }; 702 703 // Set user pref value in the pref tree. 704 class AutotestPrivateSetWhitelistedPrefFunction : public ExtensionFunction { 705 public: 706 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setWhitelistedPref", 707 AUTOTESTPRIVATE_SETWHITELISTEDPREF) 708 709 private: 710 ~AutotestPrivateSetWhitelistedPrefFunction() override; 711 ResponseAction Run() override; 712 }; 713 714 // Enable/disable a Crostini app's "scaled" property. 715 // When an app is "scaled", it will use low display density. 716 class AutotestPrivateSetCrostiniAppScaledFunction : public ExtensionFunction { 717 public: 718 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setCrostiniAppScaled", 719 AUTOTESTPRIVATE_SETCROSTINIAPPSCALED) 720 private: 721 ~AutotestPrivateSetCrostiniAppScaledFunction() override; 722 ResponseAction Run() override; 723 }; 724 725 // The profile-keyed service that manages the autotestPrivate extension API. 726 class AutotestPrivateAPI : public BrowserContextKeyedAPI, 727 public ui::ClipboardObserver { 728 public: 729 static BrowserContextKeyedAPIFactory<AutotestPrivateAPI>* 730 GetFactoryInstance(); 731 732 // TODO(achuith): Replace these with a mock object for system calls. test_mode()733 bool test_mode() const { return test_mode_; } set_test_mode(bool test_mode)734 void set_test_mode(bool test_mode) { test_mode_ = test_mode; } 735 736 private: 737 friend class BrowserContextKeyedAPIFactory<AutotestPrivateAPI>; 738 739 explicit AutotestPrivateAPI(content::BrowserContext* context); 740 ~AutotestPrivateAPI() override; 741 742 // BrowserContextKeyedAPI implementation. service_name()743 static const char* service_name() { return "AutotestPrivateAPI"; } 744 static const bool kServiceIsNULLWhileTesting = true; 745 static const bool kServiceRedirectedInIncognito = true; 746 747 // ui::ClipboardObserver 748 void OnClipboardDataChanged() override; 749 750 ScopedObserver<ui::ClipboardMonitor, ui::ClipboardObserver> 751 clipboard_observer_; 752 753 content::BrowserContext* const browser_context_; 754 bool test_mode_; // true for AutotestPrivateApiTest.AutotestPrivate test. 755 }; 756 757 // Get the primary display's scale factor. 758 class AutotestPrivateGetPrimaryDisplayScaleFactorFunction 759 : public ExtensionFunction { 760 public: 761 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getPrimaryDisplayScaleFactor", 762 AUTOTESTPRIVATE_GETPRIMARYDISPLAYSCALEFACTOR) 763 private: 764 ~AutotestPrivateGetPrimaryDisplayScaleFactorFunction() override; 765 ResponseAction Run() override; 766 }; 767 768 // Returns if tablet mode is enabled. 769 class AutotestPrivateIsTabletModeEnabledFunction : public ExtensionFunction { 770 public: 771 DECLARE_EXTENSION_FUNCTION("autotestPrivate.isTabletModeEnabled", 772 AUTOTESTPRIVATE_ISTABLETMODEENABLED) 773 private: 774 ~AutotestPrivateIsTabletModeEnabledFunction() override; 775 ResponseAction Run() override; 776 }; 777 778 // Enables/Disables tablet mode. 779 class AutotestPrivateSetTabletModeEnabledFunction : public ExtensionFunction { 780 public: 781 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTabletModeEnabled", 782 AUTOTESTPRIVATE_SETTABLETMODEENABLED) 783 784 private: 785 ~AutotestPrivateSetTabletModeEnabledFunction() override; 786 ResponseAction Run() override; 787 }; 788 789 // Returns a list of all installed applications 790 class AutotestPrivateGetAllInstalledAppsFunction : public ExtensionFunction { 791 public: 792 AutotestPrivateGetAllInstalledAppsFunction(); 793 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getAllInstalledApps", 794 AUTOTESTPRIVATE_GETALLINSTALLEDAPPS) 795 796 private: 797 ~AutotestPrivateGetAllInstalledAppsFunction() override; 798 ResponseAction Run() override; 799 }; 800 801 // Returns a list of all shelf items 802 class AutotestPrivateGetShelfItemsFunction : public ExtensionFunction { 803 public: 804 AutotestPrivateGetShelfItemsFunction(); 805 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getShelfItems", 806 AUTOTESTPRIVATE_GETSHELFITEMS) 807 808 private: 809 ~AutotestPrivateGetShelfItemsFunction() override; 810 ResponseAction Run() override; 811 }; 812 813 // Returns the shelf auto hide behavior. 814 class AutotestPrivateGetShelfAutoHideBehaviorFunction 815 : public ExtensionFunction { 816 public: 817 AutotestPrivateGetShelfAutoHideBehaviorFunction(); 818 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getShelfAutoHideBehavior", 819 AUTOTESTPRIVATE_GETSHELFAUTOHIDEBEHAVIOR) 820 821 private: 822 ~AutotestPrivateGetShelfAutoHideBehaviorFunction() override; 823 ResponseAction Run() override; 824 }; 825 826 // Sets shelf autohide behavior. 827 class AutotestPrivateSetShelfAutoHideBehaviorFunction 828 : public ExtensionFunction { 829 public: 830 AutotestPrivateSetShelfAutoHideBehaviorFunction(); 831 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setShelfAutoHideBehavior", 832 AUTOTESTPRIVATE_SETSHELFAUTOHIDEBEHAVIOR) 833 834 private: 835 ~AutotestPrivateSetShelfAutoHideBehaviorFunction() override; 836 ResponseAction Run() override; 837 }; 838 839 // Returns the shelf alignment. 840 class AutotestPrivateGetShelfAlignmentFunction : public ExtensionFunction { 841 public: 842 AutotestPrivateGetShelfAlignmentFunction(); 843 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getShelfAlignment", 844 AUTOTESTPRIVATE_GETSHELFALIGNMENT) 845 846 private: 847 ~AutotestPrivateGetShelfAlignmentFunction() override; 848 ResponseAction Run() override; 849 }; 850 851 // Sets shelf alignment. 852 class AutotestPrivateSetShelfAlignmentFunction : public ExtensionFunction { 853 public: 854 AutotestPrivateSetShelfAlignmentFunction(); 855 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setShelfAlignment", 856 AUTOTESTPRIVATE_SETSHELFALIGNMENT) 857 858 private: 859 ~AutotestPrivateSetShelfAlignmentFunction() override; 860 ResponseAction Run() override; 861 }; 862 863 // Waits until overview has finished animating to a certain state. 864 class AutotestPrivateWaitForOverviewStateFunction : public ExtensionFunction { 865 public: 866 AutotestPrivateWaitForOverviewStateFunction(); 867 DECLARE_EXTENSION_FUNCTION("autotestPrivate.waitForOverviewState", 868 AUTOTESTPRIVATE_WAITFOROVERVIEWSTATE) 869 870 private: 871 ~AutotestPrivateWaitForOverviewStateFunction() override; 872 ResponseAction Run() override; 873 874 // Invoked when the animation has completed. |animation_succeeded| is whether 875 // overview is in the target state. 876 void Done(bool success); 877 }; 878 879 // Returns the overview mode state. 880 class AutotestPrivateSetOverviewModeStateFunction : public ExtensionFunction { 881 public: 882 AutotestPrivateSetOverviewModeStateFunction(); 883 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setOverviewModeState", 884 AUTOTESTPRIVATE_SETOVERVIEWMODESTATE) 885 886 private: 887 ~AutotestPrivateSetOverviewModeStateFunction() override; 888 ResponseAction Run() override; 889 890 // Called when the overview mode changes. 891 void OnOverviewModeChanged(bool for_start, bool finished); 892 }; 893 894 class AutotestPrivateShowVirtualKeyboardIfEnabledFunction 895 : public ExtensionFunction { 896 public: 897 AutotestPrivateShowVirtualKeyboardIfEnabledFunction(); 898 DECLARE_EXTENSION_FUNCTION("autotestPrivate.showVirtualKeyboardIfEnabled", 899 AUTOTESTPRIVATE_SHOWVIRTUALKEYBOARDIFENABLED) 900 901 private: 902 ~AutotestPrivateShowVirtualKeyboardIfEnabledFunction() override; 903 ResponseAction Run() override; 904 }; 905 906 class AutotestPrivateSetArcAppWindowFocusFunction : public ExtensionFunction { 907 public: 908 AutotestPrivateSetArcAppWindowFocusFunction(); 909 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setArcAppWindowFocus", 910 AUTOTESTPRIVATE_SETARCAPPWINDOWFOCUS) 911 912 private: 913 ~AutotestPrivateSetArcAppWindowFocusFunction() override; 914 ResponseAction Run() override; 915 }; 916 917 // Starts ARC app performance tracing for the current ARC app window. 918 class AutotestPrivateArcAppTracingStartFunction : public ExtensionFunction { 919 public: 920 AutotestPrivateArcAppTracingStartFunction(); 921 DECLARE_EXTENSION_FUNCTION("autotestPrivate.arcAppTracingStart", 922 AUTOTESTPRIVATE_ARCAPPTRACINGSTART) 923 924 private: 925 ~AutotestPrivateArcAppTracingStartFunction() override; 926 ResponseAction Run() override; 927 }; 928 929 // Stops active ARC app performance tracing if it was active and analyzes 930 // results. Result is returned to the previously registered callback for 931 // traceActiveArcAppStart. 932 class AutotestPrivateArcAppTracingStopAndAnalyzeFunction 933 : public ExtensionFunction { 934 public: 935 AutotestPrivateArcAppTracingStopAndAnalyzeFunction(); 936 DECLARE_EXTENSION_FUNCTION("autotestPrivate.arcAppTracingStopAndAnalyze", 937 AUTOTESTPRIVATE_ARCAPPTRACINGSTOPANDANALYZE) 938 939 private: 940 ~AutotestPrivateArcAppTracingStopAndAnalyzeFunction() override; 941 ResponseAction Run() override; 942 943 void OnTracingResult(bool success, 944 double fps, 945 double commit_deviation, 946 double render_quality); 947 }; 948 949 class AutotestPrivateSwapWindowsInSplitViewFunction : public ExtensionFunction { 950 public: 951 AutotestPrivateSwapWindowsInSplitViewFunction(); 952 DECLARE_EXTENSION_FUNCTION("autotestPrivate.swapWindowsInSplitView", 953 AUTOTESTPRIVATE_SWAPWINDOWSINSPLITVIEW) 954 955 private: 956 ~AutotestPrivateSwapWindowsInSplitViewFunction() override; 957 ResponseAction Run() override; 958 }; 959 960 class AutotestPrivateWaitForDisplayRotationFunction 961 : public ExtensionFunction, 962 public ash::ScreenRotationAnimatorObserver, 963 public ash::ScreenOrientationController::Observer { 964 public: 965 AutotestPrivateWaitForDisplayRotationFunction(); 966 DECLARE_EXTENSION_FUNCTION("autotestPrivate.waitForDisplayRotation", 967 AUTOTESTPRIVATE_WAITFORDISPLAYROTATION) 968 969 // ash::ScreenRotationAnimatorObserver: 970 void OnScreenCopiedBeforeRotation() override; 971 void OnScreenRotationAnimationFinished(ash::ScreenRotationAnimator* animator, 972 bool canceled) override; 973 974 // ash::ScreenOrientationController::Observer: 975 void OnUserRotationLockChanged() override; 976 977 private: 978 ~AutotestPrivateWaitForDisplayRotationFunction() override; 979 ResponseAction Run() override; 980 981 ResponseValue CheckScreenRotationAnimation(); 982 983 int64_t display_id_ = display::kInvalidDisplayId; 984 base::Optional<display::Display::Rotation> target_rotation_; 985 // A reference to keep the instance alive while waiting for rotation. 986 scoped_refptr<ExtensionFunction> self_; 987 }; 988 989 class AutotestPrivateGetAppWindowListFunction : public ExtensionFunction { 990 public: 991 AutotestPrivateGetAppWindowListFunction(); 992 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getAppWindowList", 993 AUTOTESTPRIVATE_GETAPPWINDOWLIST) 994 995 private: 996 ~AutotestPrivateGetAppWindowListFunction() override; 997 ResponseAction Run() override; 998 }; 999 1000 class AutotestPrivateSetAppWindowStateFunction : public ExtensionFunction { 1001 public: 1002 AutotestPrivateSetAppWindowStateFunction(); 1003 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setAppWindowState", 1004 AUTOTESTPRIVATE_SETAPPWINDOWSTATE) 1005 1006 private: 1007 ~AutotestPrivateSetAppWindowStateFunction() override; 1008 ResponseAction Run() override; 1009 1010 void WindowStateChanged(chromeos::WindowStateType expected_type, 1011 bool success); 1012 1013 std::unique_ptr<WindowStateChangeObserver> window_state_observer_; 1014 }; 1015 1016 class AutotestPrivateCloseAppWindowFunction : public ExtensionFunction { 1017 public: 1018 DECLARE_EXTENSION_FUNCTION("autotestPrivate.closeAppWindow", 1019 AUTOTESTPRIVATE_CLOSEAPPWINDOW) 1020 1021 private: 1022 ~AutotestPrivateCloseAppWindowFunction() override; 1023 ResponseAction Run() override; 1024 }; 1025 1026 class AutotestPrivateInstallPWAForCurrentURLFunction 1027 : public ExtensionFunction { 1028 public: 1029 AutotestPrivateInstallPWAForCurrentURLFunction(); 1030 DECLARE_EXTENSION_FUNCTION("autotestPrivate.installPWAForCurrentURL", 1031 AUTOTESTPRIVATE_INSTALLPWAFORCURRENTURL) 1032 1033 private: 1034 class PWABannerObserver; 1035 class PWARegistrarObserver; 1036 ~AutotestPrivateInstallPWAForCurrentURLFunction() override; 1037 ResponseAction Run() override; 1038 1039 // Called when a PWA is loaded from a URL. 1040 void PWALoaded(); 1041 // Called when a PWA is installed. 1042 void PWAInstalled(const web_app::AppId& app_id); 1043 // Called when intalling a PWA times out. 1044 void PWATimeout(); 1045 1046 std::unique_ptr<PWABannerObserver> banner_observer_; 1047 std::unique_ptr<PWARegistrarObserver> registrar_observer_; 1048 base::OneShotTimer timeout_timer_; 1049 }; 1050 1051 class AutotestPrivateActivateAcceleratorFunction : public ExtensionFunction { 1052 public: 1053 AutotestPrivateActivateAcceleratorFunction(); 1054 DECLARE_EXTENSION_FUNCTION("autotestPrivate.activateAccelerator", 1055 AUTOTESTPRIVATE_ACTIVATEACCELERATOR) 1056 1057 private: 1058 ~AutotestPrivateActivateAcceleratorFunction() override; 1059 ResponseAction Run() override; 1060 }; 1061 1062 class AutotestPrivateWaitForLauncherStateFunction : public ExtensionFunction { 1063 public: 1064 AutotestPrivateWaitForLauncherStateFunction(); 1065 DECLARE_EXTENSION_FUNCTION("autotestPrivate.waitForLauncherState", 1066 AUTOTESTPRIVATE_WAITFORLAUNCHERSTATE) 1067 1068 private: 1069 ~AutotestPrivateWaitForLauncherStateFunction() override; 1070 ResponseAction Run() override; 1071 1072 void Done(); 1073 }; 1074 1075 class AutotestPrivateCreateNewDeskFunction : public ExtensionFunction { 1076 public: 1077 AutotestPrivateCreateNewDeskFunction(); 1078 DECLARE_EXTENSION_FUNCTION("autotestPrivate.createNewDesk", 1079 AUTOTESTPRIVATE_CREATENEWDESK) 1080 1081 private: 1082 ~AutotestPrivateCreateNewDeskFunction() override; 1083 ResponseAction Run() override; 1084 }; 1085 1086 class AutotestPrivateActivateDeskAtIndexFunction : public ExtensionFunction { 1087 public: 1088 AutotestPrivateActivateDeskAtIndexFunction(); 1089 DECLARE_EXTENSION_FUNCTION("autotestPrivate.activateDeskAtIndex", 1090 AUTOTESTPRIVATE_ACTIVATEDESKATINDEX) 1091 1092 private: 1093 ~AutotestPrivateActivateDeskAtIndexFunction() override; 1094 ResponseAction Run() override; 1095 1096 void OnAnimationComplete(); 1097 }; 1098 1099 class AutotestPrivateRemoveActiveDeskFunction : public ExtensionFunction { 1100 public: 1101 AutotestPrivateRemoveActiveDeskFunction(); 1102 DECLARE_EXTENSION_FUNCTION("autotestPrivate.removeActiveDesk", 1103 AUTOTESTPRIVATE_REMOVEACTIVEDESK) 1104 1105 private: 1106 ~AutotestPrivateRemoveActiveDeskFunction() override; 1107 ResponseAction Run() override; 1108 1109 void OnAnimationComplete(); 1110 }; 1111 1112 class AutotestPrivateActivateAdjacentDesksToTargetIndexFunction 1113 : public ExtensionFunction { 1114 public: 1115 AutotestPrivateActivateAdjacentDesksToTargetIndexFunction(); 1116 DECLARE_EXTENSION_FUNCTION( 1117 "autotestPrivate.activateAdjacentDesksToTargetIndex", 1118 AUTOTESTPRIVATE_ACTIVATEADJACENTDESKSTOTARGETINDEX) 1119 1120 private: 1121 ~AutotestPrivateActivateAdjacentDesksToTargetIndexFunction() override; 1122 ResponseAction Run() override; 1123 1124 void OnAnimationComplete(); 1125 }; 1126 1127 class AutotestPrivateMouseClickFunction : public ExtensionFunction { 1128 public: 1129 AutotestPrivateMouseClickFunction(); 1130 DECLARE_EXTENSION_FUNCTION("autotestPrivate.mouseClick", 1131 AUTOTESTPRIVATE_MOUSECLICK) 1132 1133 private: 1134 ~AutotestPrivateMouseClickFunction() override; 1135 ResponseAction Run() override; 1136 1137 std::unique_ptr<EventGenerator> event_generator_; 1138 }; 1139 1140 class AutotestPrivateMousePressFunction : public ExtensionFunction { 1141 public: 1142 AutotestPrivateMousePressFunction(); 1143 DECLARE_EXTENSION_FUNCTION("autotestPrivate.mousePress", 1144 AUTOTESTPRIVATE_MOUSEPRESS) 1145 1146 private: 1147 ~AutotestPrivateMousePressFunction() override; 1148 ResponseAction Run() override; 1149 1150 std::unique_ptr<EventGenerator> event_generator_; 1151 }; 1152 1153 class AutotestPrivateMouseReleaseFunction : public ExtensionFunction { 1154 public: 1155 AutotestPrivateMouseReleaseFunction(); 1156 DECLARE_EXTENSION_FUNCTION("autotestPrivate.mouseRelease", 1157 AUTOTESTPRIVATE_MOUSERELEASE) 1158 1159 private: 1160 ~AutotestPrivateMouseReleaseFunction() override; 1161 ResponseAction Run() override; 1162 1163 std::unique_ptr<EventGenerator> event_generator_; 1164 }; 1165 1166 class AutotestPrivateMouseMoveFunction : public ExtensionFunction { 1167 public: 1168 AutotestPrivateMouseMoveFunction(); 1169 DECLARE_EXTENSION_FUNCTION("autotestPrivate.mouseMove", 1170 AUTOTESTPRIVATE_MOUSEMOVE) 1171 1172 private: 1173 ~AutotestPrivateMouseMoveFunction() override; 1174 ResponseAction Run() override; 1175 1176 void OnDone(); 1177 1178 std::unique_ptr<EventGenerator> event_generator_; 1179 }; 1180 1181 class AutotestPrivateSetMetricsEnabledFunction : public ExtensionFunction { 1182 public: 1183 AutotestPrivateSetMetricsEnabledFunction(); 1184 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setMetricsEnabled", 1185 AUTOTESTPRIVATE_SETMETRICSENABLED) 1186 1187 private: 1188 ~AutotestPrivateSetMetricsEnabledFunction() override; 1189 ResponseAction Run() override; 1190 1191 void OnStatsReportingStateChanged(); 1192 1193 std::unique_ptr<chromeos::StatsReportingController::ObserverSubscription> 1194 stats_reporting_observer_subscription_; 1195 bool target_value_ = false; 1196 }; 1197 1198 class AutotestPrivateStartTracingFunction : public ExtensionFunction { 1199 public: 1200 AutotestPrivateStartTracingFunction(); 1201 DECLARE_EXTENSION_FUNCTION("autotestPrivate.startTracing", 1202 AUTOTESTPRIVATE_STARTTRACING) 1203 1204 private: 1205 ~AutotestPrivateStartTracingFunction() override; 1206 ResponseAction Run() override; 1207 1208 void OnStartTracing(); 1209 }; 1210 1211 class AutotestPrivateStopTracingFunction : public ExtensionFunction { 1212 public: 1213 AutotestPrivateStopTracingFunction(); 1214 DECLARE_EXTENSION_FUNCTION("autotestPrivate.stopTracing", 1215 AUTOTESTPRIVATE_STOPTRACING) 1216 1217 private: 1218 ~AutotestPrivateStopTracingFunction() override; 1219 ResponseAction Run() override; 1220 1221 void OnTracingComplete(std::unique_ptr<std::string> trace); 1222 }; 1223 1224 class AutotestPrivateSetArcTouchModeFunction : public ExtensionFunction { 1225 public: 1226 AutotestPrivateSetArcTouchModeFunction(); 1227 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setArcTouchMode", 1228 AUTOTESTPRIVATE_SETARCTOUCHMODE) 1229 1230 private: 1231 ~AutotestPrivateSetArcTouchModeFunction() override; 1232 ResponseAction Run() override; 1233 }; 1234 1235 class AutotestPrivatePinShelfIconFunction : public ExtensionFunction { 1236 public: 1237 AutotestPrivatePinShelfIconFunction(); 1238 DECLARE_EXTENSION_FUNCTION("autotestPrivate.pinShelfIcon", 1239 AUTOTESTPRIVATE_PINSHELFICON) 1240 private: 1241 ~AutotestPrivatePinShelfIconFunction() override; 1242 ResponseAction Run() override; 1243 }; 1244 1245 class AutotestPrivateGetScrollableShelfInfoForStateFunction 1246 : public ExtensionFunction { 1247 public: 1248 AutotestPrivateGetScrollableShelfInfoForStateFunction(); 1249 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getScrollableShelfInfoForState", 1250 AUTOTESTPRIVATE_GETSCROLLABLESHELFINFOFORSTATE) 1251 1252 private: 1253 ~AutotestPrivateGetScrollableShelfInfoForStateFunction() override; 1254 ResponseAction Run() override; 1255 }; 1256 1257 class AutotestPrivateGetShelfUIInfoForStateFunction : public ExtensionFunction { 1258 public: 1259 AutotestPrivateGetShelfUIInfoForStateFunction(); 1260 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getShelfUIInfoForState", 1261 AUTOTESTPRIVATE_GETSHELFUIINFOFORSTATE) 1262 1263 private: 1264 ~AutotestPrivateGetShelfUIInfoForStateFunction() override; 1265 ResponseAction Run() override; 1266 }; 1267 1268 class AutotestPrivateSetWindowBoundsFunction : public ExtensionFunction { 1269 public: 1270 AutotestPrivateSetWindowBoundsFunction(); 1271 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setWindowBounds", 1272 AUTOTESTPRIVATE_SETWINDOWBOUNDS) 1273 1274 private: 1275 ~AutotestPrivateSetWindowBoundsFunction() override; 1276 ResponseAction Run() override; 1277 1278 void WindowBoundsChanged(const gfx::Rect& bounds_in_display, 1279 int64_t display_id, 1280 bool success); 1281 1282 std::unique_ptr<WindowBoundsChangeObserver> window_bounds_observer_; 1283 }; 1284 1285 class AutotestPrivateStartSmoothnessTrackingFunction 1286 : public ExtensionFunction { 1287 public: 1288 DECLARE_EXTENSION_FUNCTION("autotestPrivate.startSmoothnessTracking", 1289 AUTOTESTPRIVATE_STARTSMOOTHNESSTRACKING) 1290 1291 private: 1292 ~AutotestPrivateStartSmoothnessTrackingFunction() override; 1293 ResponseAction Run() override; 1294 }; 1295 1296 class AutotestPrivateStopSmoothnessTrackingFunction : public ExtensionFunction { 1297 public: 1298 DECLARE_EXTENSION_FUNCTION("autotestPrivate.stopSmoothnessTracking", 1299 AUTOTESTPRIVATE_STOPSMOOTHNESSTRACKING) 1300 1301 private: 1302 ~AutotestPrivateStopSmoothnessTrackingFunction() override; 1303 ResponseAction Run() override; 1304 1305 void OnReportData(const cc::FrameSequenceMetrics::CustomReportData& data); 1306 }; 1307 1308 class AutotestPrivateWaitForAmbientPhotoAnimationFunction 1309 : public ExtensionFunction { 1310 public: 1311 AutotestPrivateWaitForAmbientPhotoAnimationFunction(); 1312 DECLARE_EXTENSION_FUNCTION("autotestPrivate.waitForAmbientPhotoAnimation", 1313 AUTOTESTPRIVATE_WAITFORAMBIENTPHOTOANIMATION) 1314 1315 private: 1316 ~AutotestPrivateWaitForAmbientPhotoAnimationFunction() override; 1317 ResponseAction Run() override; 1318 1319 // Called when photo transition animations completed. 1320 void OnPhotoTransitionAnimationCompleted(); 1321 1322 // Called when photo transition animations fail to finish in a certain amount 1323 // of time. We will respond with an error. 1324 void Timeout(); 1325 1326 base::OneShotTimer timeout_timer_; 1327 }; 1328 1329 class AutotestPrivateDisableSwitchAccessDialogFunction 1330 : public ExtensionFunction { 1331 public: 1332 AutotestPrivateDisableSwitchAccessDialogFunction(); 1333 DECLARE_EXTENSION_FUNCTION("autotestPrivate.disableSwitchAccessDialog", 1334 AUTOTESTPRIVATE_DISABLESWITCHACCESSDIALOG) 1335 1336 private: 1337 ~AutotestPrivateDisableSwitchAccessDialogFunction() override; 1338 ResponseAction Run() override; 1339 }; 1340 1341 class AutotestPrivateDisableAutomationFunction : public ExtensionFunction { 1342 public: 1343 AutotestPrivateDisableAutomationFunction(); 1344 DECLARE_EXTENSION_FUNCTION("autotestPrivate.disableAutomation", 1345 AUTOTESTPRIVATE_DISABLEAUTOMATION) 1346 1347 private: 1348 ~AutotestPrivateDisableAutomationFunction() override; 1349 ResponseAction Run() override; 1350 }; 1351 1352 class AutotestPrivateStartThroughputTrackerDataCollectionFunction 1353 : public ExtensionFunction { 1354 public: 1355 AutotestPrivateStartThroughputTrackerDataCollectionFunction(); 1356 DECLARE_EXTENSION_FUNCTION( 1357 "autotestPrivate.startThroughputTrackerDataCollection", 1358 AUTOTESTPRIVATE_STARTTHROUGHPUTTRACKERDATACOLLECTION) 1359 1360 private: 1361 ~AutotestPrivateStartThroughputTrackerDataCollectionFunction() override; 1362 ResponseAction Run() override; 1363 }; 1364 1365 class AutotestPrivateStopThroughputTrackerDataCollectionFunction 1366 : public ExtensionFunction { 1367 public: 1368 AutotestPrivateStopThroughputTrackerDataCollectionFunction(); 1369 DECLARE_EXTENSION_FUNCTION( 1370 "autotestPrivate.stopThroughputTrackerDataCollection", 1371 AUTOTESTPRIVATE_STOPTHROUGHPUTTRACKERDATACOLLECTION) 1372 1373 private: 1374 ~AutotestPrivateStopThroughputTrackerDataCollectionFunction() override; 1375 ResponseAction Run() override; 1376 }; 1377 1378 template <> 1379 KeyedService* 1380 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor( 1381 content::BrowserContext* context) const; 1382 1383 } // namespace extensions 1384 1385 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_ 1386