url_forwarder_configurator_win.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2021 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 REMOTING_HOST_REMOTE_OPEN_URL_URL_FORWARDER_CONFIGURATOR_WIN_H_
  5. #define REMOTING_HOST_REMOTE_OPEN_URL_URL_FORWARDER_CONFIGURATOR_WIN_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include "base/memory/scoped_refptr.h"
  9. #include "base/memory/weak_ptr.h"
  10. #include "base/sequence_checker.h"
  11. #include "base/task/sequenced_task_runner.h"
  12. #include "base/thread_annotations.h"
  13. #include "base/timer/timer.h"
  14. #include "remoting/host/remote_open_url/url_forwarder_configurator.h"
  15. namespace remoting {
  16. class WtsSessionChangeObserver;
  17. // Windows implementation of UrlForwarderConfigurator.
  18. // Note that this class requires elevated privileges.
  19. class UrlForwarderConfiguratorWin final : public UrlForwarderConfigurator {
  20. public:
  21. UrlForwarderConfiguratorWin();
  22. ~UrlForwarderConfiguratorWin() override;
  23. void IsUrlForwarderSetUp(IsUrlForwarderSetUpCallback callback) override;
  24. void SetUpUrlForwarder(const SetUpUrlForwarderCallback& callback) override;
  25. UrlForwarderConfiguratorWin(const UrlForwarderConfiguratorWin&) = delete;
  26. UrlForwarderConfiguratorWin& operator=(const UrlForwarderConfiguratorWin&) =
  27. delete;
  28. private:
  29. void OnSetUpResponse(bool success);
  30. void OnReportUserInterventionRequired();
  31. void OnWtsSessionChange(uint32_t event, uint32_t session_id);
  32. SEQUENCE_CHECKER(sequence_checker_);
  33. scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
  34. // For uncurtained sessions, Windows reuses the same console session before
  35. // and after the user logs in. So we use these members to delay checking the
  36. // URL forwarder state until the user is logged in. They are valid (non-null)
  37. // only when the session is not logged in.
  38. // For curtained sessions, Windows creates a new session whenever the user
  39. // logs in, in which case the desktop process will be destroyed along with the
  40. // URL configurator and the pending requests, and a new desktop process will
  41. // be launched and IsUrlForwarderSetUp() will be called with a valid user
  42. // context.
  43. std::unique_ptr<WtsSessionChangeObserver> wts_session_change_observer_
  44. GUARDED_BY_CONTEXT(sequence_checker_);
  45. IsUrlForwarderSetUpCallback is_url_forwarder_set_up_callback_
  46. GUARDED_BY_CONTEXT(sequence_checker_);
  47. SetUpUrlForwarderCallback set_up_url_forwarder_callback_
  48. GUARDED_BY_CONTEXT(sequence_checker_);
  49. base::OneShotTimer report_user_intervention_required_timer_
  50. GUARDED_BY_CONTEXT(sequence_checker_);
  51. base::WeakPtrFactory<UrlForwarderConfiguratorWin> weak_factory_{this};
  52. };
  53. } // namespace remoting
  54. #endif // REMOTING_HOST_REMOTE_OPEN_URL_URL_FORWARDER_CONFIGURATOR_WIN_H_