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
|
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/media_controls/media_controls_resource_loader.h"
#include "build/build_config.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/modules/media_controls/resources/grit/media_controls_resources.h"
#include "third_party/blink/renderer/platform/data_resource_helper.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace {
bool ShouldLoadAndroidCSS() {
#if BUILDFLAG(IS_ANDROID)
return true;
#else
return blink::RuntimeEnabledFeatures::MobileLayoutThemeEnabled();
#endif
}
} // namespace
namespace blink {
MediaControlsResourceLoader::MediaControlsResourceLoader()
: UAStyleSheetLoader() {}
MediaControlsResourceLoader::~MediaControlsResourceLoader() = default;
String MediaControlsResourceLoader::GetMediaControlsCSS() const {
return UncompressResourceAsString(IDR_UASTYLE_MEDIA_CONTROLS_CSS);
}
String MediaControlsResourceLoader::GetMediaControlsAndroidCSS() const {
return UncompressResourceAsString(IDR_UASTYLE_MEDIA_CONTROLS_ANDROID_CSS);
}
// static
String MediaControlsResourceLoader::GetShadowLoadingStyleSheet() {
return UncompressResourceAsString(IDR_SHADOWSTYLE_MEDIA_CONTROLS_LOADING_CSS);
}
// static
String MediaControlsResourceLoader::GetJumpSVGImage() {
return UncompressResourceAsString(IDR_MEDIA_CONTROLS_JUMP_SVG);
}
// static
String MediaControlsResourceLoader::GetArrowRightSVGImage() {
return UncompressResourceAsString(IDR_MEDIA_CONTROLS_ARROW_RIGHT_SVG);
}
// static
String MediaControlsResourceLoader::GetArrowLeftSVGImage() {
return UncompressResourceAsString(IDR_MEDIA_CONTROLS_ARROW_LEFT_SVG);
}
// static
String MediaControlsResourceLoader::GetScrubbingMessageStyleSheet() {
return UncompressResourceAsString(
IDR_SHADOWSTYLE_MEDIA_CONTROLS_SCRUBBING_MESSAGE_CSS);
}
// static
String MediaControlsResourceLoader::GetAnimatedArrowStyleSheet() {
return UncompressResourceAsString(
IDR_SHADOWSTYLE_MEDIA_CONTROLS_ANIMATED_ARROW_CSS);
}
// static
String MediaControlsResourceLoader::GetMediaInterstitialsStyleSheet() {
return UncompressResourceAsString(IDR_UASTYLE_MEDIA_INTERSTITIALS_CSS);
}
String MediaControlsResourceLoader::GetUAStyleSheet() {
if (ShouldLoadAndroidCSS()) {
return GetMediaControlsCSS() + GetMediaControlsAndroidCSS() +
GetMediaInterstitialsStyleSheet();
}
return GetMediaControlsCSS() + GetMediaInterstitialsStyleSheet();
}
void MediaControlsResourceLoader::InjectMediaControlsUAStyleSheet() {
CSSDefaultStyleSheets& default_style_sheets =
CSSDefaultStyleSheets::Instance();
std::unique_ptr<MediaControlsResourceLoader> loader =
std::make_unique<MediaControlsResourceLoader>();
if (!default_style_sheets.HasMediaControlsStyleSheetLoader())
default_style_sheets.SetMediaControlsStyleSheetLoader(std::move(loader));
}
} // namespace blink
|