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

Side by Side 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 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 if (IsIncognito()) {
1601 browser_->GetWindowTitleForCurrentTab(include_app_name)); 1601 return l10n_util::GetStringFUTF16(
1602 IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT,
1603 GetAccessibleTabLabel(include_app_name, active_index));
1604 }
1605 return GetAccessibleTabLabel(include_app_name, active_index);
1606 } 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.
1607 if (IsIncognito()) {
1608 return l10n_util::GetStringFUTF16(
1609 IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT,
1610 browser_->GetWindowTitleForCurrentTab(include_app_name));
1611 }
1612 return browser_->GetWindowTitleForCurrentTab(include_app_name);
1602 } 1613 }
1603 return browser_->GetWindowTitleForCurrentTab(include_app_name); 1614 }
1615
1616 base::string16 BrowserView::GetAccessibleTabLabel(bool include_app_name,
1617 int index) const {
1618 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.
1619 base::string16 window_title =
1620 browser_->GetWindowTitleForTab(include_app_name, index);
1621 TabRendererData data = tabstrip_->tab_at(index)->data();
sky 2017/01/03 23:11:41 const TabRendererData&
edwardjung 2017/01/05 16:59:45 Done.
1622
1623 // Tab has crashed.
1624 if (data.IsCrashed()) {
1625 return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_CRASHED_FORMAT,
1626 window_title);
1627 }
1628 // Network error interstitial.
1629 if (data.network_state == TabRendererData::NETWORK_STATE_ERROR) {
1630 return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_NETWORK_ERROR_FORMAT,
1631 window_title);
1632 }
1633 // Alert tab states.
1634 switch (data.alert_state) {
1635 case TabAlertState::AUDIO_PLAYING:
1636 return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_AUDIO_PLAYING_FORMAT,
1637 window_title);
1638 case TabAlertState::USB_CONNECTED:
1639 return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_USB_CONNECTED_FORMAT,
1640 window_title);
1641 case TabAlertState::BLUETOOTH_CONNECTED:
1642 return l10n_util::GetStringFUTF16(
1643 IDS_TAB_AX_LABEL_BLUETOOTH_CONNECTED_FORMAT, window_title);
1644 case TabAlertState::MEDIA_RECORDING:
1645 return l10n_util::GetStringFUTF16(
1646 IDS_TAB_AX_LABEL_MEDIA_RECORDING_FORMAT, window_title);
1647 case TabAlertState::AUDIO_MUTING:
1648 return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_AUDIO_MUTING_FORMAT,
1649 window_title);
1650 case TabAlertState::TAB_CAPTURING:
1651 return l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_TAB_CAPTURING_FORMAT,
1652 window_title);
1653 case TabAlertState::NONE:
1654 return window_title;
1655 }
1656 }
1657 return base::string16();
1604 } 1658 }
1605 1659
1606 views::View* BrowserView::GetInitiallyFocusedView() { 1660 views::View* BrowserView::GetInitiallyFocusedView() {
1607 return nullptr; 1661 return nullptr;
1608 } 1662 }
1609 1663
1610 bool BrowserView::ShouldShowWindowTitle() const { 1664 bool BrowserView::ShouldShowWindowTitle() const {
1611 #if defined(USE_ASH) 1665 #if defined(USE_ASH)
1612 // For Ash only, trusted windows (apps and settings) do not show a title, 1666 // 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. 1667 // crbug.com/119411. Child windows (i.e. popups) do show a title.
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 AddChildView(contents_container_); 2068 AddChildView(contents_container_);
2015 set_contents_view(contents_container_); 2069 set_contents_view(contents_container_);
2016 2070
2017 // Top container holds tab strip and toolbar and lives at the front of the 2071 // Top container holds tab strip and toolbar and lives at the front of the
2018 // view hierarchy. 2072 // view hierarchy.
2019 top_container_ = new TopContainerView(this); 2073 top_container_ = new TopContainerView(this);
2020 AddChildView(top_container_); 2074 AddChildView(top_container_);
2021 2075
2022 // TabStrip takes ownership of the controller. 2076 // TabStrip takes ownership of the controller.
2023 BrowserTabStripController* tabstrip_controller = 2077 BrowserTabStripController* tabstrip_controller =
2024 new BrowserTabStripController(browser_.get(), 2078 new BrowserTabStripController(browser_.get(), browser_->tab_strip_model(),
2025 browser_->tab_strip_model()); 2079 this);
2026 tabstrip_ = new TabStrip(tabstrip_controller); 2080 tabstrip_ = new TabStrip(tabstrip_controller);
2027 top_container_->AddChildView(tabstrip_); 2081 top_container_->AddChildView(tabstrip_);
2028 tabstrip_controller->InitFromModel(tabstrip_); 2082 tabstrip_controller->InitFromModel(tabstrip_);
2029 2083
2030 toolbar_ = new ToolbarView(browser_.get()); 2084 toolbar_ = new ToolbarView(browser_.get());
2031 top_container_->AddChildView(toolbar_); 2085 top_container_->AddChildView(toolbar_);
2032 toolbar_->Init(); 2086 toolbar_->Init();
2033 2087
2034 // The infobar container must come after the toolbar so its arrow paints on 2088 // The infobar container must come after the toolbar so its arrow paints on
2035 // top. 2089 // top.
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
2592 } 2646 }
2593 2647
2594 extensions::ActiveTabPermissionGranter* 2648 extensions::ActiveTabPermissionGranter*
2595 BrowserView::GetActiveTabPermissionGranter() { 2649 BrowserView::GetActiveTabPermissionGranter() {
2596 content::WebContents* web_contents = GetActiveWebContents(); 2650 content::WebContents* web_contents = GetActiveWebContents();
2597 if (!web_contents) 2651 if (!web_contents)
2598 return nullptr; 2652 return nullptr;
2599 return extensions::TabHelper::FromWebContents(web_contents) 2653 return extensions::TabHelper::FromWebContents(web_contents)
2600 ->active_tab_permission_granter(); 2654 ->active_tab_permission_granter();
2601 } 2655 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698