feat: add "accessibleTitle" property to a BrowserWindow instance (#19698)

Sometimes it's necessary to convey more information about the window to screen reader users only (simply putting everything to the window title might be unnecessarily noisy).

For example, Chromium uses that technique to tell screen reader users that the window is in incognito mode (the incognito window looks differently and doesn't have «incognito» in the title, but for blind users the screen reader will announce that it's incognito).
This commit is contained in:
Marat Abdullin 2019-08-28 00:35:34 +02:00 committed by Alexey Kuzmin
parent 1dcda7b809
commit ae9424d93a
5 changed files with 46 additions and 0 deletions

View file

@ -582,6 +582,22 @@ const views::Widget* NativeWindow::GetWidget() const {
return widget();
}
base::string16 NativeWindow::GetAccessibleWindowTitle() const {
if (accessible_title_.empty()) {
return views::WidgetDelegate::GetAccessibleWindowTitle();
}
return accessible_title_;
}
void NativeWindow::SetAccessibleTitle(const std::string& title) {
accessible_title_ = base::UTF8ToUTF16(title);
}
std::string NativeWindow::GetAccessibleTitle() {
return base::UTF16ToUTF8(accessible_title_);
}
// static
void NativeWindowRelay::CreateForWebContents(
content::WebContents* web_contents,