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

Unified Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 2581023002: Add tab status to accessibility labels (Closed)
Patch Set: Add tab index check. Fixes ChromeVox crash. Created 4 years 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/ui/views/frame/browser_view.cc
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index f2a776f3b188e2ffb5e54ed5588256b86d3b0d6b..9bb2c2fd03b69b56f82ed29be54e0d23a3bdf31c 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -1595,12 +1595,66 @@ base::string16 BrowserView::GetWindowTitle() const {
base::string16 BrowserView::GetAccessibleWindowTitle() const {
const bool include_app_name = false;
- if (IsIncognito()) {
- return l10n_util::GetStringFUTF16(
- IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT,
- browser_->GetWindowTitleForCurrentTab(include_app_name));
+ int active_index = browser_->tab_strip_model()->active_index();
+ if (active_index > -1) {
+ if (IsIncognito()) {
+ return l10n_util::GetStringFUTF16(
+ IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT,
+ GetAccessibleTabLabel(include_app_name, active_index));
+ }
+ return GetAccessibleTabLabel(include_app_name, active_index);
+ } else {
sky 2017/01/03 23:11:41 no else after return (see chromium style guide for
edwardjung 2017/01/05 16:59:45 Done.
+ if (IsIncognito()) {
+ return l10n_util::GetStringFUTF16(
+ IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT,
+ browser_->GetWindowTitleForCurrentTab(include_app_name));
+ }
+ return browser_->GetWindowTitleForCurrentTab(include_app_name);
+ }
+}
+
+base::string16 BrowserView::GetAccessibleTabLabel(bool include_app_name,
+ int index) const {
+ if (index > -1) {
sky 2017/01/03 23:11:41 When is this called with -1? I think callers shoul
edwardjung 2017/01/05 16:59:45 This was a fix for ChromeVox which would call this
sky 2017/01/05 17:45:17 Ok, fair enough. Can you make 1617 and early retur
edwardjung 2017/01/05 18:41:14 Done. I also added a comment for this check.
+ base::string16 window_title =
+ browser_->GetWindowTitleForTab(include_app_name, index);
+ TabRendererData data = tabstrip_->tab_at(index)->data();
sky 2017/01/03 23:11:41 const TabRendererData&
edwardjung 2017/01/05 16:59:45 Done.
+
+ // Tab has crashed.
+ if (data.IsCrashed()) {
+ return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_CRASHED_FORMAT,
+ window_title);
+ }
+ // Network error interstitial.
+ if (data.network_state == TabRendererData::NETWORK_STATE_ERROR) {
+ return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_NETWORK_ERROR_FORMAT,
+ window_title);
+ }
+ // Alert tab states.
+ switch (data.alert_state) {
+ case TabAlertState::AUDIO_PLAYING:
+ return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_AUDIO_PLAYING_FORMAT,
+ window_title);
+ case TabAlertState::USB_CONNECTED:
+ return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_USB_CONNECTED_FORMAT,
+ window_title);
+ case TabAlertState::BLUETOOTH_CONNECTED:
+ return l10n_util::GetStringFUTF16(
+ IDS_TAB_AX_LABEL_BLUETOOTH_CONNECTED_FORMAT, window_title);
+ case TabAlertState::MEDIA_RECORDING:
+ return l10n_util::GetStringFUTF16(
+ IDS_TAB_AX_LABEL_MEDIA_RECORDING_FORMAT, window_title);
+ case TabAlertState::AUDIO_MUTING:
+ return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_AUDIO_MUTING_FORMAT,
+ window_title);
+ case TabAlertState::TAB_CAPTURING:
+ return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_TAB_CAPTURING_FORMAT,
+ window_title);
+ case TabAlertState::NONE:
+ return window_title;
+ }
}
- return browser_->GetWindowTitleForCurrentTab(include_app_name);
+ return base::string16();
}
views::View* BrowserView::GetInitiallyFocusedView() {
@@ -2021,8 +2075,8 @@ void BrowserView::InitViews() {
// TabStrip takes ownership of the controller.
BrowserTabStripController* tabstrip_controller =
- new BrowserTabStripController(browser_.get(),
- browser_->tab_strip_model());
+ new BrowserTabStripController(browser_.get(), browser_->tab_strip_model(),
+ this);
tabstrip_ = new TabStrip(tabstrip_controller);
top_container_->AddChildView(tabstrip_);
tabstrip_controller->InitFromModel(tabstrip_);

Powered by Google App Engine
This is Rietveld 408576698