cast_web_preferences.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2020 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 CHROMECAST_BROWSER_CAST_WEB_PREFERENCES_H_
  5. #define CHROMECAST_BROWSER_CAST_WEB_PREFERENCES_H_
  6. #include "base/supports_user_data.h"
  7. #include "third_party/abseil-cpp/absl/types/optional.h"
  8. #include "third_party/blink/public/mojom/webpreferences/web_preferences.mojom.h"
  9. namespace chromecast {
  10. // Stores user provided settings for a specific WebContents. These will be used
  11. // to override default WebPreferences during the lifetime of the WebContents.
  12. class CastWebPreferences : public base::SupportsUserData::Data {
  13. public:
  14. struct Preferences {
  15. Preferences();
  16. absl::optional<blink::mojom::AutoplayPolicy> autoplay_policy;
  17. absl::optional<bool> hide_scrollbars;
  18. absl::optional<bool> javascript_enabled;
  19. absl::optional<bool> supports_multiple_windows;
  20. };
  21. // Unique key used to identify CastWebPreferences in WebContents' user data.
  22. static const void* kCastWebPreferencesDataKey;
  23. CastWebPreferences();
  24. CastWebPreferences(const CastWebPreferences&) = delete;
  25. CastWebPreferences& operator=(CastWebPreferences&) = delete;
  26. Preferences* preferences() { return &preferences_; }
  27. // Overrides |prefs| with any locally stored preferences.
  28. void Update(blink::web_pref::WebPreferences* prefs);
  29. private:
  30. Preferences preferences_;
  31. };
  32. } // namespace chromecast
  33. #endif // CHROMECAST_BROWSER_CAST_WEB_PREFERENCES_H_