| 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 Tab* current_tab = |
| 1599 tabstrip_->tab_at(browser_->tab_strip_model()->active_index()); |
| 1600 |
| 1598 if (IsIncognito()) { | 1601 if (IsIncognito()) { |
| 1599 return l10n_util::GetStringFUTF16( | 1602 return l10n_util::GetStringFUTF16( |
| 1600 IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT, | 1603 IDS_ACCESSIBLE_INCOGNITO_WINDOW_TITLE_FORMAT, |
| 1601 browser_->GetWindowTitleForCurrentTab(include_app_name)); | 1604 GetAccessibleTabLabel(include_app_name, current_tab->data())); |
| 1602 } | 1605 } |
| 1603 return browser_->GetWindowTitleForCurrentTab(include_app_name); | 1606 return GetAccessibleTabLabel(include_app_name, current_tab->data()); |
| 1607 } |
| 1608 |
| 1609 base::string16 BrowserView::GetAccessibleTabLabel(bool include_app_name, |
| 1610 TabRendererData data) const { |
| 1611 base::string16 window_title = |
| 1612 browser_->GetWindowTitleForCurrentTab(include_app_name); |
| 1613 base::string16 tab_label; |
| 1614 if (data.IsCrashed()) { |
| 1615 // Tab has crashed. |
| 1616 tab_label = l10n_util::GetStringFUTF16(IDS_TAB_AX_LABEL_CRASHED_FORMAT, |
| 1617 window_title); |
| 1618 } else if (data.network_state == TabRendererData::NETWORK_STATE_ERROR) { |
| 1619 // Network error interstitial. |
| 1620 tab_label = l10n_util::GetStringFUTF16( |
| 1621 IDS_TAB_AX_LABEL_NETWORK_ERROR_FORMAT, window_title); |
| 1622 } else { |
| 1623 // Alert tab states. |
| 1624 switch (data.alert_state) { |
| 1625 case TabAlertState::AUDIO_PLAYING: |
| 1626 tab_label = l10n_util::GetStringFUTF16( |
| 1627 IDS_TAB_AX_LABEL_AUDIO_PLAYING_FORMAT, window_title); |
| 1628 break; |
| 1629 case TabAlertState::USB_CONNECTED: |
| 1630 tab_label = l10n_util::GetStringFUTF16( |
| 1631 IDS_TAB_AX_LABEL_USB_CONNECTED_FORMAT, window_title); |
| 1632 break; |
| 1633 case TabAlertState::BLUETOOTH_CONNECTED: |
| 1634 tab_label = l10n_util::GetStringFUTF16( |
| 1635 IDS_TAB_AX_LABEL_BLUETOOTH_CONNECTED_FORMAT, window_title); |
| 1636 break; |
| 1637 case TabAlertState::MEDIA_RECORDING: |
| 1638 tab_label = l10n_util::GetStringFUTF16( |
| 1639 IDS_TAB_AX_LABEL_MEDIA_RECORDING_FORMAT, window_title); |
| 1640 break; |
| 1641 case TabAlertState::AUDIO_MUTING: |
| 1642 tab_label = l10n_util::GetStringFUTF16( |
| 1643 IDS_TAB_AX_LABEL_AUDIO_MUTING_FORMAT, window_title); |
| 1644 break; |
| 1645 case TabAlertState::TAB_CAPTURING: |
| 1646 tab_label = l10n_util::GetStringFUTF16( |
| 1647 IDS_TAB_AX_LABEL_TAB_CAPTURING_FORMAT, window_title); |
| 1648 break; |
| 1649 case TabAlertState::NONE: |
| 1650 default: |
| 1651 tab_label = window_title; |
| 1652 break; |
| 1653 } |
| 1654 } |
| 1655 return tab_label; |
| 1604 } | 1656 } |
| 1605 | 1657 |
| 1606 views::View* BrowserView::GetInitiallyFocusedView() { | 1658 views::View* BrowserView::GetInitiallyFocusedView() { |
| 1607 return nullptr; | 1659 return nullptr; |
| 1608 } | 1660 } |
| 1609 | 1661 |
| 1610 bool BrowserView::ShouldShowWindowTitle() const { | 1662 bool BrowserView::ShouldShowWindowTitle() const { |
| 1611 #if defined(USE_ASH) | 1663 #if defined(USE_ASH) |
| 1612 // For Ash only, trusted windows (apps and settings) do not show a title, | 1664 // 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. | 1665 // crbug.com/119411. Child windows (i.e. popups) do show a title. |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2596 } | 2648 } |
| 2597 | 2649 |
| 2598 extensions::ActiveTabPermissionGranter* | 2650 extensions::ActiveTabPermissionGranter* |
| 2599 BrowserView::GetActiveTabPermissionGranter() { | 2651 BrowserView::GetActiveTabPermissionGranter() { |
| 2600 content::WebContents* web_contents = GetActiveWebContents(); | 2652 content::WebContents* web_contents = GetActiveWebContents(); |
| 2601 if (!web_contents) | 2653 if (!web_contents) |
| 2602 return nullptr; | 2654 return nullptr; |
| 2603 return extensions::TabHelper::FromWebContents(web_contents) | 2655 return extensions::TabHelper::FromWebContents(web_contents) |
| 2604 ->active_tab_permission_granter(); | 2656 ->active_tab_permission_granter(); |
| 2605 } | 2657 } |
| OLD | NEW |