Skip to content

Commit

Permalink
Bug 1854425 - Migrate WDBA .ini files to Fluent r=nrishel,fluent-revi…
Browse files Browse the repository at this point in the history
…ewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D189144
  • Loading branch information
nipunshukla21 committed Oct 20, 2023
1 parent 46c52f6 commit bdefd9a
Show file tree
Hide file tree
Showing 11 changed files with 264 additions and 231 deletions.
1 change: 0 additions & 1 deletion browser/installer/package-manifest.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#endif
#ifdef MOZ_DEFAULT_BROWSER_AGENT
@RESPATH@/defaultagent.ini
@RESPATH@/defaultagent_localized.ini
#endif
#if defined(MOZ_UPDATE_AGENT) || defined(MOZ_DEFAULT_BROWSER_AGENT)
@RESPATH@/locale.ini
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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/.

default-browser-agent-task-description = The Default Browser Agent task checks when the default changes from { -brand-short-name } to another browser. If the change happens under suspicious circumstances, it will prompt users to change back to { -brand-short-name } no more than two times. This task is installed automatically by { -brand-short-name }, and is reinstalled when { -brand-short-name } updates. To disable this task, update the “default-browser-agent.enabled” preference on the about:config page or the { -brand-short-name } enterprise policy setting “DisableDefaultBrowserAgent”.
default-browser-notification-header-text = Keep using { -brand-short-name }?
default-browser-notification-body-text = Your default browser was recently changed. Tap to restore { -brand-short-name } to default.
default-browser-notification-yes-button-text = Yes
default-browser-notification-no-button-text = No
12 changes: 0 additions & 12 deletions browser/locales/en-US/defaultagent/defaultagent_localized.ini

This file was deleted.

58 changes: 58 additions & 0 deletions python/l10n/fluent_migrations/bug_1854425_default_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/

import fluent.syntax.ast as FTL
from fluent.migrate.helpers import TERM_REFERENCE
from fluent.migrate.transforms import REPLACE, COPY


def migrate(ctx):
"""Bug 1854425 - Migrate defaultagent_localized.ini to Fluent, part {index}."""

source = "browser/defaultagent/defaultagent_localized.ini"
target = "browser/browser/backgroundtasks/defaultagent.ftl"

ctx.add_transforms(
target,
target,
[
FTL.Message(
id=FTL.Identifier("default-browser-agent-task-description"),
value=REPLACE(
source,
"DefaultBrowserAgentTaskDescription",
{
"%MOZ_APP_DISPLAYNAME%": TERM_REFERENCE("brand-short-name"),
},
),
),
FTL.Message(
id=FTL.Identifier("default-browser-notification-header-text"),
value=REPLACE(
source,
"DefaultBrowserNotificationHeaderText",
{
"%MOZ_APP_DISPLAYNAME%": TERM_REFERENCE("brand-short-name"),
},
),
),
FTL.Message(
id=FTL.Identifier("default-browser-notification-body-text"),
value=REPLACE(
source,
"DefaultBrowserNotificationBodyText",
{
"%MOZ_APP_DISPLAYNAME%": TERM_REFERENCE("brand-short-name"),
},
),
),
FTL.Message(
id=FTL.Identifier("default-browser-notification-yes-button-text"),
value=COPY(source, "DefaultBrowserNotificationYesButtonText"),
),
FTL.Message(
id=FTL.Identifier("default-browser-notification-no-button-text"),
value=COPY(source, "DefaultBrowserNotificationNoButtonText"),
),
],
)
9 changes: 0 additions & 9 deletions toolkit/locales/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,3 @@ LOCALIZED_FILES += ["!update.locale"]
LOCALIZED_GENERATED_FILES += ["locale.ini"]
LOCALIZED_GENERATED_FILES["locale.ini"].script = "generate_locale_ini.py"
LOCALIZED_FILES += ["!locale.ini"]

if CONFIG["MOZ_DEFAULT_BROWSER_AGENT"]:
LOCALIZED_GENERATED_FILES += ["defaultagent_localized.ini"]
wdba_l10n = LOCALIZED_GENERATED_FILES["defaultagent_localized.ini"]
wdba_l10n.script = "/browser/locales/generate_ini.py"
wdba_l10n.inputs = [
"/browser/locales/en-US/defaultagent/defaultagent_localized.ini",
]
LOCALIZED_FILES += ["!defaultagent_localized.ini"]
7 changes: 2 additions & 5 deletions toolkit/mozapps/defaultagent/DefaultAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <string.h>
#include <vector>

#include "mozilla/mscom/EnsureMTA.h"
#include "nsAutoRef.h"
#include "nsDebug.h"
#include "nsWindowsHelpers.h"
Expand Down Expand Up @@ -349,10 +348,8 @@ DefaultAgent::DoTask(const nsAString& aUniqueToken, const bool aForce) {
// We block while waiting for the notification which prevents STA thread
// callbacks from running as the event loop won't run. Moving notification
// handling to an MTA thread prevents this conflict.
mozilla::mscom::EnsureMTA([&] {
activitiesPerformed = MaybeShowNotification(
browserInfo, PromiseFlatString(aUniqueToken).get(), aForce);
});
activitiesPerformed = MaybeShowNotification(
browserInfo, PromiseFlatString(aUniqueToken).get(), aForce);

HRESULT hr = SendDefaultAgentPing(browserInfo, pdfInfo, activitiesPerformed);
return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
Expand Down
Loading

0 comments on commit bdefd9a

Please sign in to comment.