| 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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 toolbar_->reload_button()->ChangeMode( | 1028 toolbar_->reload_button()->ChangeMode( |
| 1029 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, | 1029 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, |
| 1030 force); | 1030 force); |
| 1031 } | 1031 } |
| 1032 } | 1032 } |
| 1033 | 1033 |
| 1034 void BrowserView::UpdateToolbar(content::WebContents* contents) { | 1034 void BrowserView::UpdateToolbar(content::WebContents* contents) { |
| 1035 // We may end up here during destruction. | 1035 // We may end up here during destruction. |
| 1036 if (toolbar_) | 1036 if (toolbar_) |
| 1037 toolbar_->Update(contents); | 1037 toolbar_->Update(contents); |
| 1038 frame_->UpdateToolbar(); | |
| 1039 } | 1038 } |
| 1040 | 1039 |
| 1041 void BrowserView::ResetToolbarTabState(content::WebContents* contents) { | 1040 void BrowserView::ResetToolbarTabState(content::WebContents* contents) { |
| 1042 // We may end up here during destruction. | 1041 // We may end up here during destruction. |
| 1043 if (toolbar_) | 1042 if (toolbar_) |
| 1044 toolbar_->ResetTabState(contents); | 1043 toolbar_->ResetTabState(contents); |
| 1045 } | 1044 } |
| 1046 | 1045 |
| 1047 void BrowserView::FocusToolbar() { | 1046 void BrowserView::FocusToolbar() { |
| 1048 // Temporarily reveal the top-of-window views (if not already revealed) so | 1047 // Temporarily reveal the top-of-window views (if not already revealed) so |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 | 1275 |
| 1277 void BrowserView::UserChangedTheme() { | 1276 void BrowserView::UserChangedTheme() { |
| 1278 frame_->FrameTypeChanged(); | 1277 frame_->FrameTypeChanged(); |
| 1279 } | 1278 } |
| 1280 | 1279 |
| 1281 void BrowserView::ShowWebsiteSettings( | 1280 void BrowserView::ShowWebsiteSettings( |
| 1282 Profile* profile, | 1281 Profile* profile, |
| 1283 content::WebContents* web_contents, | 1282 content::WebContents* web_contents, |
| 1284 const GURL& virtual_url, | 1283 const GURL& virtual_url, |
| 1285 const security_state::SecurityInfo& security_info) { | 1284 const security_state::SecurityInfo& security_info) { |
| 1286 // Some browser windows have a location icon embedded in the frame. Try to | 1285 views::View* popup_anchor = nullptr; |
| 1287 // use that if it exists. If it doesn't exist, use the location icon from | 1286 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 1288 // the location bar. | 1287 popup_anchor = toolbar_->location_bar(); |
| 1289 views::View* popup_anchor = | 1288 else |
| 1290 ui::MaterialDesignController::IsSecondaryUiMaterial() | |
| 1291 ? toolbar_->location_bar() | |
| 1292 : frame_->GetLocationIconView(); | |
| 1293 if (!popup_anchor) | |
| 1294 popup_anchor = GetLocationBarView()->location_icon_view()->GetImageView(); | 1289 popup_anchor = GetLocationBarView()->location_icon_view()->GetImageView(); |
| 1295 | 1290 |
| 1296 WebsiteSettingsPopupView::ShowPopup(popup_anchor, gfx::Rect(), profile, | 1291 WebsiteSettingsPopupView::ShowPopup(popup_anchor, gfx::Rect(), profile, |
| 1297 web_contents, virtual_url, security_info); | 1292 web_contents, virtual_url, security_info); |
| 1298 } | 1293 } |
| 1299 | 1294 |
| 1300 void BrowserView::ShowAppMenu() { | 1295 void BrowserView::ShowAppMenu() { |
| 1301 if (!toolbar_->app_menu_button()) | 1296 if (!toolbar_->app_menu_button()) |
| 1302 return; | 1297 return; |
| 1303 | 1298 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 } | 1599 } |
| 1605 | 1600 |
| 1606 views::View* BrowserView::GetInitiallyFocusedView() { | 1601 views::View* BrowserView::GetInitiallyFocusedView() { |
| 1607 return nullptr; | 1602 return nullptr; |
| 1608 } | 1603 } |
| 1609 | 1604 |
| 1610 bool BrowserView::ShouldShowWindowTitle() const { | 1605 bool BrowserView::ShouldShowWindowTitle() const { |
| 1611 #if defined(USE_ASH) | 1606 #if defined(USE_ASH) |
| 1612 // For Ash only, trusted windows (apps and settings) do not show a title, | 1607 // 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. | 1608 // crbug.com/119411. Child windows (i.e. popups) do show a title. |
| 1614 if (browser_->is_trusted_source() && | 1609 if (browser_->is_trusted_source()) |
| 1615 !browser_->SupportsWindowFeature(Browser::FEATURE_WEBAPPFRAME)) | |
| 1616 return false; | 1610 return false; |
| 1617 #endif // USE_ASH | 1611 #endif // USE_ASH |
| 1618 | 1612 |
| 1619 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); | 1613 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); |
| 1620 } | 1614 } |
| 1621 | 1615 |
| 1622 gfx::ImageSkia BrowserView::GetWindowAppIcon() { | 1616 gfx::ImageSkia BrowserView::GetWindowAppIcon() { |
| 1623 if (browser_->is_app()) { | 1617 if (browser_->is_app()) { |
| 1624 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); | 1618 WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents(); |
| 1625 extensions::TabHelper* extensions_tab_helper = | 1619 extensions::TabHelper* extensions_tab_helper = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1639 | 1633 |
| 1640 if (browser_->is_app() || browser_->is_type_popup()) | 1634 if (browser_->is_app() || browser_->is_type_popup()) |
| 1641 return browser_->GetCurrentPageIcon().AsImageSkia(); | 1635 return browser_->GetCurrentPageIcon().AsImageSkia(); |
| 1642 return gfx::ImageSkia(); | 1636 return gfx::ImageSkia(); |
| 1643 } | 1637 } |
| 1644 | 1638 |
| 1645 bool BrowserView::ShouldShowWindowIcon() const { | 1639 bool BrowserView::ShouldShowWindowIcon() const { |
| 1646 #if defined(USE_ASH) | 1640 #if defined(USE_ASH) |
| 1647 // For Ash only, trusted windows (apps and settings) do not show an icon, | 1641 // For Ash only, trusted windows (apps and settings) do not show an icon, |
| 1648 // crbug.com/119411. Child windows (i.e. popups) do show an icon. | 1642 // crbug.com/119411. Child windows (i.e. popups) do show an icon. |
| 1649 if (browser_->is_trusted_source() && | 1643 if (browser_->is_trusted_source()) |
| 1650 !browser_->SupportsWindowFeature(Browser::FEATURE_WEBAPPFRAME)) | |
| 1651 return false; | 1644 return false; |
| 1652 #endif // USE_ASH | 1645 #endif // USE_ASH |
| 1653 | 1646 |
| 1654 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); | 1647 return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); |
| 1655 } | 1648 } |
| 1656 | 1649 |
| 1657 bool BrowserView::ExecuteWindowsCommand(int command_id) { | 1650 bool BrowserView::ExecuteWindowsCommand(int command_id) { |
| 1658 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. | 1651 // This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND. |
| 1659 #if defined(OS_WIN) | 1652 #if defined(OS_WIN) |
| 1660 if (command_id == IDC_DEBUG_FRAME_TOGGLE) | 1653 if (command_id == IDC_DEBUG_FRAME_TOGGLE) |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2592 } | 2585 } |
| 2593 | 2586 |
| 2594 extensions::ActiveTabPermissionGranter* | 2587 extensions::ActiveTabPermissionGranter* |
| 2595 BrowserView::GetActiveTabPermissionGranter() { | 2588 BrowserView::GetActiveTabPermissionGranter() { |
| 2596 content::WebContents* web_contents = GetActiveWebContents(); | 2589 content::WebContents* web_contents = GetActiveWebContents(); |
| 2597 if (!web_contents) | 2590 if (!web_contents) |
| 2598 return nullptr; | 2591 return nullptr; |
| 2599 return extensions::TabHelper::FromWebContents(web_contents) | 2592 return extensions::TabHelper::FromWebContents(web_contents) |
| 2600 ->active_tab_permission_granter(); | 2593 ->active_tab_permission_granter(); |
| 2601 } | 2594 } |
| OLD | NEW |