Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| index f9768fa3c9c2e5c973541a25bc1f4bd5aaf6274a..ffcf394d5830f59385781d7f78cabd8aaa8d6124 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js |
| @@ -635,11 +635,29 @@ Background.prototype = { |
| cvox.QueueMode.FLUSH); |
| return false; |
| case 'speakTimeAndDate': |
| - var output = new Output(); |
| - var dateTime = new Date(); |
| - output.withString( |
| - dateTime.toLocaleTimeString() + |
| - ', ' + dateTime.toLocaleDateString()).go(); |
| + chrome.automation.getDesktop(function(d) { |
| + // First, try speaking the on-screen time. |
| + var allTime = d.findAll({role: RoleType.time}); |
|
dmazzoni
2016/05/06 15:53:14
Not for this change, but I think it'd be useful if
David Tseng
2016/05/06 20:40:14
Agreed; in this case, it would involve a leaf pred
|
| + allTime.filter(function(t) { |
| + return t.root.role == RoleType.desktop; |
| + }); |
| + |
| + var timeString = ''; |
| + allTime.forEach(function(t) { |
| + if (t.name) |
| + timeString = t.name; |
| + }); |
| + if (timeString) { |
| + cvox.ChromeVox.tts.speak(timeString, cvox.QueueMode.FLUSH); |
| + } else { |
| + // Fallback to the old way of speaking time. |
| + var output = new Output(); |
| + var dateTime = new Date(); |
| + output.withString( |
| + dateTime.toLocaleTimeString() + |
| + ', ' + dateTime.toLocaleDateString()).go(); |
| + } |
| + }); |
| return false; |
| case 'readCurrentTitle': |
| var target = this.currentRange_.start.node; |