Commit 6f5787dc authored by rbpotter's avatar rbpotter Committed by Commit Bot

Settings Polymer 3: Add closure compiler targets for settings_page/*

Add Polymer 3 closure compiler targets for the files in settings_page/.

Bug: 1026426
Change-Id: Ia672c0edbf05ef8779dcde296bcd704ff4c7b427
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036524
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738480}
parent 0852e093
...@@ -214,6 +214,7 @@ group("closure_compile_module") { ...@@ -214,6 +214,7 @@ group("closure_compile_module") {
"controls:closure_compile_module", "controls:closure_compile_module",
"prefs:closure_compile_module", "prefs:closure_compile_module",
"search_engines_page:closure_compile_module", "search_engines_page:closure_compile_module",
"settings_page:closure_compile_module",
] ]
} }
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni") 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") { js_type_check("closure_compile") {
deps = [ deps = [
...@@ -49,21 +52,25 @@ js_library("settings_subpage") { ...@@ -49,21 +52,25 @@ js_library("settings_subpage") {
] ]
} }
# TODO(crbug.com/1026426): Fix and enable. js_type_check("closure_compile_module") {
#js_type_check("closure_compile_module") { is_polymer3 = true
# is_polymer3 = true deps = [
# deps = [ ":main_page_behavior.m",
# ":main_page_behavior.m", ":settings_animated_pages.m",
# ":settings_animated_pages.m", ":settings_section.m",
# ":settings_section.m", ":settings_subpage.m",
# ":settings_subpage.m", ]
# ] }
#}
js_library("main_page_behavior.m") { js_library("main_page_behavior.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/settings_page/main_page_behavior.m.js" ] sources = [ "$root_gen_dir/chrome/browser/resources/settings/settings_page/main_page_behavior.m.js" ]
deps = [ deps = [
# TODO: Fill those in. ":settings_section.m",
"..:router.m",
"..:settings_routes.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:util.m",
] ]
extra_deps = [ ":modulize" ] extra_deps = [ ":modulize" ]
} }
...@@ -71,7 +78,11 @@ js_library("main_page_behavior.m") { ...@@ -71,7 +78,11 @@ js_library("main_page_behavior.m") {
js_library("settings_animated_pages.m") { js_library("settings_animated_pages.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/settings_page/settings_animated_pages.m.js" ] sources = [ "$root_gen_dir/chrome/browser/resources/settings/settings_page/settings_animated_pages.m.js" ]
deps = [ deps = [
# TODO: Fill those in. ":settings_subpage.m",
"..:router.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js/cr/ui:focus_without_ink.m",
] ]
extra_deps = [ ":settings_animated_pages_module" ] extra_deps = [ ":settings_animated_pages_module" ]
} }
...@@ -79,7 +90,7 @@ js_library("settings_animated_pages.m") { ...@@ -79,7 +90,7 @@ js_library("settings_animated_pages.m") {
js_library("settings_section.m") { js_library("settings_section.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/settings_page/settings_section.m.js" ] sources = [ "$root_gen_dir/chrome/browser/resources/settings/settings_page/settings_section.m.js" ]
deps = [ deps = [
# TODO: Fill those in. "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
] ]
extra_deps = [ ":settings_section_module" ] extra_deps = [ ":settings_section_module" ]
} }
...@@ -87,7 +98,14 @@ js_library("settings_section.m") { ...@@ -87,7 +98,14 @@ js_library("settings_section.m") {
js_library("settings_subpage.m") { js_library("settings_subpage.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/settings_page/settings_subpage.m.js" ] sources = [ "$root_gen_dir/chrome/browser/resources/settings/settings_page/settings_subpage.m.js" ]
deps = [ deps = [
# TODO: Fill those in. "..:router.m",
"//third_party/polymer/v3_0/components-chromium/iron-resizable-behavior:iron-resizable-behavior",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_search_field:cr_search_field.m",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:find_shortcut_behavior.m",
"//ui/webui/resources/js:load_time_data.m",
"//ui/webui/resources/js/cr/ui:focus_without_ink.m",
] ]
extra_deps = [ ":settings_subpage_module" ] extra_deps = [ ":settings_subpage_module" ]
} }
...@@ -107,6 +125,15 @@ polymer_modulizer("settings_animated_pages") { ...@@ -107,6 +125,15 @@ polymer_modulizer("settings_animated_pages") {
js_file = "settings_animated_pages.js" js_file = "settings_animated_pages.js"
html_file = "settings_animated_pages.html" html_file = "settings_animated_pages.html"
html_type = "dom-module" html_type = "dom-module"
auto_imports = [
"chrome/browser/resources/settings/router.html|Route, Router, RouteObserverBehavior",
"ui/webui/resources/html/assert.html|assert",
"ui/webui/resources/html/polymer.html|afterNextRender, dom, DomIf, html, Polymer",
]
namespace_rewrites = settings_namespace_rewrites + [
"Polymer.dom|dom",
"Polymer.DomIf|DomIf",
]
} }
polymer_modulizer("settings_section") { polymer_modulizer("settings_section") {
...@@ -119,10 +146,20 @@ polymer_modulizer("settings_subpage") { ...@@ -119,10 +146,20 @@ polymer_modulizer("settings_subpage") {
js_file = "settings_subpage.js" js_file = "settings_subpage.js"
html_file = "settings_subpage.html" html_file = "settings_subpage.html"
html_type = "dom-module" html_type = "dom-module"
auto_imports = settings_auto_imports + [
"chrome/browser/resources/settings/router.html|RouteObserverBehavior,Router",
"third_party/polymer/v1_0/components-chromium/iron-resizable-behavior/iron-resizable-behavior.html|IronResizableBehavior",
"ui/webui/resources/html/assert.html|assert",
"ui/webui/resources/html/find_shortcut_behavior.html|FindShortcutBehavior",
"ui/webui/resources/html/polymer.html|html, Polymer, afterNextRender",
]
namespace_rewrites = settings_namespace_rewrites +
[ "Polymer.IronResizableBehavior|IronResizableBehavior" ]
} }
import("//ui/webui/resources/tools/js_modulizer.gni") import("//ui/webui/resources/tools/js_modulizer.gni")
js_modulizer("modulize") { js_modulizer("modulize") {
input_files = [ "main_page_behavior.js" ] input_files = [ "main_page_behavior.js" ]
namespace_rewrites = settings_namespace_rewrites
} }
...@@ -2,13 +2,20 @@ ...@@ -2,13 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// clang-format off
// #import {assert} from 'chrome://resources/js/assert.m.js';
// #import {beforeNextRender} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
// #import {Route, Router} from '../router.m.js';
// #import {SettingsRoutes} from '../settings_routes.m.js';
// clang-format on
cr.define('settings', function() { cr.define('settings', function() {
/** /**
* @enum {string} * @enum {string}
* A categorization of every possible Settings URL, necessary for implementing * A categorization of every possible Settings URL, necessary for implementing
* a finite state machine. * a finite state machine.
*/ */
const RouteState = { /* #export */ const RouteState = {
// Initial state before anything has loaded yet. // Initial state before anything has loaded yet.
INITIAL: 'initial', INITIAL: 'initial',
// A dialog that has a dedicated URL (e.g. /importData). // A dialog that has a dedicated URL (e.g. /importData).
...@@ -50,7 +57,7 @@ cr.define('settings', function() { ...@@ -50,7 +57,7 @@ cr.define('settings', function() {
* container. At most one section should be expanded at any given time. * container. At most one section should be expanded at any given time.
* @polymerBehavior * @polymerBehavior
*/ */
const MainPageBehavior = { /* #export */ const MainPageBehavior = {
properties: { properties: {
/** /**
* Whether a search operation is in progress or previous search results * Whether a search operation is in progress or previous search results
...@@ -138,13 +145,15 @@ cr.define('settings', function() { ...@@ -138,13 +145,15 @@ cr.define('settings', function() {
* @private * @private
*/ */
shouldExpandAdvanced_(route) { shouldExpandAdvanced_(route) {
const routes = /** @type {!SettingsRoutes} */ (
settings.Router.getInstance().getRoutes());
return ( return (
this.tagName == 'SETTINGS-BASIC-PAGE' this.tagName == 'SETTINGS-BASIC-PAGE'
// <if expr="chromeos"> // <if expr="chromeos">
|| this.tagName == 'OS-SETTINGS-PAGE' || this.tagName == 'OS-SETTINGS-PAGE'
// </if> // </if>
) && ) &&
settings.routes.ADVANCED && settings.routes.ADVANCED.contains(route); routes.ADVANCED && routes.ADVANCED.contains(route);
}, },
/** /**
...@@ -197,9 +206,12 @@ cr.define('settings', function() { ...@@ -197,9 +206,12 @@ cr.define('settings', function() {
// TODO(dpapad): On chrome://os-settings the lazy_load.html file resides // TODO(dpapad): On chrome://os-settings the lazy_load.html file resides
// at a different path. Remove conditional logic once this file is not // at a different path. Remove conditional logic once this file is not
// shared between chrome://settings and chrome://os-settings. // shared between chrome://settings and chrome://os-settings.
// TODO(rbpotter): Fix this to work correctly in Polymer 3, instead of
// just removing the importHref lines.
const lazyLoadPathPrefix = const lazyLoadPathPrefix =
window.origin === 'chrome://settings' ? '' : '/chromeos'; window.origin === 'chrome://settings' ? '' : '/chromeos';
Polymer.importHref(`${lazyLoadPathPrefix}/lazy_load.html`, () => {}); /* #ignore */ Polymer.importHref(
/* #ignore */ `${lazyLoadPathPrefix}/lazy_load.html`, () => {});
this.ensureSectionForRoute_(route).then(section => { this.ensureSectionForRoute_(route).then(section => {
section.classList.add('expanded'); section.classList.add('expanded');
......
...@@ -171,7 +171,13 @@ Polymer({ ...@@ -171,7 +171,13 @@ Polymer({
} }
// Set the subpage's id for use by neon-animated-pages. // Set the subpage's id for use by neon-animated-pages.
const content = Polymer.DomIf._contentForTemplate( const content =
/**
@type {!{_contentForTemplate:
function(!HTMLTemplateElement):!HTMLElement}}
*/
(Polymer.DomIf)
._contentForTemplate(
/** @type {!HTMLTemplateElement} */ (domIf.firstElementChild)); /** @type {!HTMLTemplateElement} */ (domIf.firstElementChild));
const subpage = content.querySelector('settings-subpage'); const subpage = content.querySelector('settings-subpage');
subpage.setAttribute('route-path', routePath); subpage.setAttribute('route-path', routePath);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
*/ */
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
let SettingsSectionElement = Polymer({ Polymer({
is: 'settings-section', is: 'settings-section',
properties: { properties: {
......
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