forked from mirrors/gecko-dev
Bug 1482959 - Add aliased search, search styling and bug fixes to Activity Stream r=k88hudson
Differential Revision: https://phabricator.services.mozilla.com/D3236 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
5a1596f8f2
commit
ce0c5871ef
25 changed files with 165 additions and 98 deletions
|
|
@ -83,14 +83,14 @@ add_task(async function startup() {
|
|||
},
|
||||
"browser.search.log": {
|
||||
min: 100,
|
||||
max: 200,
|
||||
max: 214,
|
||||
},
|
||||
"layout.css.dpi": {
|
||||
min: 45,
|
||||
max: 75,
|
||||
},
|
||||
"network.loadinfo.skip_type_assertion": {
|
||||
max: 654,
|
||||
max: 658,
|
||||
},
|
||||
"extensions.getAddons.cache.enabled": {
|
||||
min: 7,
|
||||
|
|
|
|||
|
|
@ -18,14 +18,20 @@
|
|||
cursor: default;
|
||||
display: flex;
|
||||
height: $search-height;
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
width: $searchbar-width-smallest;
|
||||
|
||||
@media (min-width: $break-point-large) {
|
||||
.search-inner-wrapper {
|
||||
margin: 0 auto;
|
||||
width: $max-searchbar-width;
|
||||
@media (min-width: $break-point-small) {
|
||||
width: $searchbar-width-small;
|
||||
}
|
||||
|
||||
@media (min-width: $break-point-medium) {
|
||||
width: $searchbar-width-medium;
|
||||
}
|
||||
|
||||
@media (min-width: $break-point-large) {
|
||||
width: $searchbar-width-large;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +57,7 @@
|
|||
box-shadow: $shadow-secondary, 0 0 0 1px $black-25;
|
||||
}
|
||||
|
||||
&:active input,
|
||||
.search-inner-wrapper:active input,
|
||||
input:focus {
|
||||
border: $input-border-active;
|
||||
box-shadow: var(--newtab-textbox-focus-boxshadow);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class SelectableSearchShortcut extends React.PureComponent {
|
|||
const {shortcut, selected} = this.props;
|
||||
const imageStyle = {backgroundImage: `url("${shortcut.tippyTopIcon}")`};
|
||||
return (
|
||||
<div className="top-site-outer">
|
||||
<div className="top-site-outer search-shortcut">
|
||||
<input type="checkbox" id={shortcut.keyword} name={shortcut.keyword} checked={selected} onChange={this.props.onChange} />
|
||||
<label htmlFor={shortcut.keyword}>
|
||||
<div className="top-site-inner">
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ export class TopSiteLink extends React.PureComponent {
|
|||
}
|
||||
break;
|
||||
case "mousedown":
|
||||
// Block the scroll wheel from appearing for middle clicks on search top sites
|
||||
if (event.button === 1 && this.props.link.searchTopSite) {
|
||||
event.preventDefault();
|
||||
}
|
||||
// Reset at the first mouse event of a potential drag
|
||||
this.dragged = false;
|
||||
break;
|
||||
|
|
@ -110,7 +114,7 @@ export class TopSiteLink extends React.PureComponent {
|
|||
|
||||
render() {
|
||||
const {children, className, defaultStyle, isDraggable, link, onClick, title} = this.props;
|
||||
const topSiteOuterClassName = `top-site-outer${className ? ` ${className}` : ""}${link.isDragged ? " dragged" : ""}`;
|
||||
const topSiteOuterClassName = `top-site-outer${className ? ` ${className}` : ""}${link.isDragged ? " dragged" : ""}${link.searchTopSite ? " search-shortcut" : ""}`;
|
||||
const {tippyTopIcon, faviconSize} = link;
|
||||
const [letterFallback] = title;
|
||||
let imageClassName;
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ export class _TopSites extends React.PureComponent {
|
|||
onSearchShortcutsFormClose() {
|
||||
this.props.dispatch(ac.UserEvent({
|
||||
source: TOP_SITES_SOURCE,
|
||||
event: "TOP_SITES_SEARCH_SHORTCUTS_CLOSE"
|
||||
event: "SEARCH_EDIT_CLOSE"
|
||||
}));
|
||||
this.props.dispatch({type: at.TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,6 +208,13 @@ $half-base-gutter: $base-gutter / 2;
|
|||
box-shadow: inset 0 0 0 1px var(--newtab-inner-box-shadow-color), var(--newtab-card-shadow);
|
||||
}
|
||||
|
||||
// We want all search shortcuts to have a white background in case they have transparency.
|
||||
&.search-shortcut {
|
||||
.rich-icon {
|
||||
background-color: $white;
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
color: var(--newtab-topsites-label-color);
|
||||
font: message-box;
|
||||
|
|
@ -275,6 +282,8 @@ $half-base-gutter: $base-gutter / 2;
|
|||
box-shadow: $shadow-secondary;
|
||||
left: 0;
|
||||
margin: 0 auto;
|
||||
max-height: calc(100% - 40px);
|
||||
overflow-y: auto;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 40px;
|
||||
|
|
@ -318,13 +327,13 @@ $half-base-gutter: $base-gutter / 2;
|
|||
margin: 0 auto;
|
||||
padding: $form-spacing;
|
||||
|
||||
> div {
|
||||
margin-inline-end: -39px;
|
||||
}
|
||||
|
||||
.top-site-outer {
|
||||
margin-inline-start: 0;
|
||||
margin-inline-end: 39px;
|
||||
|
||||
&:nth-child(5n) {
|
||||
margin-inline-end: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ export const SectionMenuOptions = {
|
|||
id: "section_menu_action_add_search_engine",
|
||||
icon: "search",
|
||||
action: {type: at.TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL},
|
||||
userEvent: "MENU_ADD_SEARCH_SHORTCUTS"
|
||||
userEvent: "MENU_ADD_SEARCH"
|
||||
}),
|
||||
PrivacyNotice: section => ({
|
||||
id: "section_menu_action_privacy_notice",
|
||||
|
|
|
|||
|
|
@ -77,6 +77,11 @@ $icon-size: 16px;
|
|||
$smaller-icon-size: 12px;
|
||||
$larger-icon-size: 32px;
|
||||
|
||||
$searchbar-width-smallest: $grid-unit * 2 + $base-gutter * 1;
|
||||
$searchbar-width-small: $grid-unit * 3 + $base-gutter * 2;
|
||||
$searchbar-width-medium: $grid-unit * 4 + $base-gutter * 3;
|
||||
$searchbar-width-large: $grid-unit * 6 + $base-gutter * 5;
|
||||
|
||||
$wrapper-default-width: $grid-unit * 2 + $base-gutter * 1 + $section-horizontal-padding * 2; // 2 top sites
|
||||
$wrapper-max-width-small: $grid-unit * 3 + $base-gutter * 2 + $section-horizontal-padding * 2; // 3 top sites
|
||||
$wrapper-max-width-medium: $grid-unit * 4 + $base-gutter * 3 + $section-horizontal-padding * 2; // 4 top sites
|
||||
|
|
@ -91,8 +96,6 @@ $break-point-medium: $wrapper-max-width-medium + $base-gutter * 2 + $scrollbar-w
|
|||
$break-point-large: $wrapper-max-width-large + $base-gutter * 2 + $scrollbar-width;
|
||||
$break-point-widest: $wrapper-max-width-widest + $base-gutter * 2 + $scrollbar-width;
|
||||
|
||||
$max-searchbar-width: $grid-unit * 6 + $base-gutter * 5;
|
||||
|
||||
$section-title-font-size: 13px;
|
||||
|
||||
$card-width: $grid-unit * 2 + $base-gutter;
|
||||
|
|
|
|||
|
|
@ -577,6 +577,8 @@ main {
|
|||
-moz-context-properties: fill;
|
||||
fill: #FFF;
|
||||
box-shadow: inset 0 0 0 1px var(--newtab-inner-box-shadow-color), var(--newtab-card-shadow); }
|
||||
.top-site-outer.search-shortcut .rich-icon {
|
||||
background-color: #FFF; }
|
||||
.top-site-outer .title {
|
||||
color: var(--newtab-topsites-label-color);
|
||||
font: message-box;
|
||||
|
|
@ -616,6 +618,8 @@ main {
|
|||
box-shadow: 0 1px 4px 0 rgba(12, 12, 13, 0.2);
|
||||
left: 0;
|
||||
margin: 0 auto;
|
||||
max-height: calc(100% - 40px);
|
||||
overflow-y: auto;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 40px;
|
||||
|
|
@ -645,11 +649,11 @@ main {
|
|||
max-width: 700px;
|
||||
margin: 0 auto;
|
||||
padding: 32px; }
|
||||
.topsite-form .search-shortcuts-container > div {
|
||||
margin-inline-end: -39px; }
|
||||
.topsite-form .search-shortcuts-container .top-site-outer {
|
||||
margin-inline-start: 0;
|
||||
margin-inline-end: 39px; }
|
||||
.topsite-form .search-shortcuts-container .top-site-outer:nth-child(5n) {
|
||||
margin-inline-end: 0; }
|
||||
|
||||
.topsite-form .top-site-outer {
|
||||
padding: 0;
|
||||
|
|
@ -1222,12 +1226,18 @@ a.firstrun-link {
|
|||
cursor: default;
|
||||
display: flex;
|
||||
height: 48px;
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
width: 100%; }
|
||||
@media (min-width: 866px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
margin: 0 auto;
|
||||
width: 736px; } }
|
||||
width: 224px; }
|
||||
@media (min-width: 482px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
width: 352px; } }
|
||||
@media (min-width: 610px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
width: 480px; } }
|
||||
@media (min-width: 866px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
width: 736px; } }
|
||||
.search-wrapper input {
|
||||
background: var(--newtab-textbox-background-color) var(--newtab-search-icon) 12px center no-repeat;
|
||||
background-size: 24px;
|
||||
|
|
@ -1244,7 +1254,7 @@ a.firstrun-link {
|
|||
background-position-x: right 12px; }
|
||||
.search-wrapper:hover input {
|
||||
box-shadow: 0 1px 4px 0 rgba(12, 12, 13, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.25); }
|
||||
.search-wrapper:active input,
|
||||
.search-wrapper .search-inner-wrapper:active input,
|
||||
.search-wrapper input:focus {
|
||||
border: 1px solid var(--newtab-textbox-focus-color);
|
||||
box-shadow: var(--newtab-textbox-focus-boxshadow); }
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -580,6 +580,8 @@ main {
|
|||
-moz-context-properties: fill;
|
||||
fill: #FFF;
|
||||
box-shadow: inset 0 0 0 1px var(--newtab-inner-box-shadow-color), var(--newtab-card-shadow); }
|
||||
.top-site-outer.search-shortcut .rich-icon {
|
||||
background-color: #FFF; }
|
||||
.top-site-outer .title {
|
||||
color: var(--newtab-topsites-label-color);
|
||||
font: message-box;
|
||||
|
|
@ -619,6 +621,8 @@ main {
|
|||
box-shadow: 0 1px 4px 0 rgba(12, 12, 13, 0.2);
|
||||
left: 0;
|
||||
margin: 0 auto;
|
||||
max-height: calc(100% - 40px);
|
||||
overflow-y: auto;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 40px;
|
||||
|
|
@ -648,11 +652,11 @@ main {
|
|||
max-width: 700px;
|
||||
margin: 0 auto;
|
||||
padding: 32px; }
|
||||
.topsite-form .search-shortcuts-container > div {
|
||||
margin-inline-end: -39px; }
|
||||
.topsite-form .search-shortcuts-container .top-site-outer {
|
||||
margin-inline-start: 0;
|
||||
margin-inline-end: 39px; }
|
||||
.topsite-form .search-shortcuts-container .top-site-outer:nth-child(5n) {
|
||||
margin-inline-end: 0; }
|
||||
|
||||
.topsite-form .top-site-outer {
|
||||
padding: 0;
|
||||
|
|
@ -1225,12 +1229,18 @@ a.firstrun-link {
|
|||
cursor: default;
|
||||
display: flex;
|
||||
height: 48px;
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
width: 100%; }
|
||||
@media (min-width: 866px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
margin: 0 auto;
|
||||
width: 736px; } }
|
||||
width: 224px; }
|
||||
@media (min-width: 482px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
width: 352px; } }
|
||||
@media (min-width: 610px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
width: 480px; } }
|
||||
@media (min-width: 866px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
width: 736px; } }
|
||||
.search-wrapper input {
|
||||
background: var(--newtab-textbox-background-color) var(--newtab-search-icon) 12px center no-repeat;
|
||||
background-size: 24px;
|
||||
|
|
@ -1247,7 +1257,7 @@ a.firstrun-link {
|
|||
background-position-x: right 12px; }
|
||||
.search-wrapper:hover input {
|
||||
box-shadow: 0 1px 4px 0 rgba(12, 12, 13, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.25); }
|
||||
.search-wrapper:active input,
|
||||
.search-wrapper .search-inner-wrapper:active input,
|
||||
.search-wrapper input:focus {
|
||||
border: 1px solid var(--newtab-textbox-focus-color);
|
||||
box-shadow: var(--newtab-textbox-focus-boxshadow); }
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -577,6 +577,8 @@ main {
|
|||
-moz-context-properties: fill;
|
||||
fill: #FFF;
|
||||
box-shadow: inset 0 0 0 1px var(--newtab-inner-box-shadow-color), var(--newtab-card-shadow); }
|
||||
.top-site-outer.search-shortcut .rich-icon {
|
||||
background-color: #FFF; }
|
||||
.top-site-outer .title {
|
||||
color: var(--newtab-topsites-label-color);
|
||||
font: message-box;
|
||||
|
|
@ -616,6 +618,8 @@ main {
|
|||
box-shadow: 0 1px 4px 0 rgba(12, 12, 13, 0.2);
|
||||
left: 0;
|
||||
margin: 0 auto;
|
||||
max-height: calc(100% - 40px);
|
||||
overflow-y: auto;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 40px;
|
||||
|
|
@ -645,11 +649,11 @@ main {
|
|||
max-width: 700px;
|
||||
margin: 0 auto;
|
||||
padding: 32px; }
|
||||
.topsite-form .search-shortcuts-container > div {
|
||||
margin-inline-end: -39px; }
|
||||
.topsite-form .search-shortcuts-container .top-site-outer {
|
||||
margin-inline-start: 0;
|
||||
margin-inline-end: 39px; }
|
||||
.topsite-form .search-shortcuts-container .top-site-outer:nth-child(5n) {
|
||||
margin-inline-end: 0; }
|
||||
|
||||
.topsite-form .top-site-outer {
|
||||
padding: 0;
|
||||
|
|
@ -1222,12 +1226,18 @@ a.firstrun-link {
|
|||
cursor: default;
|
||||
display: flex;
|
||||
height: 48px;
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
width: 100%; }
|
||||
@media (min-width: 866px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
margin: 0 auto;
|
||||
width: 736px; } }
|
||||
width: 224px; }
|
||||
@media (min-width: 482px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
width: 352px; } }
|
||||
@media (min-width: 610px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
width: 480px; } }
|
||||
@media (min-width: 866px) {
|
||||
.search-wrapper .search-inner-wrapper {
|
||||
width: 736px; } }
|
||||
.search-wrapper input {
|
||||
background: var(--newtab-textbox-background-color) var(--newtab-search-icon) 12px center no-repeat;
|
||||
background-size: 24px;
|
||||
|
|
@ -1244,7 +1254,7 @@ a.firstrun-link {
|
|||
background-position-x: right 12px; }
|
||||
.search-wrapper:hover input {
|
||||
box-shadow: 0 1px 4px 0 rgba(12, 12, 13, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.25); }
|
||||
.search-wrapper:active input,
|
||||
.search-wrapper .search-inner-wrapper:active input,
|
||||
.search-wrapper input:focus {
|
||||
border: 1px solid var(--newtab-textbox-focus-color);
|
||||
box-shadow: var(--newtab-textbox-focus-boxshadow); }
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -3597,7 +3597,7 @@ const SectionMenuOptions = {
|
|||
id: "section_menu_action_add_search_engine",
|
||||
icon: "search",
|
||||
action: { type: common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionTypes"].TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL },
|
||||
userEvent: "MENU_ADD_SEARCH_SHORTCUTS"
|
||||
userEvent: "MENU_ADD_SEARCH"
|
||||
}),
|
||||
PrivacyNotice: section => ({
|
||||
id: "section_menu_action_privacy_notice",
|
||||
|
|
@ -4104,7 +4104,7 @@ class _TopSites extends react__WEBPACK_IMPORTED_MODULE_6___default.a.PureCompone
|
|||
onSearchShortcutsFormClose() {
|
||||
this.props.dispatch(common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionCreators"].UserEvent({
|
||||
source: _TopSitesConstants__WEBPACK_IMPORTED_MODULE_1__["TOP_SITES_SOURCE"],
|
||||
event: "TOP_SITES_SEARCH_SHORTCUTS_CLOSE"
|
||||
event: "SEARCH_EDIT_CLOSE"
|
||||
}));
|
||||
this.props.dispatch({ type: common_Actions_jsm__WEBPACK_IMPORTED_MODULE_0__["actionTypes"].TOP_SITES_CLOSE_SEARCH_SHORTCUTS_MODAL });
|
||||
}
|
||||
|
|
@ -4221,7 +4221,7 @@ class SelectableSearchShortcut extends react__WEBPACK_IMPORTED_MODULE_2___defaul
|
|||
const imageStyle = { backgroundImage: `url("${shortcut.tippyTopIcon}")` };
|
||||
return react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(
|
||||
"div",
|
||||
{ className: "top-site-outer" },
|
||||
{ className: "top-site-outer search-shortcut" },
|
||||
react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement("input", { type: "checkbox", id: shortcut.keyword, name: shortcut.keyword, checked: selected, onChange: this.props.onChange }),
|
||||
react__WEBPACK_IMPORTED_MODULE_2___default.a.createElement(
|
||||
"label",
|
||||
|
|
@ -4453,6 +4453,10 @@ class TopSiteLink extends react__WEBPACK_IMPORTED_MODULE_4___default.a.PureCompo
|
|||
}
|
||||
break;
|
||||
case "mousedown":
|
||||
// Block the scroll wheel from appearing for middle clicks on search top sites
|
||||
if (event.button === 1 && this.props.link.searchTopSite) {
|
||||
event.preventDefault();
|
||||
}
|
||||
// Reset at the first mouse event of a potential drag
|
||||
this.dragged = false;
|
||||
break;
|
||||
|
|
@ -4509,7 +4513,7 @@ class TopSiteLink extends react__WEBPACK_IMPORTED_MODULE_4___default.a.PureCompo
|
|||
|
||||
render() {
|
||||
const { children, className, defaultStyle, isDraggable, link, onClick, title } = this.props;
|
||||
const topSiteOuterClassName = `top-site-outer${className ? ` ${className}` : ""}${link.isDragged ? " dragged" : ""}`;
|
||||
const topSiteOuterClassName = `top-site-outer${className ? ` ${className}` : ""}${link.isDragged ? " dragged" : ""}${link.searchTopSite ? " search-shortcut" : ""}`;
|
||||
const { tippyTopIcon, faviconSize } = link;
|
||||
const [letterFallback] = title;
|
||||
let imageClassName;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -3,24 +3,26 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// List of sites we match against Topsites in order to identify sites
|
||||
// that should be converted to search Topsites
|
||||
const SEARCH_SHORTCUTS = [
|
||||
{keyword: "@amazon", shortURL: "amazon", url: "https://amazon.com", searchIdentifier: /^amazon/},
|
||||
{keyword: "@\u767E\u5EA6", shortURL: "baidu", url: "https://baidu.com", searchIdentifier: /^baidu/},
|
||||
{keyword: "@google", shortURL: "google", url: "https://google.com", searchIdentifier: /^google/},
|
||||
{keyword: "@\u044F\u043D\u0434\u0435\u043A\u0441", shortURL: "yandex", url: "https://yandex.com", searchIdentifier: /^yandex/}
|
||||
{keyword: "@amazon", shortURL: "amazon", url: "https://amazon.com"},
|
||||
{keyword: "@\u767E\u5EA6", shortURL: "baidu", url: "https://baidu.com"},
|
||||
{keyword: "@google", shortURL: "google", url: "https://google.com"},
|
||||
{keyword: "@\u044F\u043D\u0434\u0435\u043A\u0441", shortURL: "yandex", url: "https://yandex.com"}
|
||||
];
|
||||
this.SEARCH_SHORTCUTS = SEARCH_SHORTCUTS;
|
||||
|
||||
// These can be added via the editor but will not be added organically
|
||||
this.CUSTOM_SEARCH_SHORTCUTS = [
|
||||
...SEARCH_SHORTCUTS,
|
||||
{keyword: "@bing", shortURL: "bing", url: "https://bing.com", searchIdentifier: /^bing/},
|
||||
{keyword: "@duckduckgo", shortURL: "duckduckgo", url: "https://duckduckgo.com", searchIdentifier: /^ddg/},
|
||||
{keyword: "@ebay", shortURL: "ebay", url: "https://ebay.com", searchIdentifier: /^ebay/},
|
||||
{keyword: "@twitter", shortURL: "twitter", url: "https://twitter.com", searchIdentifier: /^twitter/},
|
||||
{keyword: "@wikipedia", shortURL: "wikipedia", url: "https://wikipedia.org", searchIdentifier: /^wikipedia/}
|
||||
{keyword: "@bing", shortURL: "bing", url: "https://bing.com"},
|
||||
{keyword: "@duckduckgo", shortURL: "duckduckgo", url: "https://duckduckgo.com"},
|
||||
{keyword: "@ebay", shortURL: "ebay", url: "https://ebay.com"},
|
||||
{keyword: "@twitter", shortURL: "twitter", url: "https://twitter.com"},
|
||||
{keyword: "@wikipedia", shortURL: "wikipedia", url: "https://wikipedia.org"}
|
||||
];
|
||||
|
||||
// Note: you must add the activity stream branch to the beginning of this if using outside activity stream
|
||||
|
|
@ -33,5 +35,13 @@ function getSearchProvider(candidateShortURL) {
|
|||
}
|
||||
this.getSearchProvider = getSearchProvider;
|
||||
|
||||
const EXPORTED_SYMBOLS = ["getSearchProvider", "SEARCH_SHORTCUTS", "CUSTOM_SEARCH_SHORTCUTS", "SEARCH_SHORTCUTS_EXPERIMENT",
|
||||
// Check topsite against predefined list of valid search engines
|
||||
// https://searchfox.org/mozilla-central/rev/ca869724246f4230b272ed1c8b9944596e80d920/toolkit/components/search/nsSearchService.js#939
|
||||
function checkHasSearchEngine(keyword) {
|
||||
return Services.search.getDefaultEngines()
|
||||
.find(e => e.wrappedJSObject._internalAliases.includes(keyword));
|
||||
}
|
||||
this.checkHasSearchEngine = checkHasSearchEngine;
|
||||
|
||||
const EXPORTED_SYMBOLS = ["checkHasSearchEngine", "getSearchProvider", "SEARCH_SHORTCUTS", "CUSTOM_SEARCH_SHORTCUTS", "SEARCH_SHORTCUTS_EXPERIMENT",
|
||||
"SEARCH_SHORTCUTS_SEARCH_ENGINES_PREF", "SEARCH_SHORTCUTS_HAVE_PINNED_PREF"];
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ const {
|
|||
SEARCH_SHORTCUTS_EXPERIMENT,
|
||||
SEARCH_SHORTCUTS_SEARCH_ENGINES_PREF,
|
||||
SEARCH_SHORTCUTS_HAVE_PINNED_PREF,
|
||||
checkHasSearchEngine,
|
||||
getSearchProvider
|
||||
} = ChromeUtils.import("resource://activity-stream/lib/SearchShortcuts.jsm", {});
|
||||
|
||||
|
|
@ -190,7 +191,7 @@ this.TopSitesFeed = class TopSitesFeed {
|
|||
!pinnedSites.find(s => s && s.hostname === shortcut.shortURL) &&
|
||||
!prevInsertedShortcuts.includes(shortcut.shortURL) &&
|
||||
nextAvailable > -1 &&
|
||||
Services.search.getEngines().find(e => e.identifier && e.identifier.match(shortcut.searchIdentifier))
|
||||
checkHasSearchEngine(shortcut.keyword)
|
||||
) {
|
||||
const site = this.topSiteToSearchTopSite({url: shortcut.url});
|
||||
this._pinSiteAt(site, nextAvailable);
|
||||
|
|
@ -376,11 +377,9 @@ this.TopSitesFeed = class TopSitesFeed {
|
|||
// Populate the state with available search shortcuts
|
||||
await new Promise(resolve => Services.search.init(resolve));
|
||||
const searchShortcuts = Services.search.getDefaultEngines().reduce((result, engine) => {
|
||||
if (engine.identifier) {
|
||||
const shortcut = CUSTOM_SEARCH_SHORTCUTS.find(s => engine.identifier.match(s.searchIdentifier));
|
||||
if (shortcut) {
|
||||
result.push(this._tippyTopProvider.processSite({...shortcut}));
|
||||
}
|
||||
const shortcut = CUSTOM_SEARCH_SHORTCUTS.find(s => engine.wrappedJSObject._internalAliases.includes(s.keyword));
|
||||
if (shortcut) {
|
||||
result.push(this._tippyTopProvider.processSite({...shortcut}));
|
||||
}
|
||||
return result;
|
||||
}, []);
|
||||
|
|
@ -392,7 +391,7 @@ this.TopSitesFeed = class TopSitesFeed {
|
|||
|
||||
topSiteToSearchTopSite(site) {
|
||||
const searchProvider = getSearchProvider(shortURL(site));
|
||||
if (!searchProvider) {
|
||||
if (!searchProvider || !checkHasSearchEngine(searchProvider.keyword)) {
|
||||
return site;
|
||||
}
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ this.TopStoriesFeed = class TopStoriesFeed {
|
|||
try {
|
||||
const {options} = SectionsManager.sections.get(SECTION_ID);
|
||||
const apiKey = this.getApiKeyFromPref(options.api_key_pref);
|
||||
// Set this to true if we're not loading from cache.
|
||||
let shouldBroadcast = false;
|
||||
this.stories_endpoint = this.produceFinalEndpointUrl(options.stories_endpoint, apiKey);
|
||||
this.topics_endpoint = this.produceFinalEndpointUrl(options.topics_endpoint, apiKey);
|
||||
this.read_more_endpoint = options.read_more_endpoint;
|
||||
|
|
@ -57,17 +55,14 @@ this.TopStoriesFeed = class TopStoriesFeed {
|
|||
// Cache is used for new page loads, which shouldn't have changed data.
|
||||
// If we have changed data, cache should be cleared,
|
||||
// and last updated should be 0, and we can fetch.
|
||||
// Think there is a bug here.
|
||||
await this.loadCachedData();
|
||||
if (this.storiesLastUpdated === 0) {
|
||||
shouldBroadcast = true;
|
||||
await this.fetchStories();
|
||||
}
|
||||
if (this.topicsLastUpdated === 0) {
|
||||
shouldBroadcast = true;
|
||||
await this.fetchTopics();
|
||||
}
|
||||
this.doContentUpdate(shouldBroadcast);
|
||||
this.doContentUpdate(true);
|
||||
this.storiesLoaded = true;
|
||||
|
||||
// This is filtered so an update function can return true to retry on the next run
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ section_menu_action_expand_section=Espandi sezione
|
|||
section_menu_action_manage_section=Gestisci sezione
|
||||
section_menu_action_manage_webext=Gestisci estensione
|
||||
section_menu_action_add_topsite=Aggiungi sito principale
|
||||
section_menu_action_add_search_engine=Aggiungi motore di ricerca
|
||||
section_menu_action_move_up=Sposta in alto
|
||||
section_menu_action_move_down=Sposta in basso
|
||||
section_menu_action_privacy_notice=Informativa sulla privacy
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ prefs_home_description=Vel kva for innhald du vil ha på Firefox-startsida di.
|
|||
# See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
prefs_section_rows_option={num} rekke;{num} rekkjer
|
||||
prefs_search_header=Nettsøk
|
||||
prefs_topsites_description=Sidene du besøker mest
|
||||
prefs_topsites_description=Sidene du besøkjer mest
|
||||
prefs_topstories_description2=Bra innhald frå heile nettet, tilpassa for deg
|
||||
prefs_topstories_options_sponsored_label=Sponsa historiar
|
||||
prefs_topstories_sponsored_learn_more=Les meir
|
||||
|
|
@ -201,4 +201,4 @@ firstrun_privacy_notice=Personvernpraksis
|
|||
|
||||
firstrun_continue_to_login=Fortset
|
||||
firstrun_skip_login=Hopp over dette steget
|
||||
section_menu_action_add_search_engine=Legg til søkemotor
|
||||
section_menu_action_add_search_engine=Legg til søkjemotor
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ cd /activity-stream && npm install . && npm run buildmc
|
|||
# Build latest m-c with Activity Stream changes
|
||||
cd /mozilla-central && ./mach build \
|
||||
&& ./mach test browser_parsable_css \
|
||||
&& ./mach lint -l eslint -l codespell browser/components/newtab \
|
||||
&& ./mach lint -l codespell browser/components/newtab \
|
||||
&& ./mach test browser/components/newtab/test/browser --headless \
|
||||
&& ./mach test browser/components/newtab/test/xpcshell \
|
||||
&& ./mach test browser/components/preferences/in-content/tests/browser_hometab_restore_defaults.js --headless \
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ window.gActivityStreamStrings = {
|
|||
"prefs_home_description": "Vel kva for innhald du vil ha på Firefox-startsida di.",
|
||||
"prefs_section_rows_option": "{num} rekke;{num} rekkjer",
|
||||
"prefs_search_header": "Nettsøk",
|
||||
"prefs_topsites_description": "Sidene du besøker mest",
|
||||
"prefs_topsites_description": "Sidene du besøkjer mest",
|
||||
"prefs_topstories_description2": "Bra innhald frå heile nettet, tilpassa for deg",
|
||||
"prefs_topstories_options_sponsored_label": "Sponsa historiar",
|
||||
"prefs_topstories_sponsored_learn_more": "Les meir",
|
||||
|
|
@ -87,7 +87,7 @@ window.gActivityStreamStrings = {
|
|||
"section_menu_action_manage_section": "Handter seksjon",
|
||||
"section_menu_action_manage_webext": "Handter utviding",
|
||||
"section_menu_action_add_topsite": "Legg til mest besøkte",
|
||||
"section_menu_action_add_search_engine": "Legg til søkemotor",
|
||||
"section_menu_action_add_search_engine": "Legg til søkjemotor",
|
||||
"section_menu_action_move_up": "Flytt opp",
|
||||
"section_menu_action_move_down": "Flytt ned",
|
||||
"section_menu_action_privacy_notice": "Personvernmerknad",
|
||||
|
|
|
|||
|
|
@ -1182,14 +1182,11 @@ describe("Top Sites Feed", () => {
|
|||
feed.store.state.Prefs.values[SEARCH_SHORTCUTS_EXPERIMENT_PREF] = true;
|
||||
feed.store.state.Prefs.values[SEARCH_SHORTCUTS_SEARCH_ENGINES_PREF] = "google,amazon";
|
||||
feed.store.state.Prefs.values[SEARCH_SHORTCUTS_HAVE_PINNED_PREF] = "";
|
||||
global.Services.search.getEngines = () => [
|
||||
{identifier: "google"},
|
||||
{identifier: "amazon"}
|
||||
];
|
||||
global.Services.search.getDefaultEngines = () => [
|
||||
{identifier: "google"},
|
||||
{identifier: "amazon"}
|
||||
const searchEngines = [
|
||||
{wrappedJSObject: {_internalAliases: ["@google"]}},
|
||||
{wrappedJSObject: {_internalAliases: ["@amazon"]}}
|
||||
];
|
||||
global.Services.search.getDefaultEngines = () => searchEngines;
|
||||
fakeNewTabUtils.pinnedLinks.pin = sinon.stub().callsFake((site, index) => {
|
||||
fakeNewTabUtils.pinnedLinks.links[index] = site;
|
||||
});
|
||||
|
|
@ -1295,12 +1292,10 @@ describe("Top Sites Feed", () => {
|
|||
data: {
|
||||
searchShortcuts: [{
|
||||
keyword: "@google",
|
||||
searchIdentifier: /^google/,
|
||||
shortURL: "google",
|
||||
url: "https://google.com"
|
||||
}, {
|
||||
keyword: "@amazon",
|
||||
searchIdentifier: /^amazon/,
|
||||
shortURL: "amazon",
|
||||
url: "https://amazon.com"
|
||||
}]
|
||||
|
|
@ -1355,7 +1350,7 @@ describe("Top Sites Feed", () => {
|
|||
|
||||
it("should not pin a shortcut if the corresponding search engine is not available", async () => {
|
||||
// Make Amazon search engine unavailable
|
||||
global.Services.search.getEngines = () => [{identifier: "google"}];
|
||||
global.Services.search.getDefaultEngines = () => [{wrappedJSObject: {_internalAliases: ["@google"]}}];
|
||||
fakeNewTabUtils.pinnedLinks.links.fill(null);
|
||||
await feed._maybeInsertSearchShortcuts(fakeNewTabUtils.pinnedLinks.links);
|
||||
assert.notOk(fakeNewTabUtils.pinnedLinks.links.find(s => s && s.url === "https://amazon.com"));
|
||||
|
|
|
|||
|
|
@ -1007,6 +1007,17 @@ describe("Top Stories Feed", () => {
|
|||
await instance.loadCachedData();
|
||||
assert.notCalled(sectionsManagerStub.updateSection);
|
||||
});
|
||||
it("should broadcast in doContentUpdate when updating from cache", async () => {
|
||||
sectionsManagerStub.sections.set("topstories", {options: {stories_referrer: "referrer"}});
|
||||
globals.set("NewTabUtils", {blockedLinks: {isBlocked: () => {}}});
|
||||
const stories = {"recommendations": [{}]};
|
||||
const topics = {"topics": [{}]};
|
||||
sinon.spy(instance, "doContentUpdate");
|
||||
instance.cache.get = () => ({stories, topics});
|
||||
await instance.onInit();
|
||||
assert.calledOnce(instance.doContentUpdate);
|
||||
assert.calledWith(instance.doContentUpdate, true);
|
||||
});
|
||||
it("should initialize user domain affinity provider from cache if personalization is preffed on", async () => {
|
||||
const domainAffinities = {
|
||||
"parameterSets": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue