зеркало из 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
|
# 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/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
[localization] @AB_CD@.jar:
|
|
||||||
dom (%dom/**/*.ftl)
|
|
||||||
|
|
||||||
@AB_CD@.jar:
|
@AB_CD@.jar:
|
||||||
locale/@AB_CD@/global/css.properties (%chrome/layout/css.properties)
|
locale/@AB_CD@/global/css.properties (%chrome/layout/css.properties)
|
||||||
|
|
|
@ -6,16 +6,14 @@
|
||||||
|
|
||||||
#include "MediaController.h"
|
#include "MediaController.h"
|
||||||
#include "MediaControlUtils.h"
|
#include "MediaControlUtils.h"
|
||||||
|
|
||||||
#include "mozilla/Assertions.h"
|
#include "mozilla/Assertions.h"
|
||||||
#include "mozilla/intl/Localization.h"
|
|
||||||
#include "mozilla/Logging.h"
|
#include "mozilla/Logging.h"
|
||||||
#include "mozilla/Services.h"
|
#include "mozilla/Services.h"
|
||||||
#include "mozilla/StaticPtr.h"
|
#include "mozilla/StaticPtr.h"
|
||||||
#include "nsIObserverService.h"
|
#include "nsIObserverService.h"
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
|
|
||||||
using mozilla::intl::Localization;
|
|
||||||
|
|
||||||
#undef LOG
|
#undef LOG
|
||||||
#define LOG(msg, ...) \
|
#define LOG(msg, ...) \
|
||||||
MOZ_LOG(gMediaControlLog, LogLevel::Debug, \
|
MOZ_LOG(gMediaControlLog, LogLevel::Debug, \
|
||||||
|
@ -113,24 +111,6 @@ void MediaControlService::Init() {
|
||||||
MOZ_ASSERT(mMediaControlKeyManager->IsOpened());
|
MOZ_ASSERT(mMediaControlKeyManager->IsOpened());
|
||||||
mMediaControlKeyManager->AddListener(mMediaKeysHandler.get());
|
mMediaControlKeyManager->AddListener(mMediaKeysHandler.get());
|
||||||
mControllerManager = MakeUnique<ControllerManager>(this);
|
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() {
|
MediaControlService::~MediaControlService() {
|
||||||
|
@ -282,10 +262,6 @@ MediaSessionPlaybackState MediaControlService::GetMainControllerPlaybackState()
|
||||||
: MediaSessionPlaybackState::None;
|
: MediaSessionPlaybackState::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString MediaControlService::GetFallbackTitle() const {
|
|
||||||
return mFallbackTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Following functions belong to ControllerManager
|
// Following functions belong to ControllerManager
|
||||||
MediaControlService::ControllerManager::ControllerManager(
|
MediaControlService::ControllerManager::ControllerManager(
|
||||||
MediaControlService* aService)
|
MediaControlService* aService)
|
||||||
|
|
|
@ -82,11 +82,6 @@ class MediaControlService final : public nsIObserver {
|
||||||
MediaMetadataBase GetMainControllerMediaMetadata() const;
|
MediaMetadataBase GetMainControllerMediaMetadata() const;
|
||||||
MediaSessionPlaybackState GetMainControllerPlaybackState() 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:
|
private:
|
||||||
MediaControlService();
|
MediaControlService();
|
||||||
~MediaControlService();
|
~MediaControlService();
|
||||||
|
@ -171,7 +166,6 @@ class MediaControlService final : public nsIObserver {
|
||||||
RefPtr<MediaControlKeyListener> mMediaKeysHandler;
|
RefPtr<MediaControlKeyListener> mMediaKeysHandler;
|
||||||
MediaEventProducer<uint64_t> mMediaControllerAmountChangedEvent;
|
MediaEventProducer<uint64_t> mMediaControllerAmountChangedEvent;
|
||||||
UniquePtr<ControllerManager> mControllerManager;
|
UniquePtr<ControllerManager> mControllerManager;
|
||||||
nsString mFallbackTitle;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
|
@ -198,8 +198,9 @@ MediaMetadataBase MediaStatusManager::CreateDefaultMetadata() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString MediaStatusManager::GetDefaultTitle() const {
|
nsString MediaStatusManager::GetDefaultTitle() const {
|
||||||
RefPtr<MediaControlService> service = MediaControlService::GetService();
|
// TODO : maybe need l10n? (bug1657701)
|
||||||
nsString defaultTitle = service->GetFallbackTitle();
|
nsString defaultTitle;
|
||||||
|
defaultTitle.AssignLiteral("Firefox is playing media");
|
||||||
|
|
||||||
RefPtr<CanonicalBrowsingContext> bc =
|
RefPtr<CanonicalBrowsingContext> bc =
|
||||||
CanonicalBrowsingContext::Get(mTopLevelBrowsingContextId);
|
CanonicalBrowsingContext::Get(mTopLevelBrowsingContextId);
|
||||||
|
|
|
@ -220,23 +220,13 @@ function isCurrentMetadataEqualTo(metadata) {
|
||||||
* the `options`.
|
* the `options`.
|
||||||
*/
|
*/
|
||||||
async function isGivenTabUsingDefaultMetadata(tab, 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();
|
const metadata = tab.linkedBrowser.browsingContext.mediaController.getMetadata();
|
||||||
|
|
||||||
await SpecialPowers.spawn(
|
await SpecialPowers.spawn(
|
||||||
tab.linkedBrowser,
|
tab.linkedBrowser,
|
||||||
[metadata.title, fallbackTitle, options.isPrivateBrowsing],
|
[metadata.title, options.isPrivateBrowsing],
|
||||||
(title, fallbackTitle, isPrivateBrowsing) => {
|
(title, isPrivateBrowsing) => {
|
||||||
if (isPrivateBrowsing || !content.document.title.length) {
|
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 {
|
} else {
|
||||||
is(
|
is(
|
||||||
title,
|
title,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче