caption_style.cc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2018 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. #include "ui/native_theme/caption_style.h"
  5. #include "base/json/json_reader.h"
  6. #include "base/values.h"
  7. #include "build/build_config.h"
  8. namespace ui {
  9. CaptionStyle::CaptionStyle() = default;
  10. CaptionStyle::CaptionStyle(const CaptionStyle& other) = default;
  11. CaptionStyle::~CaptionStyle() = default;
  12. // static
  13. absl::optional<CaptionStyle> CaptionStyle::FromSpec(const std::string& spec) {
  14. CaptionStyle style;
  15. absl::optional<base::Value> dict = base::JSONReader::Read(spec);
  16. if (!dict.has_value() || !dict->is_dict())
  17. return absl::nullopt;
  18. if (const std::string* value = dict->FindStringKey("text-color"))
  19. style.text_color = *value;
  20. if (const std::string* value = dict->FindStringKey("background-color"))
  21. style.background_color = *value;
  22. return style;
  23. }
  24. #if !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_APPLE)
  25. absl::optional<CaptionStyle> CaptionStyle::FromSystemSettings() {
  26. return absl::nullopt;
  27. }
  28. #endif
  29. } // namespace ui