Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: chrome/browser/resources/settings/internet_page/internet_page.js

Issue 2841873004: MD Settings: Fix subpage navigation focus for bluetooth+internet (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/internet_page/internet_page.js
diff --git a/chrome/browser/resources/settings/internet_page/internet_page.js b/chrome/browser/resources/settings/internet_page/internet_page.js
index c25245484617256fb38619566fc80f6d8eba2962..1b13a2cc79b8fee76ce19723065a52fe04db78e9 100644
--- a/chrome/browser/resources/settings/internet_page/internet_page.js
+++ b/chrome/browser/resources/settings/internet_page/internet_page.js
@@ -88,8 +88,22 @@ Polymer({
return [];
}
},
+
+ /**
+ * @type {!Map<string, string>}
dpapad 2017/04/25 21:25:19 Ni: Use shorthand syntax, @private {!Map<string, s
stevenjb 2017/04/25 23:32:53 Done.
+ * @private
+ */
+ focusConfig_: {
+ type: Object,
+ value: function() {
+ return new Map();
+ },
+ },
},
+ /** @private {string} Type of last detail page visited. */
+ detailType_: '',
+
// Element event listeners
listeners: {
'device-enabled-toggled': 'onDeviceEnabledToggled_',
@@ -110,13 +124,13 @@ Polymer({
/** @override */
attached: function() {
- this.onExtensionAddedListener_ = this.onExtensionAddedListener_ ||
- this.onExtensionAdded_.bind(this);
+ this.onExtensionAddedListener_ =
+ this.onExtensionAddedListener_ || this.onExtensionAdded_.bind(this);
chrome.management.onInstalled.addListener(this.onExtensionAddedListener_);
chrome.management.onEnabled.addListener(this.onExtensionAddedListener_);
- this.onExtensionRemovedListener_ = this.onExtensionRemovedListener_ ||
- this.onExtensionRemoved_.bind(this);
+ this.onExtensionRemovedListener_ =
+ this.onExtensionRemovedListener_ || this.onExtensionRemoved_.bind(this);
chrome.management.onUninstalled.addListener(
this.onExtensionRemovedListener_);
@@ -146,9 +160,10 @@ Polymer({
/**
* settings.RouteObserverBehavior
* @param {!settings.Route} route
+ * @param {!settings.Route} oldRoute
* @protected
*/
- currentRouteChanged: function(route) {
+ currentRouteChanged: function(route, oldRoute) {
if (route == settings.Route.INTERNET_NETWORKS) {
// Handle direct navigation to the networks page,
// e.g. chrome://settings/internet/networks?type=WiFi
@@ -163,6 +178,27 @@ Polymer({
var type = queryParams.get('type');
if (type)
this.knownNetworksType_ = type;
+ } else if (route != settings.Route.INTERNET && route.path != '/') {
dpapad 2017/04/25 21:25:19 Is this equivalent to the following? } else if (r
stevenjb 2017/04/25 23:32:53 Looks like it. Done.
+ // If we are navigating to a non internet section, do not set focus.
+ return;
+ }
+
+ // Focus the subpage arrow where appropriate.
+ if (oldRoute == settings.Route.NETWORK_DETAIL ||
dpapad 2017/04/25 21:25:19 Is this equivalent to the following? if (!setting
stevenjb 2017/04/25 23:32:53 Handy. Yes. Done.
+ oldRoute == settings.Route.INTERNET_NETWORKS ||
+ oldRoute == settings.Route.KNOWN_NETWORKS) {
+ var selector;
+ if (route == settings.Route.INTERNET_NETWORKS) {
dpapad 2017/04/25 21:25:19 Nit (optional): This can be compacted as follows:
stevenjb 2017/04/25 23:32:53 Acknowledged.
+ // iron-list makes the correct timing to focus an item in the list
+ // very complicated, and the item may not exist, so just focus the
+ // entire list for now.
+ selector = '* /deep/ #networkList';
+ } else if (this.detailType_) {
+ selector = '* /deep/ #' + this.detailType_ + ' /deep/ .subpage-arrow';
+ }
+ if (selector && this.querySelector(selector))
dpapad 2017/04/25 21:25:19 When would querySelector(selector) return nothing
stevenjb 2017/04/25 23:32:53 If an Ethernet cable were unplugged while visiting
+ this.focusConfig_.set(oldRoute.path, selector);
dpapad 2017/04/25 21:25:19 I don't fully understand the updates to the focusC
stevenjb 2017/04/25 23:32:53 Done. (I took this approach because of the dynami
+ this.detailType_ = '';
}
},
@@ -184,6 +220,7 @@ Polymer({
* @private
*/
onShowDetail_: function(event) {
+ this.detailType_ = event.detail.Type;
var params = new URLSearchParams;
params.append('guid', event.detail.GUID);
params.append('type', event.detail.Type);
@@ -197,6 +234,7 @@ Polymer({
* @private
*/
onShowNetworks_: function(event) {
+ this.detailType_ = event.detail.Type;
var params = new URLSearchParams;
params.append('type', event.detail.Type);
this.subpageType_ = event.detail.Type;
@@ -216,6 +254,7 @@ Polymer({
* @private
*/
onShowKnownNetworks_: function(event) {
+ this.detailType_ = event.detail.Type;
var params = new URLSearchParams;
params.append('type', event.detail.Type);
this.knownNetworksType_ = event.detail.type;
@@ -329,8 +368,8 @@ Polymer({
* @private
*/
deviceIsEnabled_: function(deviceState) {
- return !!deviceState && deviceState.State ==
- chrome.networkingPrivate.DeviceStateType.ENABLED;
+ return !!deviceState &&
+ deviceState.State == chrome.networkingPrivate.DeviceStateType.ENABLED;
},
/**

Powered by Google App Engine
This is Rietveld 408576698