From ac3a0026e4908788e3a8650de7653c6c222c5dcc Mon Sep 17 00:00:00 2001 From: Andrei Oprea Date: Fri, 16 Apr 2021 12:30:26 +0200 Subject: [PATCH] Bug 1703874 - Nudge Existing Users to Set as Default Using Infobar (#206) --- cfr.json | 40 +++ cfr.yaml | 26 ++ schema/cfr.schema.json | 266 +++++++++--------- ...system-special-message-actions.schema.json | 9 + scripts/validate.py | 17 +- 5 files changed, 222 insertions(+), 136 deletions(-) diff --git a/cfr.json b/cfr.json index 229ecef..d603b90 100644 --- a/cfr.json +++ b/cfr.json @@ -158,5 +158,45 @@ "*://*/*" ] } + }, + { + "id": "INFOBAR_DEFAULT_AND_PIN_87", + "groups": [ + "cfr" + ], + "content": { + "category": "cfrFeatures", + "bucket_id": "INFOBAR_DEFAULT_AND_PIN_87", + "text": { + "string_id": "default-browser-notification-message" + }, + "type": "global", + "buttons": [ + { + "label": { + "string_id": "default-browser-notification-button" + }, + "action": { + "type": "PIN_AND_DEFAULT" + }, + "primary": true, + "accessKey": "P" + } + ] + }, + "trigger": { + "id": "defaultBrowserCheck" + }, + "template": "infobar", + "frequency": { + "lifetime": 100, + "custom": [ + { + "period": 3024000000, + "cap": 1 + } + ] + }, + "targeting": "!isDefaultBrowser && !'browser.shell.checkDefaultBrowser'|preferenceValue && isMajorUpgrade != true" } ] \ No newline at end of file diff --git a/cfr.yaml b/cfr.yaml index f13567a..8ddb7f5 100644 --- a/cfr.yaml +++ b/cfr.yaml @@ -104,3 +104,29 @@ id: openURL patterns: - "*://*/*" +- id: INFOBAR_DEFAULT_AND_PIN_87 + groups: + - cfr + content: + category: cfrFeatures + bucket_id: INFOBAR_DEFAULT_AND_PIN_87 + text: + string_id: default-browser-notification-message + type: global + buttons: + - label: + string_id: default-browser-notification-button + action: + type: PIN_AND_DEFAULT + primary: true + accessKey: P + trigger: + id: defaultBrowserCheck + template: infobar + frequency: + lifetime: 100 + custom: + - period: 3024000000 # 86400000 * 35 (35 days to ms) + cap: 1 + # Not default browser and user dismissed the default browser prompt + targeting: "!isDefaultBrowser && !'browser.shell.checkDefaultBrowser'|preferenceValue && isMajorUpgrade != true" diff --git a/schema/cfr.schema.json b/schema/cfr.schema.json index 80ace48..f3474b5 100644 --- a/schema/cfr.schema.json +++ b/schema/cfr.schema.json @@ -12,6 +12,138 @@ "description": "Target for links or buttons", "type": "string", "format": "uri" + }, + "buttons": { + "description": "The label and functionality for the buttons in the pop-over.", + "type": "object", + "properties": { + "primary": { + "type": "object", + "properties": { + "label": { + "type": "object", + "oneOf": [ + { + "properties": { + "value": { + "allOf": [ + {"$ref": "#/definitions/plainText"}, + {"description": "Button label override used when a localized version is not available."} + ] + }, + "attributes": { + "type": "object", + "properties": { + "accesskey": { + "type": "string", + "description": "A single character to be used as a shortcut key for the secondary button. This should be one of the characters that appears in the button label." + } + }, + "required": ["accesskey"], + "description": "Button attributes." + } + }, + "required": ["value", "attributes"] + }, + { + "properties": { + "string_id": { + "allOf": [ + {"$ref": "#/definitions/plainText"}, + {"description": "Id of localized string for button"} + ] + } + }, + "required": ["string_id"] + } + ], + "description": "Id of localized string or message override." + }, + "action": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "Action dispatched by the button." + }, + "data": { + "properties": { + "url": { + "type": "null", + "$comment": "This is dynamically generated from the addon.id. See CFRPageActions.jsm", + "description": "URL used in combination with the primary action dispatched." + } + } + } + } + } + }, + "secondary": { + "type": "object", + "properties": { + "label": { + "type": "object", + "oneOf": [ + { + "properties": { + "value": { + "allOf": [ + {"$ref": "#/definitions/plainText"}, + {"description": "Button label override used when a localized version is not available."} + ] + }, + "attributes": { + "type": "object", + "properties": { + "accesskey": { + "type": "string", + "description": "A single character to be used as a shortcut key for the secondary button. This should be one of the characters that appears in the button label." + } + }, + "required": ["accesskey"], + "description": "Button attributes." + } + }, + "required": ["value", "attributes"] + }, + { + "properties": { + "string_id": { + "allOf": [ + {"$ref": "#/definitions/plainText"}, + {"description": "Id of localized string for button"} + ] + } + }, + "required": ["string_id"] + } + ], + "description": "Id of localized string or message override." + }, + "action": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "Action dispatched by the button." + }, + "data": { + "properties": { + "url": { + "allOf": [ + {"$ref": "#/definitions/linkUrl"}, + {"description": "URL used in combination with the primary action dispatched."} + ] + } + } + } + } + } + } + }, + "required": ["label"] + } + } } }, "properties": { @@ -242,136 +374,10 @@ "required": ["steps"] }, "buttons": { - "description": "The label and functionality for the buttons in the pop-over.", - "type": "object", - "properties": { - "primary": { - "type": "object", - "properties": { - "label": { - "type": "object", - "oneOf": [ - { - "properties": { - "value": { - "allOf": [ - {"$ref": "#/definitions/plainText"}, - {"description": "Button label override used when a localized version is not available."} - ] - }, - "attributes": { - "type": "object", - "properties": { - "accesskey": { - "type": "string", - "description": "A single character to be used as a shortcut key for the secondary button. This should be one of the characters that appears in the button label." - } - }, - "required": ["accesskey"], - "description": "Button attributes." - } - }, - "required": ["value", "attributes"] - }, - { - "properties": { - "string_id": { - "allOf": [ - {"$ref": "#/definitions/plainText"}, - {"description": "Id of localized string for button"} - ] - } - }, - "required": ["string_id"] - } - ], - "description": "Id of localized string or message override." - }, - "action": { - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "Action dispatched by the button." - }, - "data": { - "properties": { - "url": { - "type": "null", - "$comment": "This is dynamically generated from the addon.id. See CFRPageActions.jsm", - "description": "URL used in combination with the primary action dispatched." - } - } - } - } - } - }, - "secondary": { - "type": "object", - "properties": { - "label": { - "type": "object", - "oneOf": [ - { - "properties": { - "value": { - "allOf": [ - {"$ref": "#/definitions/plainText"}, - {"description": "Button label override used when a localized version is not available."} - ] - }, - "attributes": { - "type": "object", - "properties": { - "accesskey": { - "type": "string", - "description": "A single character to be used as a shortcut key for the secondary button. This should be one of the characters that appears in the button label." - } - }, - "required": ["accesskey"], - "description": "Button attributes." - } - }, - "required": ["value", "attributes"] - }, - { - "properties": { - "string_id": { - "allOf": [ - {"$ref": "#/definitions/plainText"}, - {"description": "Id of localized string for button"} - ] - } - }, - "required": ["string_id"] - } - ], - "description": "Id of localized string or message override." - }, - "action": { - "type": "object", - "properties": { - "type": { - "type": "string", - "description": "Action dispatched by the button." - }, - "data": { - "properties": { - "url": { - "allOf": [ - {"$ref": "#/definitions/linkUrl"}, - {"description": "URL used in combination with the primary action dispatched."} - ] - } - } - } - } - } - } - }, - "required": ["label"] - } - } + "oneOf": [ + {"$ref": "#/definitions/buttons"}, + {"type": "array"} + ] } }, "additionalProperties": true, diff --git a/schema/messaging-system-special-message-actions.schema.json b/schema/messaging-system-special-message-actions.schema.json index 40870ab..a7e0c62 100644 --- a/schema/messaging-system-special-message-actions.schema.json +++ b/schema/messaging-system-special-message-actions.schema.json @@ -199,6 +199,15 @@ }, "type": "object" }, + "PIN_AND_DEFAULT": { + "description": "Pin browser to taskbar and set as default", + "properties": { + "type": { + "enum": ["PIN_AND_DEFAULT"], + "type": "string" + } + } + }, "SHOW_FIREFOX_ACCOUNTS": { "description": "Show Firefox Accounts", "properties": { diff --git a/scripts/validate.py b/scripts/validate.py index f2dbee0..8d69c36 100755 --- a/scripts/validate.py +++ b/scripts/validate.py @@ -99,13 +99,18 @@ def validate_action(action, for_exp): def extract_actions(message, message_type): def _extract_cfr(): - for name, button in message["content"].get("buttons", {}).items(): - if name == "primary": + buttons_prop = message["content"].get("buttons", {}) + if type(buttons_prop) is list: + for button in buttons_prop: yield button["action"] - else: - for sub_button in button: - if "action" in sub_button: - yield sub_button["action"] + else: + for name, button in buttons_prop.items(): + if name == "primary": + yield button["action"] + else: + for sub_button in button: + if "action" in sub_button: + yield sub_button["action"] def _extract_onboarding(): for card in message: