Commit 623e45e7 authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

Settings: Port search_engines_page/ to Polymer 3.

 - Fix a bug in route.js where pageVisibility is undefined in
   Polymer 3.
 - Fix a newly found type-check error in
   global_scroll_target_begavior.js (only happens in the context
   of a JS module).
 - Update search_engines_page/ prod and test code as needed.
 - Update BUILD.gn, grdp files as needed.

Bug: 1026426
Change-Id: Ic2229bebdca80d08189943fabd62e1d86f050a2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032669
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738448}
parent 74b8bba7
......@@ -213,6 +213,7 @@ group("closure_compile_module") {
":closure_compile_local_module",
"controls:closure_compile_module",
"prefs:closure_compile_module",
"search_engines_page:closure_compile_module",
]
}
......
......@@ -82,7 +82,7 @@ cr.define('settings', function() {
* Returns the target only when the route is active.
* @param {HTMLElement} target
* @param {boolean} active
* @return {?HTMLElement}
* @return {?HTMLElement|undefined}
* @private
*/
getActiveTarget_(target, active) {
......
......@@ -109,23 +109,23 @@ cr.define('settings', function() {
r.SYNC_ADVANCED = r.SYNC.createChild('/syncSetup/advanced');
}
/* #ignore */ const pageVisibility = settings.pageVisibility || {};
const visibility = settings.pageVisibility || {};
// <if expr="not chromeos">
r.IMPORT_DATA = r.BASIC.createChild('/importData');
r.IMPORT_DATA.isNavigableDialog = true;
if (pageVisibility.people !== false) {
if (visibility.people !== false) {
r.MANAGE_PROFILE = r.PEOPLE.createChild('/manageProfile');
}
// </if>
if (pageVisibility.appearance !== false) {
if (visibility.appearance !== false) {
r.APPEARANCE = r.BASIC.createSection('/appearance', 'appearance');
r.FONTS = r.APPEARANCE.createChild('/fonts');
}
if (pageVisibility.autofill !== false) {
if (visibility.autofill !== false) {
r.AUTOFILL = r.BASIC.createSection('/autofill', 'autofill');
r.PASSWORDS = r.AUTOFILL.createChild('/passwords');
r.PAYMENTS = r.AUTOFILL.createChild('/payments');
......@@ -135,25 +135,25 @@ cr.define('settings', function() {
r.CLEAR_BROWSER_DATA = r.BASIC.createChild('/clearBrowserData');
r.CLEAR_BROWSER_DATA.isNavigableDialog = true;
if (pageVisibility.privacy !== false) {
if (visibility.privacy !== false) {
r.PRIVACY = r.BASIC.createSection('/privacy', 'privacy');
addPrivacyChildRoutes(r);
}
if (pageVisibility.defaultBrowser !== false) {
if (visibility.defaultBrowser !== false) {
r.DEFAULT_BROWSER =
r.BASIC.createSection('/defaultBrowser', 'defaultBrowser');
}
r.SEARCH_ENGINES = r.SEARCH.createChild('/searchEngines');
if (pageVisibility.onStartup !== false) {
if (visibility.onStartup !== false) {
r.ON_STARTUP = r.BASIC.createSection('/onStartup', 'onStartup');
r.STARTUP_PAGES = r.ON_STARTUP.createChild('/startupPages');
}
// Advanced Routes
if (pageVisibility.advancedSettings !== false) {
if (visibility.advancedSettings !== false) {
r.ADVANCED = new settings.Route('/advanced');
r.LANGUAGES = r.ADVANCED.createSection('/languages', 'languages');
......@@ -161,7 +161,7 @@ cr.define('settings', function() {
r.EDIT_DICTIONARY = r.LANGUAGES.createChild('/editDictionary');
// </if>
if (pageVisibility.downloads !== false) {
if (visibility.downloads !== false) {
r.DOWNLOADS = r.ADVANCED.createSection('/downloads', 'downloads');
}
......@@ -184,7 +184,7 @@ cr.define('settings', function() {
r.SYSTEM = r.ADVANCED.createSection('/system', 'system');
// </if>
if (pageVisibility.reset !== false) {
if (visibility.reset !== false) {
r.RESET = r.ADVANCED.createSection('/reset', 'reset');
r.RESET_DIALOG = r.ADVANCED.createChild('/resetProfileSettings');
r.RESET_DIALOG.isNavigableDialog = true;
......
......@@ -3,6 +3,9 @@
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/polymer/polymer.gni")
import("//ui/webui/resources/tools/js_modulizer.gni")
import("../settings.gni")
js_type_check("closure_compile") {
deps = [
......@@ -18,6 +21,7 @@ js_type_check("closure_compile") {
js_library("search_engine_dialog") {
deps = [
":search_engines_browser_proxy",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:load_time_data",
"//ui/webui/resources/js:web_ui_listener_behavior",
......@@ -67,6 +71,7 @@ js_library("search_engines_page") {
":search_engines_browser_proxy",
"..:global_scroll_target_behavior",
"..:route",
"//third_party/polymer/v1_0/components-chromium/iron-list:iron-list-extracted",
"//third_party/polymer/v1_0/components-chromium/iron-resizable-behavior:iron-resizable-behavior-extracted",
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:cr",
......@@ -75,23 +80,27 @@ js_library("search_engines_page") {
]
}
# TODO(crbug.com/1026426): Fix and enable.
#js_type_check("closure_compile_module") {
# is_polymer3 = true
# deps = [
# ":omnibox_extension_entry.m",
# ":search_engine_dialog.m",
# ":search_engine_entry.m",
# ":search_engines_browser_proxy.m",
# ":search_engines_list.m",
# ":search_engines_page.m",
# ]
#}
js_type_check("closure_compile_module") {
is_polymer3 = true
deps = [
":omnibox_extension_entry.m",
":search_engine_dialog.m",
":search_engine_entry.m",
":search_engines_browser_proxy.m",
":search_engines_list.m",
":search_engines_page.m",
]
}
js_library("omnibox_extension_entry.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/search_engines_page/omnibox_extension_entry.m.js" ]
deps = [
# TODO: Fill those in.
":search_engines_browser_proxy.m",
"..:extension_control_browser_proxy.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu.m",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js/cr/ui:focus_row_behavior.m",
]
extra_deps = [ ":omnibox_extension_entry_module" ]
}
......@@ -99,7 +108,11 @@ js_library("omnibox_extension_entry.m") {
js_library("search_engine_dialog.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.m.js" ]
deps = [
# TODO: Fill those in.
":search_engines_browser_proxy.m",
"..:i18n_setup.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
"//ui/webui/resources/js:web_ui_listener_behavior.m",
]
extra_deps = [ ":search_engine_dialog_module" ]
}
......@@ -107,23 +120,26 @@ js_library("search_engine_dialog.m") {
js_library("search_engine_entry.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/search_engines_page/search_engine_entry.m.js" ]
deps = [
# TODO: Fill those in.
":search_engines_browser_proxy.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu.m",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js/cr/ui:focus_row_behavior.m",
]
extra_deps = [ ":search_engine_entry_module" ]
}
js_library("search_engines_browser_proxy.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.m.js" ]
deps = [
# TODO: Fill those in.
]
deps = [ "//ui/webui/resources/js:cr.m" ]
extra_deps = [ ":modulize" ]
}
js_library("search_engines_list.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/search_engines_page/search_engines_list.m.js" ]
deps = [
# TODO: Fill those in.
":search_engines_browser_proxy.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
extra_deps = [ ":search_engines_list_module" ]
}
......@@ -131,15 +147,19 @@ js_library("search_engines_list.m") {
js_library("search_engines_page.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/search_engines_page/search_engines_page.m.js" ]
deps = [
# TODO: Fill those in.
":search_engines_browser_proxy.m",
"..:global_scroll_target_behavior.m",
"..:settings_routes.m",
"//third_party/polymer/v3_0/components-chromium/iron-list",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:web_ui_listener_behavior.m",
]
extra_deps = [ ":search_engines_page_module" ]
}
import("//tools/polymer/polymer.gni")
group("polymer3_elements") {
deps = [
public_deps = [
":modulize",
":omnibox_extension_entry_module",
":search_engine_dialog_module",
......@@ -154,18 +174,32 @@ polymer_modulizer("omnibox_extension_entry") {
js_file = "omnibox_extension_entry.js"
html_file = "omnibox_extension_entry.html"
html_type = "dom-module"
namespace_rewrites = settings_namespace_rewrites
auto_imports = settings_auto_imports + [
"chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.html|SearchEngine",
"ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.html|AnchorAlignment",
"ui/webui/resources/html/assert.html|assert",
]
}
polymer_modulizer("search_engine_dialog") {
js_file = "search_engine_dialog.js"
html_file = "search_engine_dialog.html"
html_type = "dom-module"
namespace_rewrites = settings_namespace_rewrites
auto_imports = settings_auto_imports + [ "chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.html|SearchEnginesBrowserProxyImpl,SearchEnginesBrowserProxy,SearchEngine,SearchEnginesInfo" ]
}
polymer_modulizer("search_engine_entry") {
js_file = "search_engine_entry.js"
html_file = "search_engine_entry.html"
html_type = "dom-module"
namespace_rewrites = settings_namespace_rewrites
auto_imports = settings_auto_imports + [
"chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.html|SearchEnginesBrowserProxyImpl,SearchEnginesBrowserProxy,SearchEngine",
"ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.html|AnchorAlignment",
"ui/webui/resources/html/assert.html|assert",
]
}
polymer_modulizer("search_engine_entry_css") {
......@@ -178,16 +212,24 @@ polymer_modulizer("search_engines_list") {
js_file = "search_engines_list.js"
html_file = "search_engines_list.html"
html_type = "dom-module"
auto_imports = [ "chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.html|SearchEngine" ]
}
polymer_modulizer("search_engines_page") {
js_file = "search_engines_page.js"
html_file = "search_engines_page.html"
html_type = "dom-module"
namespace_rewrites =
settings_namespace_rewrites + [ "settings.routes|routes" ]
auto_imports = settings_auto_imports + [
"chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.html|SearchEnginesBrowserProxyImpl,SearchEngine,SearchEnginesInfo",
"chrome/browser/resources/settings/route.html|routes",
"ui/webui/resources/html/assert.html|assert",
"ui/webui/resources/html/polymer.html|afterNextRender,html,Polymer",
]
}
import("//ui/webui/resources/tools/js_modulizer.gni")
js_modulizer("modulize") {
input_files = [ "search_engines_browser_proxy.js" ]
namespace_rewrites = settings_namespace_rewrites
}
......@@ -3,9 +3,11 @@
<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html">
<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_row_behavior.html">
<link rel="import" href="../extension_control_browser_proxy.html">
<link rel="import" href="search_engine_entry_css.html">
<link rel="import" href="search_engines_browser_proxy.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="../site_favicon.html">
......
......@@ -105,7 +105,7 @@ Polymer({
/** @private */
cancel_() {
this.$.dialog.cancel();
/** @type {!CrDialogElement} */ (this.$.dialog).cancel();
},
/** @private */
......
......@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js';
// clang-format on
/**
* @fileoverview A helper object used from the "Manage search engines" section
* to interact with the browser.
......@@ -27,7 +31,7 @@
* urlLocked: boolean}}
* @see chrome/browser/ui/webui/settings/search_engine_manager_handler.cc
*/
let SearchEngine;
/* #export */ let SearchEngine;
/**
* @typedef {{
......@@ -36,11 +40,11 @@ let SearchEngine;
* extensions: !Array<!SearchEngine>
* }}
*/
let SearchEnginesInfo;
/* #export */ let SearchEnginesInfo;
cr.define('settings', function() {
/** @interface */
class SearchEnginesBrowserProxy {
/* #export */ class SearchEnginesBrowserProxy {
/** @param {number} modelIndex */
setDefaultSearchEngine(modelIndex) {}
......@@ -73,7 +77,7 @@ cr.define('settings', function() {
/**
* @implements {settings.SearchEnginesBrowserProxy}
*/
class SearchEnginesBrowserProxyImpl {
/* #export */ class SearchEnginesBrowserProxyImpl {
/** @override */
setDefaultSearchEngine(modelIndex) {
chrome.send('setDefaultSearchEngine', [modelIndex]);
......
......@@ -5,6 +5,7 @@
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="../settings_vars_css.html">
<link rel="import" href="search_engine_entry.html">
<link rel="import" href="search_engines_browser_proxy.html">
<dom-module id="settings-search-engines-list">
<template>
......
......@@ -141,7 +141,7 @@ Polymer({
/** @private */
extensionsChanged_() {
if (this.showExtensionsList_ && this.$.extensions) {
this.$.extensions.notifyResize();
/** @type {!IronListElement} */ (this.$.extensions).notifyResize();
}
},
......@@ -166,7 +166,8 @@ Polymer({
*/
onAddSearchEngineTap_(e) {
e.preventDefault();
this.openDialog_(null, assert(this.$.addSearchEngine));
this.openDialog_(
null, assert(/** @type {HTMLElement} */ (this.$.addSearchEngine)));
},
/** @private */
......
......@@ -15,6 +15,8 @@ settings_namespace_rewrites = [
"settings.Route|Route",
"settings.SearchEnginesBrowserProxy|SearchEnginesBrowserProxy",
"action_link.m.js|action_link.js",
# TODO(1026426): Add more entries above as needed.
]
......
......@@ -12,5 +12,11 @@ import './controls/settings_textarea.m.js';
import './controls/settings_toggle_button.m.js';
import './site_favicon.m.js';
import './search_engines_page/omnibox_extension_entry.m.js';
import './search_engines_page/search_engine_dialog.m.js';
import './search_engines_page/search_engine_entry.m.js';
import './search_engines_page/search_engines_page.m.js';
export {ExtensionControlBrowserProxyImpl} from './extension_control_browser_proxy.m.js';
export {prefToString, stringToPrefValue} from './prefs/pref_util.m.js';
export {SearchEnginesBrowserProxyImpl} from './search_engines_page/search_engines_browser_proxy.m.js';
......@@ -109,4 +109,33 @@
file="${root_gen_dir}/chrome/browser/resources/settings/site_favicon.m.js"
use_base_dir="false"
type="BINDATA" />
<include name="IDR_SETTINGS_SEARCH_ENGINES_BROWSER_PROXY_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.m.js"
use_base_dir="false"
type="BINDATA"
preprocess="true" />
<include name="IDR_SETTINGS_SEARCH_ENGINES_PAGE_OMNIBOX_EXTENSION_ENTRY_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/search_engines_page/omnibox_extension_entry.m.js"
use_base_dir="false"
type="BINDATA" />
<include name="IDR_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINE_DIALOG_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/search_engines_page/search_engine_dialog.m.js"
use_base_dir="false"
type="BINDATA" />
<include name="IDR_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINE_ENTRY_CSS_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/search_engines_page/search_engine_entry_css.m.js"
use_base_dir="false"
type="BINDATA" />
<include name="IDR_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINE_ENTRY_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/search_engines_page/search_engine_entry.m.js"
use_base_dir="false"
type="BINDATA" />
<include name="IDR_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINES_LIST_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/search_engines_page/search_engines_list.m.js"
use_base_dir="false"
type="BINDATA" />
<include name="IDR_SETTINGS_SEARCH_ENGINES_PAGE_SEARCH_ENGINES_PAGE_M_JS"
file="${root_gen_dir}/chrome/browser/resources/settings/search_engines_page/search_engines_page.m.js"
use_base_dir="false"
type="BINDATA" />
</grit-part>
......@@ -212,11 +212,13 @@ js2gtest("browser_tests_js_webui") {
"$root_gen_dir/chrome/test/data/webui/settings/dropdown_menu_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/extension_controlled_indicator_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/pref_util_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/search_engines_page_test.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/settings_slider_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/settings_textarea_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/settings_toggle_button_tests.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/site_favicon_test.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/test_extension_control_browser_proxy.m.js",
"$root_gen_dir/chrome/test/data/webui/settings/test_search_engines_browser_proxy.m.js",
"$root_gen_dir/chrome/test/data/webui/test_browser_proxy.m.js",
"$root_gen_dir/chrome/test/data/webui/test_store.m.js",
"$root_gen_dir/chrome/test/data/webui/test_util.m.js",
......
......@@ -12,11 +12,13 @@ js_modulizer("modulize") {
"dropdown_menu_tests.js",
"extension_controlled_indicator_tests.js",
"pref_util_tests.js",
"search_engines_page_test.js",
"site_favicon_test.js",
"settings_slider_tests.js",
"settings_textarea_tests.js",
"settings_toggle_button_tests.js",
"test_extension_control_browser_proxy.js",
"test_search_engines_browser_proxy.js",
]
namespace_rewrites = [
"settings.ExtensionControlBrowserProxyImpl|ExtensionControlBrowserProxyImpl",
......@@ -27,5 +29,7 @@ js_modulizer("modulize") {
"Settings.PrefUtil.prefToString|prefToString",
"global.traceAssertionsForTesting|window.traceAssertionsForTesting",
"Settings.PrefUtil.stringToPrefValue|stringToPrefValue",
"settings_search.TestSearchEnginesBrowserProxy|TestSearchEnginesBrowserProxy",
"settings.SearchEnginesBrowserProxyImpl|SearchEnginesBrowserProxyImpl",
]
}
......@@ -144,3 +144,15 @@ var CrSettingsToggleButtonV3Test = class extends CrSettingsV3BrowserTest {
TEST_F('CrSettingsToggleButtonV3Test', 'All', function() {
mocha.run();
});
// eslint-disable-next-line no-var
var CrSettingsSearchEnginesV3Test = class extends CrSettingsV3BrowserTest {
/** @override */
get browsePreload() {
return 'chrome://settings/test_loader.html?module=settings/search_engines_page_test.m.js';
}
};
TEST_F('CrSettingsSearchEnginesV3Test', 'All', function() {
mocha.run();
});
......@@ -2,6 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// #import {eventToPromise} from 'chrome://test/test_util.m.js';
// #import {ExtensionControlBrowserProxyImpl} from 'chrome://settings/settings.js';
// #import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {SearchEnginesBrowserProxyImpl} from 'chrome://settings/settings.js';
// #import {TestExtensionControlBrowserProxy} from 'chrome://test/settings/test_extension_control_browser_proxy.m.js';
// #import {TestSearchEnginesBrowserProxy} from 'chrome://test/settings/test_search_engines_browser_proxy.m.js';
// clang-format on
/**
* @param {number} id
* @param {string} name
......
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// #import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js';
cr.define('settings_search', function() {
/**
* A test version of SearchEnginesBrowserProxy. Provides helper methods
......@@ -10,7 +12,7 @@ cr.define('settings_search', function() {
*
* @implements {settings.SearchEnginesBrowserProxy}
*/
class TestSearchEnginesBrowserProxy extends TestBrowserProxy {
/* #export */ class TestSearchEnginesBrowserProxy extends TestBrowserProxy {
constructor() {
super([
'getSearchEnginesList',
......@@ -95,6 +97,7 @@ cr.define('settings_search', function() {
};
}
// #cr_define_end
return {
createSampleSearchEngine: createSampleSearchEngine,
TestSearchEnginesBrowserProxy: TestSearchEnginesBrowserProxy,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment