test_shell_delegate.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifndef ASH_TEST_SHELL_DELEGATE_H_
  5. #define ASH_TEST_SHELL_DELEGATE_H_
  6. #include <memory>
  7. #include <string>
  8. #include "ash/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
  9. #include "ash/shell_delegate.h"
  10. #include "base/callback.h"
  11. #include "mojo/public/cpp/bindings/pending_receiver.h"
  12. #include "url/gurl.h"
  13. namespace ash {
  14. class TestShellDelegate : public ShellDelegate {
  15. public:
  16. TestShellDelegate();
  17. TestShellDelegate(const TestShellDelegate&) = delete;
  18. TestShellDelegate& operator=(const TestShellDelegate&) = delete;
  19. ~TestShellDelegate() override;
  20. // Allows tests to override the MultiDeviceSetup binding behavior for this
  21. // TestShellDelegate.
  22. using MultiDeviceSetupBinder = base::RepeatingCallback<void(
  23. mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup>)>;
  24. void SetMultiDeviceSetupBinder(MultiDeviceSetupBinder binder) {
  25. multidevice_setup_binder_ = std::move(binder);
  26. }
  27. // Overridden from ShellDelegate:
  28. bool CanShowWindowForUser(const aura::Window* window) const override;
  29. std::unique_ptr<CaptureModeDelegate> CreateCaptureModeDelegate()
  30. const override;
  31. AccessibilityDelegate* CreateAccessibilityDelegate() override;
  32. std::unique_ptr<BackGestureContextualNudgeDelegate>
  33. CreateBackGestureContextualNudgeDelegate(
  34. BackGestureContextualNudgeController* controller) override;
  35. std::unique_ptr<NearbyShareDelegate> CreateNearbyShareDelegate(
  36. NearbyShareController* controller) const override;
  37. std::unique_ptr<DesksTemplatesDelegate> CreateDesksTemplatesDelegate()
  38. const override;
  39. scoped_refptr<network::SharedURLLoaderFactory>
  40. GetGeolocationUrlLoaderFactory() const override;
  41. bool CanGoBack(gfx::NativeWindow window) const override;
  42. void SetTabScrubberChromeOSEnabled(bool enabled) override;
  43. void ShouldExitFullscreenBeforeLock(
  44. ShouldExitFullscreenCallback callback) override;
  45. bool ShouldWaitForTouchPressAck(gfx::NativeWindow window) override;
  46. int GetBrowserWebUITabStripHeight() override;
  47. void BindMultiDeviceSetup(
  48. mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup>
  49. receiver) override;
  50. void BindMultiCaptureService(
  51. mojo::PendingReceiver<video_capture::mojom::MultiCaptureService> receiver)
  52. override;
  53. bool IsSessionRestoreInProgress() const override;
  54. void SetUpEnvironmentForLockedFullscreen(bool locked) override {}
  55. const GURL& GetLastCommittedURLForWindowIfAny(aura::Window* window) override;
  56. void ForceSkipWarningUserOnClose(
  57. const std::vector<aura::Window*>& windows) override {}
  58. void SetCanGoBack(bool can_go_back);
  59. void SetShouldExitFullscreenBeforeLock(
  60. bool should_exit_fullscreen_before_lock);
  61. void SetShouldWaitForTouchAck(bool should_wait_for_touch_ack);
  62. void SetSessionRestoreInProgress(bool in_progress);
  63. bool IsLoggingRedirectDisabled() const override;
  64. base::FilePath GetPrimaryUserDownloadsFolder() const override;
  65. void OpenFeedbackPageForPersistentDesksBar() override {}
  66. void SetLastCommittedURLForWindow(const GURL& url);
  67. version_info::Channel GetChannel() override;
  68. std::string GetVersionString() override;
  69. void set_channel(version_info::Channel channel) { channel_ = channel; }
  70. void set_version_string(const std::string& string) {
  71. version_string_ = string;
  72. }
  73. private:
  74. // True if the current top window can go back.
  75. bool can_go_back_ = true;
  76. // True if the tab scrubber is enabled.
  77. bool tab_scrubber_enabled_ = true;
  78. // False if it is allowed by policy to keep fullscreen after unlock.
  79. bool should_exit_fullscreen_before_lock_ = true;
  80. // True if when performing back gesture on the top window, we should handle
  81. // the event after the touch ack is received. Please refer to
  82. // |BackGestureEventHandler::should_wait_for_touch_ack_| for detailed
  83. // description.
  84. bool should_wait_for_touch_ack_ = false;
  85. // True if window browser sessions are restoring.
  86. bool session_restore_in_progress_ = false;
  87. MultiDeviceSetupBinder multidevice_setup_binder_;
  88. GURL last_committed_url_ = GURL::EmptyGURL();
  89. version_info::Channel channel_ = version_info::Channel::UNKNOWN;
  90. std::string version_string_;
  91. };
  92. } // namespace ash
  93. #endif // ASH_TEST_SHELL_DELEGATE_H_