summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Apacible <apacible@google.com>2016-03-21 10:59:36 -0700
committerJennifer Apacible <apacible@google.com>2016-03-21 18:01:55 +0000
commit32ccd64cce0c370052e2ef1ba2d4421a73de2f56 (patch)
treecaf5221ba9117790846d636b67bf376358bb1264
parent0a7d7379015541ad6356f2cb4d90be4614ca3135 (diff)
downloadchromium_src-32ccd64cce0c370052e2ef1ba2d4421a73de2f56.zip
chromium_src-32ccd64cce0c370052e2ef1ba2d4421a73de2f56.tar.gz
chromium_src-32ccd64cce0c370052e2ef1ba2d4421a73de2f56.tar.bz2
[Media Router] Disable focus if not triggered by user.
In some cases such as page load, an unexpected focus event is triggered separately from any user input (e.g. tab or click). Disable this without disabling focus in general; focus is still needed for accessibility reasons. BUG=593221 Review URL: https://codereview.chromium.org/1799303002 Cr-Commit-Position: refs/heads/master@{#381130} (cherry picked from commit 280874bcce6eaa1b31d65fcdbe7f31bdfe191434) Review URL: https://codereview.chromium.org/1821733002 . Cr-Commit-Position: refs/branch-heads/2661@{#318} Cr-Branched-From: ef6f6ae5e4c96622286b563658d5cd62a6cf1197-refs/heads/master@{#378081}
-rw-r--r--chrome/browser/resources/media_router/elements/media_router_header/media_router_header.html2
-rw-r--r--chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js42
-rw-r--r--chrome/browser/resources/media_router/externs.js6
3 files changed, 37 insertions, 13 deletions
diff --git a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.html b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.html
index cb892af..d3e5a9a 100644
--- a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.html
+++ b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.html
@@ -13,7 +13,7 @@
</paper-icon-button>
</div>
<div id="header-and-arrow-container" on-click="onHeaderOrArrowClick_">
- <span id="header-text" title="[[tooltip]]">
+ <span id="header-text" title="[[tooltip]]" tabindex="0">
[[headingText]]</span>
<div id="arrow-drop-container">
<paper-icon-button icon="[[computeArrowDropIcon_(view)]]"
diff --git a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
index 36eb363..9c712c6 100644
--- a/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
+++ b/chrome/browser/resources/media_router/elements/media_router_header/media_router_header.js
@@ -84,6 +84,10 @@ Polymer({
},
},
+ listeners: {
+ 'focus': 'onFocus_',
+ },
+
attached: function() {
// isRTL() only works after i18n_template.js runs to set <html dir>.
// Set the back button icon based on text direction.
@@ -132,18 +136,6 @@ Polymer({
},
/**
- * Handles a click on the arrow button by firing an arrow-click event.
- *
- * @private
- */
- onHeaderOrArrowClick_: function() {
- if (this.view == media_router.MediaRouterView.SINK_LIST ||
- this.view == media_router.MediaRouterView.CAST_MODE_LIST) {
- this.fire('header-or-arrow-click');
- }
- },
-
- /**
* Handles a click on the back button by firing a back-click event.
*
* @private
@@ -162,6 +154,32 @@ Polymer({
},
/**
+ * Called when a focus event is triggered.
+ *
+ * @param {!Event} event The event object.
+ * @private
+ */
+ onFocus_: function(event) {
+ // If the focus event was not triggered by the user, remove focus from
+ // the element. This prevents unexpected focusing such as when the dialog
+ // is initially loaded.
+ if (!event.sourceCapabilities)
+ event.path[0].blur();
+ },
+
+ /**
+ * Handles a click on the arrow button by firing an arrow-click event.
+ *
+ * @private
+ */
+ onHeaderOrArrowClick_: function() {
+ if (this.view == media_router.MediaRouterView.SINK_LIST ||
+ this.view == media_router.MediaRouterView.CAST_MODE_LIST) {
+ this.fire('header-or-arrow-click');
+ }
+ },
+
+ /**
* Updates header height to accomodate email text. This is called on changes
* to |showEmail| and will return early if the value has not changed.
*
diff --git a/chrome/browser/resources/media_router/externs.js b/chrome/browser/resources/media_router/externs.js
index 5821b32..c81db5b 100644
--- a/chrome/browser/resources/media_router/externs.js
+++ b/chrome/browser/resources/media_router/externs.js
@@ -13,3 +13,9 @@ var performance = {};
* @return {number}
*/
performance.now = function() {};
+
+/** @interface */
+var InputDeviceCapabilities;
+
+/** @type {?InputDeviceCapabilities} */
+Event.prototype.sourceCapabilities;