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