Commit c05fe5f1 authored by Nnamdi Theodore Johnson-Kanu's avatar Nnamdi Theodore Johnson-Kanu Committed by Commit Bot

[CrOS settings] Fix polymer_modulizer for os_settings_ui/

This CL is in preparation for enabling Polymer3 in ChromeOS settings
pages. It fixed issues in os_settings_ui/ folder that break
semi-automatic Polymer3 migration. These changes include adding missing
#cr_define_end comments to JS file which were missing them, as well as
making sure that files which use cr.define() include the entire file's
content within the cr.define() call, since this is required by Polymer3
conversion tools.

Bug: 1045266
Change-Id: Iaf3379cc76c4eab1efff139dd5d7542adf5f2293
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2153338Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Nnamdi Theodore Johnson-kanu <tjohnsonkanu@google.com>
Cr-Commit-Position: refs/heads/master@{#760256}
parent b724b870
......@@ -34,26 +34,25 @@ js_library("os_settings_ui") {
# ]
#}
# TODO: Fix and re-enable
#js_library("os_settings_ui.m") {
# sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_settings_ui/os_settings_ui.m.js" ]
# deps = [
# # TODO: Fill those in.
# ]
# extra_deps = [ ":os_settings_ui_module" ]
#}
js_library("os_settings_ui.m") {
sources = [ "$root_gen_dir/chrome/browser/resources/settings/chromeos/os_settings_ui/os_settings_ui.m.js" ]
deps = [
# TODO: Fill those in.
]
extra_deps = [ ":os_settings_ui_module" ]
}
import("//tools/polymer/polymer.gni")
group("polymer3_elements") {
public_deps = [
# TODO: Fix and re-enable
#":os_settings_ui_module"
":os_settings_ui_module",
]
}
# TODO: Fix and re-enable
#polymer_modulizer("os_settings_ui") {
# js_file = "os_settings_ui.js"
# html_file = "os_settings_ui.html"
# html_type = "dom-module"
#}
polymer_modulizer("os_settings_ui") {
js_file = "os_settings_ui.js"
html_file = "os_settings_ui.html"
html_type = "dom-module"
}
......@@ -18,17 +18,15 @@ cr.define('settings', function() {
!window.settings || !settings.defaultResourceLoaded,
'settings_ui.js run twice. You probably have an invalid import.');
return {defaultResourceLoaded};
});
Polymer({
Polymer({
is: 'os-settings-ui',
behaviors: [
CrContainerShadowBehavior,
FindShortcutBehavior,
// Calls currentRouteChanged() in attached(), so ensure other behaviors run
// their attached() first.
// Calls currentRouteChanged() in attached(), so ensure other behaviors
// run their attached() first.
settings.RouteObserverBehavior,
],
......@@ -61,8 +59,8 @@ Polymer({
},
/**
* Whether settings is in the narrow state (side nav hidden). Controlled by
* a binding in the os-toolbar element.
* Whether settings is in the narrow state (side nav hidden). Controlled
* by a binding in the os-toolbar element.
*/
isNarrow: {
type: Boolean,
......@@ -102,8 +100,8 @@ Polymer({
},
/**
* The route of the selected element in os-settings-menu. Stored here to defer
* navigation until drawer animation completes.
* The route of the selected element in os-settings-menu. Stored here to
* defer navigation until drawer animation completes.
* @private {settings.Route}
*/
activeRoute_: null,
......@@ -115,8 +113,8 @@ Polymer({
/**
* @override
* @suppress {es5Strict} Object literals cannot contain duplicate keys in ES5
* strict mode.
* @suppress {es5Strict} Object literals cannot contain duplicate keys in
* ES5 strict mode.
*/
ready() {
// Lazy-create the drawer the first time it is opened or swiped into view.
......@@ -241,13 +239,14 @@ Polymer({
}
if (loadTimeData.getBoolean('newOsSettingsSearch')) {
// TODO(crbug/1056909): Remove when new os settings search complete. This
// block prevents the old settings search code from being executed.
// TODO(crbug/1056909): Remove when new os settings search complete.
// This block prevents the old settings search code from being executed.
return;
}
const urlSearchQuery =
settings.Router.getInstance().getQueryParameters().get('search') || '';
settings.Router.getInstance().getQueryParameters().get('search') ||
'';
if (urlSearchQuery == this.lastSearchQuery_) {
return;
}
......@@ -256,14 +255,16 @@ Polymer({
const toolbar = /** @type {!OsToolbarElement} */ (this.$$('os-toolbar'));
const searchField =
/** @type {?CrToolbarSearchFieldElement} */ (toolbar.getSearchField());
/** @type {?CrToolbarSearchFieldElement} */ (
toolbar.getSearchField());
if (!searchField) {
// TODO(crbug/1056909): Remove this and surrounding code when new os
// settings search complete. If the search field has not been rendered
// yet, do not continue. crbug/1056909 changes the toolbar search field to
// an optional value, so the element is not attached to the DOM the first
// time this runs when the new OS Settings search flag is not flipped on.
// yet, do not continue. crbug/1056909 changes the toolbar search field
// to an optional value, so the element is not attached to the DOM the
// first time this runs when the new OS Settings search flag is not
// flipped on.
return;
}
......@@ -298,7 +299,8 @@ Polymer({
* @private
*/
onRefreshPref_(e) {
return /** @type {SettingsPrefsElement} */ (this.$.prefs).refresh(e.detail);
return /** @type {SettingsPrefsElement} */ (this.$.prefs)
.refresh(e.detail);
},
/**
......@@ -340,8 +342,8 @@ Polymer({
this.activeRoute_ = route;
if (this.isNarrow) {
// If the onIronActivate event came from the drawer, close the drawer and
// wait for the menu to close before navigating to |activeRoute_|.
// If the onIronActivate event came from the drawer, close the drawer
// and wait for the menu to close before navigating to |activeRoute_|.
this.$.drawer.close();
return;
}
......@@ -362,23 +364,26 @@ Polymer({
navigateToActiveRoute_() {
if (this.activeRoute_) {
settings.Router.getInstance().navigateTo(
this.activeRoute_, /* dynamicParams */ null, /* removeSearch */ true);
this.activeRoute_, /* dynamicParams */ null,
/* removeSearch */ true);
this.activeRoute_ = null;
}
},
/**
* When this is called, The drawer animation is finished, and the dialog no
* longer has focus. The selected section will gain focus if one was selected.
* Otherwise, the drawer was closed due being canceled, and the main settings
* container is given focus. That way the arrow keys can be used to scroll
* the container, and pressing tab focuses a component in settings.
* longer has focus. The selected section will gain focus if one was
* selected. Otherwise, the drawer was closed due being canceled, and the
* main settings container is given focus. That way the arrow keys can be
* used to scroll the container, and pressing tab focuses a component in
* settings.
* @private
*/
onMenuClose_() {
if (!this.$.drawer.wasCanceled()) {
// If a navigation happened, MainPageBehavior#currentRouteChanged handles
// focusing the corresponding section when we call settings.NavigateTo().
// If a navigation happened, MainPageBehavior#currentRouteChanged
// handles focusing the corresponding section when we call
// settings.NavigateTo().
this.navigateToActiveRoute_();
return;
}
......@@ -414,4 +419,8 @@ Polymer({
this.$.drawer.close();
}
},
});
// #cr_define_end
return {defaultResourceLoaded};
});
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