pref_names.cc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #include "components/live_caption/pref_names.h"
  5. #include <string>
  6. #include "base/feature_list.h"
  7. #include "build/build_config.h"
  8. #include "components/prefs/pref_service.h"
  9. #if !BUILDFLAG(IS_ANDROID)
  10. #include "components/soda/constants.h"
  11. #include "media/base/media_switches.h"
  12. #endif
  13. namespace prefs {
  14. #if !defined(ANDROID)
  15. // Whether the Live Caption bubble is expanded.
  16. const char kLiveCaptionBubbleExpanded[] =
  17. "accessibility.captions.live_caption_bubble_expanded";
  18. // Whether the Live Caption bubble is pinned.
  19. const char kLiveCaptionBubblePinned[] =
  20. "accessibility.captions.live_caption_bubble_pinned";
  21. // Whether the Live Caption feature is enabled.
  22. const char kLiveCaptionEnabled[] =
  23. "accessibility.captions.live_caption_enabled";
  24. // The language to use with the Live Caption feature.
  25. const char kLiveCaptionLanguageCode[] =
  26. "accessibility.captions.live_caption_language";
  27. // The list of origins that should not display an error message when using the
  28. // Media Foundation renderer.
  29. const char kLiveCaptionMediaFoundationRendererErrorSilenced[] =
  30. "accessibility.captions.live_caption_media_foundation_renderer_error_"
  31. "silenced";
  32. const std::string GetLiveCaptionLanguageCode(PrefService* profile_prefs) {
  33. if (base::FeatureList::IsEnabled(media::kLiveCaptionMultiLanguage))
  34. return profile_prefs->GetString(prefs::kLiveCaptionLanguageCode);
  35. // Default to en-US if the kLiveCaptionMultiLanguage feature isn't enabled.
  36. return speech::kUsEnglishLocale;
  37. }
  38. bool IsLanguageCodeForLiveCaption(speech::LanguageCode language_code,
  39. PrefService* profile_prefs) {
  40. return language_code ==
  41. speech::GetLanguageCode(GetLiveCaptionLanguageCode(profile_prefs));
  42. }
  43. #endif // !defined(ANDROID)
  44. // String indicating the size of the captions text as a percentage.
  45. const char kAccessibilityCaptionsTextSize[] =
  46. "accessibility.captions.text_size";
  47. // String indicating the font of the captions text.
  48. const char kAccessibilityCaptionsTextFont[] =
  49. "accessibility.captions.text_font";
  50. // Comma-separated string indicating the RGB values of the captions text color.
  51. const char kAccessibilityCaptionsTextColor[] =
  52. "accessibility.captions.text_color";
  53. // Integer indicating the opacity of the captions text from 0 - 100.
  54. const char kAccessibilityCaptionsTextOpacity[] =
  55. "accessibility.captions.text_opacity";
  56. // Comma-separated string indicating the RGB values of the background color.
  57. const char kAccessibilityCaptionsBackgroundColor[] =
  58. "accessibility.captions.background_color";
  59. // CSS string indicating the shadow of the captions text.
  60. const char kAccessibilityCaptionsTextShadow[] =
  61. "accessibility.captions.text_shadow";
  62. // Integer indicating the opacity of the captions text background from 0 - 100.
  63. const char kAccessibilityCaptionsBackgroundOpacity[] =
  64. "accessibility.captions.background_opacity";
  65. } // namespace prefs