Commit fa8e0afd authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

Have VoiceOver play a sound when a download changes state.

Safari plays a sound when a download fails. This does it for both
success and failure.

Bug: 787139
Change-Id: If3df9aaed218f8b66fcf124ae8f2529eba87c6f5
Reviewed-on: https://chromium-review.googlesource.com/850743Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#527113}
parent 80bdddf5
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "content/public/browser/download_item.h" #include "content/public/browser/download_item.h"
#include "content/public/browser/page_navigator.h" #include "content/public/browser/page_navigator.h"
#include "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTweaker.h" #include "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTweaker.h"
#include "ui/base/cocoa/a11y_util.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/font.h" #include "ui/gfx/font.h"
...@@ -228,6 +229,10 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { ...@@ -228,6 +229,10 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
- (void)setStateFromDownload:(DownloadItemModel*)downloadModel { - (void)setStateFromDownload:(DownloadItemModel*)downloadModel {
DCHECK_EQ([self download], downloadModel->download()); DCHECK_EQ([self download], downloadModel->download());
if (downloadModel->download()->GetState() != DownloadItem::IN_PROGRESS)
ui::a11y_util::PlayElementUpdatedSound(self.view.window);
if (base::FeatureList::IsEnabled(features::kMacMaterialDesignDownloadShelf)) { if (base::FeatureList::IsEnabled(features::kMacMaterialDesignDownloadShelf)) {
[progressView_ setStateFromDownload:downloadModel]; [progressView_ setStateFromDownload:downloadModel];
CGFloat preferredWidth = progressView_.preferredWidth; CGFloat preferredWidth = progressView_.preferredWidth;
......
...@@ -17,6 +17,11 @@ namespace a11y_util { ...@@ -17,6 +17,11 @@ namespace a11y_util {
// voice over (i.e., an icon next to a written description of the icon). // voice over (i.e., an icon next to a written description of the icon).
UI_BASE_EXPORT void HideImageFromAccessibilityOrder(NSImageView* view); UI_BASE_EXPORT void HideImageFromAccessibilityOrder(NSImageView* view);
// Ask VoiceOver to play a sound for |object|, generally a view or window
// (undocumented). Built-in apps seem to use this to indicate that something
// interesting has happened, like a failed download or available completions.
UI_BASE_EXPORT void PlayElementUpdatedSound(id source);
} // namespace a11y_util } // namespace a11y_util
} // namespace ui } // namespace ui
......
...@@ -15,5 +15,11 @@ void HideImageFromAccessibilityOrder(NSImageView* view) { ...@@ -15,5 +15,11 @@ void HideImageFromAccessibilityOrder(NSImageView* view) {
forAttribute:NSAccessibilityRoleAttribute]; forAttribute:NSAccessibilityRoleAttribute];
} }
void PlayElementUpdatedSound(id source) {
NSAccessibilityPostNotificationWithUserInfo(
source, @"AXPlaySound",
@{@"AXSoundIdentifier" : @"AXElementUpdatedSound"});
}
} // namespace a11y_util } // namespace a11y_util
} // namespace ui } // namespace ui
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