Skip to content

Commit

Permalink
Bug 1703874 - Nudge Existing Users to Set as Default Using Infobar (#206
Browse files Browse the repository at this point in the history
)
  • Loading branch information
piatra committed Apr 16, 2021
1 parent 60a6702 commit ac3a002
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 136 deletions.
40 changes: 40 additions & 0 deletions cfr.json
Expand Up @@ -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"
}
]
26 changes: 26 additions & 0 deletions cfr.yaml
Expand Up @@ -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"
266 changes: 136 additions & 130 deletions schema/cfr.schema.json
Expand Up @@ -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": {
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions schema/messaging-system-special-message-actions.schema.json
Expand Up @@ -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": {
Expand Down
17 changes: 11 additions & 6 deletions scripts/validate.py
Expand Up @@ -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:
Expand Down

0 comments on commit ac3a002

Please sign in to comment.