| 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 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #include "chrome/browser/ui/views/accelerator_table.h" | 61 #include "chrome/browser/ui/views/accelerator_table.h" |
| 62 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" | 62 #include "chrome/browser/ui/views/accessibility/invert_bubble_view.h" |
| 63 #include "chrome/browser/ui/views/autofill/save_card_bubble_views.h" | 63 #include "chrome/browser/ui/views/autofill/save_card_bubble_views.h" |
| 64 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 64 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 65 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" | 65 #include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h" |
| 66 #include "chrome/browser/ui/views/browser_dialogs.h" | 66 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 67 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" | 67 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
| 68 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 68 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
| 69 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" | 69 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" |
| 70 #include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h" | 70 #include "chrome/browser/ui/views/extensions/bookmark_app_bubble_view.h" |
| 71 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" | |
| 72 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 71 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 73 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" | 72 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" |
| 74 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" | 73 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" |
| 75 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 74 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| 76 #include "chrome/browser/ui/views/frame/top_container_view.h" | 75 #include "chrome/browser/ui/views/frame/top_container_view.h" |
| 77 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" | 76 #include "chrome/browser/ui/views/frame/web_contents_close_handler.h" |
| 78 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 77 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 79 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 78 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 80 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 79 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 81 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 80 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | 91 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 93 #include "chrome/browser/ui/views/toolbar/reload_button.h" | 92 #include "chrome/browser/ui/views/toolbar/reload_button.h" |
| 94 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 93 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 95 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" | 94 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
| 96 #include "chrome/browser/ui/views/update_recommended_message_box.h" | 95 #include "chrome/browser/ui/views/update_recommended_message_box.h" |
| 97 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" | 96 #include "chrome/browser/ui/views/website_settings/permissions_bubble_view.h" |
| 98 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" | 97 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" |
| 99 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 98 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
| 100 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 99 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 101 #include "chrome/common/chrome_switches.h" | 100 #include "chrome/common/chrome_switches.h" |
| 102 #include "chrome/common/extensions/command.h" | |
| 103 #include "chrome/common/pref_names.h" | 101 #include "chrome/common/pref_names.h" |
| 104 #include "chrome/common/url_constants.h" | 102 #include "chrome/common/url_constants.h" |
| 105 #include "chrome/grit/chromium_strings.h" | 103 #include "chrome/grit/chromium_strings.h" |
| 106 #include "chrome/grit/generated_resources.h" | 104 #include "chrome/grit/generated_resources.h" |
| 107 #include "chrome/grit/locale_settings.h" | 105 #include "chrome/grit/locale_settings.h" |
| 108 #include "components/app_modal/app_modal_dialog.h" | 106 #include "components/app_modal/app_modal_dialog.h" |
| 109 #include "components/app_modal/app_modal_dialog_queue.h" | 107 #include "components/app_modal/app_modal_dialog_queue.h" |
| 110 #include "components/app_modal/native_app_modal_dialog.h" | 108 #include "components/app_modal/native_app_modal_dialog.h" |
| 111 #include "components/omnibox/browser/omnibox_popup_model.h" | 109 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 112 #include "components/omnibox/browser/omnibox_popup_view.h" | 110 #include "components/omnibox/browser/omnibox_popup_view.h" |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 location_bar->FocusLocation(select_all); | 1099 location_bar->FocusLocation(select_all); |
| 1102 } else { | 1100 } else { |
| 1103 // If none of location bar got focus, then clear focus. | 1101 // If none of location bar got focus, then clear focus. |
| 1104 views::FocusManager* focus_manager = GetFocusManager(); | 1102 views::FocusManager* focus_manager = GetFocusManager(); |
| 1105 DCHECK(focus_manager); | 1103 DCHECK(focus_manager); |
| 1106 focus_manager->ClearFocus(); | 1104 focus_manager->ClearFocus(); |
| 1107 } | 1105 } |
| 1108 } | 1106 } |
| 1109 | 1107 |
| 1110 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { | 1108 void BrowserView::UpdateReloadStopState(bool is_loading, bool force) { |
| 1111 if (toolbar_->reload_button()) { | 1109 toolbar_->reload_button()->ChangeMode( |
| 1112 toolbar_->reload_button()->ChangeMode( | 1110 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, force); |
| 1113 is_loading ? ReloadButton::MODE_STOP : ReloadButton::MODE_RELOAD, | |
| 1114 force); | |
| 1115 } | |
| 1116 } | 1111 } |
| 1117 | 1112 |
| 1118 void BrowserView::UpdateToolbar(content::WebContents* contents) { | 1113 void BrowserView::UpdateToolbar(content::WebContents* contents) { |
| 1119 // We may end up here during destruction. | 1114 // We may end up here during destruction. |
| 1120 if (toolbar_) | 1115 if (toolbar_) |
| 1121 toolbar_->Update(contents); | 1116 toolbar_->Update(contents); |
| 1122 frame_->UpdateToolbar(); | 1117 frame_->UpdateToolbar(); |
| 1123 } | 1118 } |
| 1124 | 1119 |
| 1125 void BrowserView::ResetToolbarTabState(content::WebContents* contents) { | 1120 void BrowserView::ResetToolbarTabState(content::WebContents* contents) { |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 } | 1840 } |
| 1846 | 1841 |
| 1847 views::ClientView* BrowserView::CreateClientView(views::Widget* widget) { | 1842 views::ClientView* BrowserView::CreateClientView(views::Widget* widget) { |
| 1848 return this; | 1843 return this; |
| 1849 } | 1844 } |
| 1850 | 1845 |
| 1851 void BrowserView::OnWidgetActivationChanged(views::Widget* widget, | 1846 void BrowserView::OnWidgetActivationChanged(views::Widget* widget, |
| 1852 bool active) { | 1847 bool active) { |
| 1853 if (active) | 1848 if (active) |
| 1854 BrowserList::SetLastActive(browser_.get()); | 1849 BrowserList::SetLastActive(browser_.get()); |
| 1855 | |
| 1856 if (!extension_keybinding_registry_ && | |
| 1857 GetFocusManager()) { // focus manager can be null in tests. | |
| 1858 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( | |
| 1859 browser_->profile(), GetFocusManager(), | |
| 1860 extensions::ExtensionKeybindingRegistry::ALL_EXTENSIONS, this)); | |
| 1861 } | |
| 1862 | |
| 1863 extensions::ExtensionCommandsGlobalRegistry* registry = | |
| 1864 extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile()); | |
| 1865 if (active) { | |
| 1866 registry->set_registry_for_active_window( | |
| 1867 extension_keybinding_registry_.get()); | |
| 1868 } else if (registry->registry_for_active_window() == | |
| 1869 extension_keybinding_registry_.get()) { | |
| 1870 registry->set_registry_for_active_window(nullptr); | |
| 1871 } | |
| 1872 } | 1850 } |
| 1873 | 1851 |
| 1874 void BrowserView::OnWindowBeginUserBoundsChange() { | 1852 void BrowserView::OnWindowBeginUserBoundsChange() { |
| 1875 WebContents* web_contents = GetActiveWebContents(); | 1853 WebContents* web_contents = GetActiveWebContents(); |
| 1876 if (!web_contents) | 1854 if (!web_contents) |
| 1877 return; | 1855 return; |
| 1878 web_contents->GetRenderViewHost()->NotifyMoveOrResizeStarted(); | 1856 web_contents->GetRenderViewHost()->NotifyMoveOrResizeStarted(); |
| 1879 } | 1857 } |
| 1880 | 1858 |
| 1881 void BrowserView::OnWidgetMove() { | 1859 void BrowserView::OnWidgetMove() { |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2625 } | 2603 } |
| 2626 // Don't use bookmark_bar_view_->height() which won't be the final height if | 2604 // Don't use bookmark_bar_view_->height() which won't be the final height if |
| 2627 // the bookmark bar is animating. | 2605 // the bookmark bar is animating. |
| 2628 return chrome::kNTPBookmarkBarHeight - | 2606 return chrome::kNTPBookmarkBarHeight - |
| 2629 views::NonClientFrameView::kClientEdgeThickness; | 2607 views::NonClientFrameView::kClientEdgeThickness; |
| 2630 } | 2608 } |
| 2631 | 2609 |
| 2632 void BrowserView::ExecuteExtensionCommand( | 2610 void BrowserView::ExecuteExtensionCommand( |
| 2633 const extensions::Extension* extension, | 2611 const extensions::Extension* extension, |
| 2634 const extensions::Command& command) { | 2612 const extensions::Command& command) { |
| 2635 extension_keybinding_registry_->ExecuteCommand(extension->id(), | 2613 toolbar_->ExecuteExtensionCommand(extension, command); |
| 2636 command.accelerator()); | |
| 2637 } | 2614 } |
| 2638 | 2615 |
| 2639 ExclusiveAccessContext* BrowserView::GetExclusiveAccessContext() { | 2616 ExclusiveAccessContext* BrowserView::GetExclusiveAccessContext() { |
| 2640 return this; | 2617 return this; |
| 2641 } | 2618 } |
| 2642 | 2619 |
| 2643 bool BrowserView::DoCutCopyPasteForWebContents( | 2620 bool BrowserView::DoCutCopyPasteForWebContents( |
| 2644 WebContents* contents, | 2621 WebContents* contents, |
| 2645 void (WebContents::*method)()) { | 2622 void (WebContents::*method)()) { |
| 2646 // It's possible for a non-null WebContents to have a null RWHV if it's | 2623 // It's possible for a non-null WebContents to have a null RWHV if it's |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2739 return GetWidget()->GetClientAreaBoundsInScreen(); | 2716 return GetWidget()->GetClientAreaBoundsInScreen(); |
| 2740 } | 2717 } |
| 2741 | 2718 |
| 2742 bool BrowserView::IsImmersiveModeEnabled() { | 2719 bool BrowserView::IsImmersiveModeEnabled() { |
| 2743 return immersive_mode_controller()->IsEnabled(); | 2720 return immersive_mode_controller()->IsEnabled(); |
| 2744 } | 2721 } |
| 2745 | 2722 |
| 2746 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { | 2723 gfx::Rect BrowserView::GetTopContainerBoundsInScreen() { |
| 2747 return top_container_->GetBoundsInScreen(); | 2724 return top_container_->GetBoundsInScreen(); |
| 2748 } | 2725 } |
| 2749 | |
| 2750 extensions::ActiveTabPermissionGranter* | |
| 2751 BrowserView::GetActiveTabPermissionGranter() { | |
| 2752 content::WebContents* web_contents = GetActiveWebContents(); | |
| 2753 if (!web_contents) | |
| 2754 return nullptr; | |
| 2755 return extensions::TabHelper::FromWebContents(web_contents) | |
| 2756 ->active_tab_permission_granter(); | |
| 2757 } | |
| OLD | NEW |