1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_TEST_SHELL_DELEGATE_H_
#define ASH_TEST_SHELL_DELEGATE_H_
#include <memory>
#include <string>
#include "ash/shell_delegate.h"
#include "base/functional/callback.h"
#include "chromeos/ash/services/multidevice_setup/public/mojom/multidevice_setup.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "url/gurl.h"
namespace ash {
class UserEducationDelegate;
class WindowState;
class TestShellDelegate : public ShellDelegate {
public:
TestShellDelegate();
TestShellDelegate(const TestShellDelegate&) = delete;
TestShellDelegate& operator=(const TestShellDelegate&) = delete;
~TestShellDelegate() override;
// Allows tests to override the MultiDeviceSetup binding behavior for this
// TestShellDelegate.
using MultiDeviceSetupBinder = base::RepeatingCallback<void(
mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup>)>;
void SetMultiDeviceSetupBinder(MultiDeviceSetupBinder binder) {
multidevice_setup_binder_ = std::move(binder);
}
// Allows tests to override the `UserEducationDelegate` creation behavior for
// this `TestShellDelegate`.
using UserEducationDelegateFactory =
base::RepeatingCallback<std::unique_ptr<UserEducationDelegate>()>;
void SetUserEducationDelegateFactory(UserEducationDelegateFactory factory) {
user_education_delegate_factory_ = std::move(factory);
}
// Overridden from ShellDelegate:
bool CanShowWindowForUser(const aura::Window* window) const override;
std::unique_ptr<CaptureModeDelegate> CreateCaptureModeDelegate()
const override;
std::unique_ptr<ClipboardHistoryControllerDelegate>
CreateClipboardHistoryControllerDelegate() const override;
std::unique_ptr<GameDashboardDelegate> CreateGameDashboardDelegate()
const override;
std::unique_ptr<AcceleratorPrefsDelegate> CreateAcceleratorPrefsDelegate()
const override;
AccessibilityDelegate* CreateAccessibilityDelegate() override;
std::unique_ptr<BackGestureContextualNudgeDelegate>
CreateBackGestureContextualNudgeDelegate(
BackGestureContextualNudgeController* controller) override;
std::unique_ptr<MediaNotificationProvider> CreateMediaNotificationProvider()
override;
std::unique_ptr<NearbyShareDelegate> CreateNearbyShareDelegate(
NearbyShareController* controller) const override;
std::unique_ptr<SavedDeskDelegate> CreateSavedDeskDelegate() const override;
std::unique_ptr<SystemSoundsDelegate> CreateSystemSoundsDelegate()
const override;
std::unique_ptr<UserEducationDelegate> CreateUserEducationDelegate()
const override;
scoped_refptr<network::SharedURLLoaderFactory>
GetGeolocationUrlLoaderFactory() const override;
bool CanGoBack(gfx::NativeWindow window) const override;
void SetTabScrubberChromeOSEnabled(bool enabled) override;
void ShouldExitFullscreenBeforeLock(
ShouldExitFullscreenCallback callback) override;
bool ShouldWaitForTouchPressAck(gfx::NativeWindow window) override;
int GetBrowserWebUITabStripHeight() override;
void BindMultiDeviceSetup(
mojo::PendingReceiver<multidevice_setup::mojom::MultiDeviceSetup>
receiver) override;
void BindMultiCaptureService(
mojo::PendingReceiver<video_capture::mojom::MultiCaptureService> receiver)
override;
bool IsSessionRestoreInProgress() const override;
void SetUpEnvironmentForLockedFullscreen(
const WindowState& window_state) override {}
const GURL& GetLastCommittedURLForWindowIfAny(aura::Window* window) override;
void ForceSkipWarningUserOnClose(
const std::vector<aura::Window*>& windows) override {}
void SetCanGoBack(bool can_go_back);
void SetShouldExitFullscreenBeforeLock(
bool should_exit_fullscreen_before_lock);
void SetShouldWaitForTouchAck(bool should_wait_for_touch_ack);
void SetSessionRestoreInProgress(bool in_progress);
bool IsLoggingRedirectDisabled() const override;
base::FilePath GetPrimaryUserDownloadsFolder() const override;
void OpenFeedbackDialog(FeedbackSource source,
const std::string& description_template) override {}
void SetLastCommittedURLForWindow(const GURL& url);
version_info::Channel GetChannel() override;
std::string GetVersionString() override;
void set_channel(version_info::Channel channel) { channel_ = channel; }
void set_version_string(const std::string& string) {
version_string_ = string;
}
private:
// True if the current top window can go back.
bool can_go_back_ = true;
// True if the tab scrubber is enabled.
bool tab_scrubber_enabled_ = true;
// False if it is allowed by policy to keep fullscreen after unlock.
bool should_exit_fullscreen_before_lock_ = true;
// True if when performing back gesture on the top window, we should handle
// the event after the touch ack is received. Please refer to
// |BackGestureEventHandler::should_wait_for_touch_ack_| for detailed
// description.
bool should_wait_for_touch_ack_ = false;
// True if window browser sessions are restoring.
bool session_restore_in_progress_ = false;
MultiDeviceSetupBinder multidevice_setup_binder_;
UserEducationDelegateFactory user_education_delegate_factory_;
GURL last_committed_url_ = GURL::EmptyGURL();
version_info::Channel channel_ = version_info::Channel::UNKNOWN;
std::string version_string_;
};
} // namespace ash
#endif // ASH_TEST_SHELL_DELEGATE_H_
|