зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 305a050902fe (bug 1657701) for Browser-chrome failure in unreferenced file: resource://gre/localization/en-US/dom/media.ftl. CLOSED TREE
This commit is contained in:
Родитель
ae5e3a0d7c
Коммит
bf02570c59
|
@ -1,5 +0,0 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
mediastatus-fallback-title = { -brand-short-name } is playing media
|
|
@ -3,8 +3,6 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
[localization] @AB_CD@.jar:
|
||||
dom (%dom/**/*.ftl)
|
||||
|
||||
@AB_CD@.jar:
|
||||
locale/@AB_CD@/global/css.properties (%chrome/layout/css.properties)
|
||||
|
|
|
@ -6,16 +6,14 @@
|
|||
|
||||
#include "MediaController.h"
|
||||
#include "MediaControlUtils.h"
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/intl/Localization.h"
|
||||
#include "mozilla/Logging.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
using mozilla::intl::Localization;
|
||||
|
||||
#undef LOG
|
||||
#define LOG(msg, ...) \
|
||||
MOZ_LOG(gMediaControlLog, LogLevel::Debug, \
|
||||
|
@ -113,24 +111,6 @@ void MediaControlService::Init() {
|
|||
MOZ_ASSERT(mMediaControlKeyManager->IsOpened());
|
||||
mMediaControlKeyManager->AddListener(mMediaKeysHandler.get());
|
||||
mControllerManager = MakeUnique<ControllerManager>(this);
|
||||
|
||||
// Initialize the fallback title
|
||||
nsCOMPtr<nsIGlobalObject> global =
|
||||
xpc::NativeGlobal(xpc::PrivilegedJunkScope());
|
||||
RefPtr<Localization> l10n = Localization::Create(global, true, {});
|
||||
l10n->AddResourceId(u"branding/brand.ftl"_ns);
|
||||
l10n->AddResourceId(u"dom/media.ftl"_ns);
|
||||
{
|
||||
AutoSafeJSContext cx;
|
||||
|
||||
nsAutoCString translation;
|
||||
ErrorResult rv;
|
||||
l10n->FormatValueSync(cx, "mediastatus-fallback-title"_ns, {}, translation,
|
||||
rv);
|
||||
if (!rv.Failed()) {
|
||||
mFallbackTitle = NS_ConvertUTF8toUTF16(translation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MediaControlService::~MediaControlService() {
|
||||
|
@ -282,10 +262,6 @@ MediaSessionPlaybackState MediaControlService::GetMainControllerPlaybackState()
|
|||
: MediaSessionPlaybackState::None;
|
||||
}
|
||||
|
||||
nsString MediaControlService::GetFallbackTitle() const {
|
||||
return mFallbackTitle;
|
||||
}
|
||||
|
||||
// Following functions belong to ControllerManager
|
||||
MediaControlService::ControllerManager::ControllerManager(
|
||||
MediaControlService* aService)
|
||||
|
|
|
@ -82,11 +82,6 @@ class MediaControlService final : public nsIObserver {
|
|||
MediaMetadataBase GetMainControllerMediaMetadata() const;
|
||||
MediaSessionPlaybackState GetMainControllerPlaybackState() const;
|
||||
|
||||
// Media title that should be used as a fallback. This commonly used
|
||||
// when playing media in private browsing mode and we are trying to avoid
|
||||
// exposing potentially sensitive titles.
|
||||
nsString GetFallbackTitle() const;
|
||||
|
||||
private:
|
||||
MediaControlService();
|
||||
~MediaControlService();
|
||||
|
@ -171,7 +166,6 @@ class MediaControlService final : public nsIObserver {
|
|||
RefPtr<MediaControlKeyListener> mMediaKeysHandler;
|
||||
MediaEventProducer<uint64_t> mMediaControllerAmountChangedEvent;
|
||||
UniquePtr<ControllerManager> mControllerManager;
|
||||
nsString mFallbackTitle;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -198,8 +198,9 @@ MediaMetadataBase MediaStatusManager::CreateDefaultMetadata() const {
|
|||
}
|
||||
|
||||
nsString MediaStatusManager::GetDefaultTitle() const {
|
||||
RefPtr<MediaControlService> service = MediaControlService::GetService();
|
||||
nsString defaultTitle = service->GetFallbackTitle();
|
||||
// TODO : maybe need l10n? (bug1657701)
|
||||
nsString defaultTitle;
|
||||
defaultTitle.AssignLiteral("Firefox is playing media");
|
||||
|
||||
RefPtr<CanonicalBrowsingContext> bc =
|
||||
CanonicalBrowsingContext::Get(mTopLevelBrowsingContextId);
|
||||
|
|
|
@ -220,23 +220,13 @@ function isCurrentMetadataEqualTo(metadata) {
|
|||
* the `options`.
|
||||
*/
|
||||
async function isGivenTabUsingDefaultMetadata(tab, options = {}) {
|
||||
const localization = new Localization([
|
||||
"branding/brand.ftl",
|
||||
"dom/media.ftl",
|
||||
]);
|
||||
const fallbackTitle = await localization.formatValue(
|
||||
"mediastatus-fallback-title"
|
||||
);
|
||||
ok(fallbackTitle.length > 0, "l10n fallback title is not empty");
|
||||
|
||||
const metadata = tab.linkedBrowser.browsingContext.mediaController.getMetadata();
|
||||
|
||||
await SpecialPowers.spawn(
|
||||
tab.linkedBrowser,
|
||||
[metadata.title, fallbackTitle, options.isPrivateBrowsing],
|
||||
(title, fallbackTitle, isPrivateBrowsing) => {
|
||||
[metadata.title, options.isPrivateBrowsing],
|
||||
(title, isPrivateBrowsing) => {
|
||||
if (isPrivateBrowsing || !content.document.title.length) {
|
||||
is(title, fallbackTitle, "Using a generic default fallback title");
|
||||
is(title, "Firefox is playing media", "Using a generic default title");
|
||||
} else {
|
||||
is(
|
||||
title,
|
||||
|
|
Загрузка…
Ссылка в новой задаче