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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 2581023002: Add tab status to accessibility labels (Closed)
Patch Set: Add check for active browser tab index to prevent crashes 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_view.h" 5 #include "chrome/browser/ui/views/frame/browser_view.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 #endif 1588 #endif
1589 return false; 1589 return false;
1590 } 1590 }
1591 1591
1592 base::string16 BrowserView::GetWindowTitle() const { 1592 base::string16 BrowserView::GetWindowTitle() const {
1593 return browser_->GetWindowTitleForCurrentTab(true /* include_app_name */); 1593 return browser_->GetWindowTitleForCurrentTab(true /* include_app_name */);
1594 } 1594 }
1595 1595
1596 base::string16 BrowserView::GetAccessibleWindowTitle() const { 1596 base::string16 BrowserView::GetAccessibleWindowTitle() const {
1597 const bool include_app_name = false; 1597 const bool include_app_name = false;
1598 if (IsIncognito()) { 1598 int active_index = browser_->tab_strip_model()->active_index();
1599 return l10n_util::GetStringFUTF16( 1599 if (active_index > -1) {
1600 IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT, 1600 Tab* current_tab = tabstrip_->tab_at(active_index);
1601 browser_->GetWindowTitleForCurrentTab(include_app_name)); 1601
1602 if (IsIncognito()) {
1603 return l10n_util::GetStringFUTF16(
1604 IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT,
1605 GetAccessibleTabLabel(include_app_name, current_tab->data()));
1606 }
1607 return GetAccessibleTabLabel(include_app_name, current_tab->data());
1608 } else {
1609 if (IsIncognito()) {
1610 return l10n_util::GetStringFUTF16(
1611 IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT,
1612 browser_->GetWindowTitleForCurrentTab(include_app_name));
1613 }
1614 return browser_->GetWindowTitleForCurrentTab(include_app_name);
1602 } 1615 }
1603 return browser_->GetWindowTitleForCurrentTab(include_app_name); 1616 }
1617
1618 base::string16 BrowserView::GetAccessibleTabLabel(
1619 bool include_app_name,
1620 const TabRendererData& data) const {
1621 base::string16 window_title =
1622 browser_->GetWindowTitleForCurrentTab(include_app_name);
sky 2016/12/16 00:52:51 Shouldn't you only do this for the active tab? May
edwardjung 2016/12/19 12:59:25 Good point, changed.
1623 base::string16 tab_label;
1624 if (data.IsCrashed()) {
1625 // Tab has crashed.
1626 tab_label = l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_CRASHED_FORMAT,
sky 2016/12/16 00:52:51 As you only set the label and then return at the e
edwardjung 2016/12/19 12:59:25 Done.
1627 window_title);
1628 } else if (data.network_state == TabRendererData::NETWORK_STATE_ERROR) {
1629 // Network error interstitial.
1630 tab_label = l10n_util::GetStringFUTF16(
1631 IDS_TAB_AX_LABEL_NETWORK_ERROR_FORMAT, window_title);
1632 } else {
1633 // Alert tab states.
1634 switch (data.alert_state) {
1635 case TabAlertState::AUDIO_PLAYING:
1636 tab_label = l10n_util::GetStringFUTF16(
1637 IDS_TAB_AX_LABEL_AUDIO_PLAYING_FORMAT, window_title);
1638 break;
1639 case TabAlertState::USB_CONNECTED:
1640 tab_label = l10n_util::GetStringFUTF16(
1641 IDS_TAB_AX_LABEL_USB_CONNECTED_FORMAT, window_title);
1642 break;
1643 case TabAlertState::BLUETOOTH_CONNECTED:
1644 tab_label = l10n_util::GetStringFUTF16(
1645 IDS_TAB_AX_LABEL_BLUETOOTH_CONNECTED_FORMAT, window_title);
1646 break;
1647 case TabAlertState::MEDIA_RECORDING:
1648 tab_label = l10n_util::GetStringFUTF16(
1649 IDS_TAB_AX_LABEL_MEDIA_RECORDING_FORMAT, window_title);
1650 break;
1651 case TabAlertState::AUDIO_MUTING:
1652 tab_label = l10n_util::GetStringFUTF16(
1653 IDS_TAB_AX_LABEL_AUDIO_MUTING_FORMAT, window_title);
1654 break;
1655 case TabAlertState::TAB_CAPTURING:
1656 tab_label = l10n_util::GetStringFUTF16(
1657 IDS_TAB_AX_LABEL_TAB_CAPTURING_FORMAT, window_title);
1658 break;
1659 case TabAlertState::NONE:
1660 tab_label = window_title;
1661 break;
1662 }
1663 }
1664 return tab_label;
1604 } 1665 }
1605 1666
1606 views::View* BrowserView::GetInitiallyFocusedView() { 1667 views::View* BrowserView::GetInitiallyFocusedView() {
1607 return nullptr; 1668 return nullptr;
1608 } 1669 }
1609 1670
1610 bool BrowserView::ShouldShowWindowTitle() const { 1671 bool BrowserView::ShouldShowWindowTitle() const {
1611 #if defined(USE_ASH) 1672 #if defined(USE_ASH)
1612 // For Ash only, trusted windows (apps and settings) do not show a title, 1673 // For Ash only, trusted windows (apps and settings) do not show a title,
1613 // crbug.com/119411. Child windows (i.e. popups) do show a title. 1674 // crbug.com/119411. Child windows (i.e. popups) do show a title.
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
2592 } 2653 }
2593 2654
2594 extensions::ActiveTabPermissionGranter* 2655 extensions::ActiveTabPermissionGranter*
2595 BrowserView::GetActiveTabPermissionGranter() { 2656 BrowserView::GetActiveTabPermissionGranter() {
2596 content::WebContents* web_contents = GetActiveWebContents(); 2657 content::WebContents* web_contents = GetActiveWebContents();
2597 if (!web_contents) 2658 if (!web_contents)
2598 return nullptr; 2659 return nullptr;
2599 return extensions::TabHelper::FromWebContents(web_contents) 2660 return extensions::TabHelper::FromWebContents(web_contents)
2600 ->active_tab_permission_granter(); 2661 ->active_tab_permission_granter();
2601 } 2662 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698