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