OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 fullscreen_request_.bubble_type); | 808 fullscreen_request_.bubble_type); |
809 } else { | 809 } else { |
810 ProcessFullscreen(true, GURL(), | 810 ProcessFullscreen(true, GURL(), |
811 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); | 811 FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION); |
812 } | 812 } |
813 } else { | 813 } else { |
814 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); | 814 ProcessFullscreen(false, GURL(), FEB_TYPE_NONE); |
815 } | 815 } |
816 } | 816 } |
817 | 817 |
| 818 #if defined(OS_WIN) |
| 819 void BrowserView::ToggleMetroSnapMode(bool enable) { |
| 820 // Reduce jankiness during the following position changes by: |
| 821 // * Hiding the window until it's in the final position |
| 822 // * Ignoring all intervening Layout() calls, which resize the webpage and |
| 823 // thus are slow and look ugly |
| 824 ignore_layout_ = true; |
| 825 LocationBarView* location_bar = GetLocationBarView(); |
| 826 #if !defined(USE_AURA) |
| 827 OmniboxViewWin* omnibox_view = |
| 828 static_cast<OmniboxViewWin*>(location_bar->GetLocationEntry()); |
| 829 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> |
| 830 PushForceHidden(); |
| 831 #endif |
| 832 |
| 833 if (enable) { |
| 834 // Move focus out of the location bar if necessary. |
| 835 views::FocusManager* focus_manager = GetFocusManager(); |
| 836 DCHECK(focus_manager); |
| 837 // Look for focus in the location bar itself or any child view. |
| 838 if (location_bar->Contains(focus_manager->GetFocusedView())) |
| 839 focus_manager->ClearFocus(); |
| 840 |
| 841 #if !defined(USE_AURA) |
| 842 // If we don't hide the edit and force it to not show until we come out of |
| 843 // fullscreen, then if the user was on the New Tab Page, the edit contents |
| 844 // will appear atop the web contents once we go into fullscreen mode. This |
| 845 // has something to do with how we move the main window while it's hidden; |
| 846 // if we don't hide the main window below, we don't get this problem. |
| 847 omnibox_view->set_force_hidden(true); |
| 848 ShowWindow(omnibox_view->m_hWnd, SW_HIDE); |
| 849 #endif |
| 850 } else { |
| 851 #if !defined(USE_AURA) |
| 852 // Show the edit again since we're no longer in fullscreen mode. |
| 853 omnibox_view->set_force_hidden(false); |
| 854 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); |
| 855 #endif |
| 856 } |
| 857 |
| 858 // Enter metro snap mode. |
| 859 static_cast<views::NativeWidgetWin*>( |
| 860 frame_->native_widget())->SetMetroSnapFullscreen(enable); |
| 861 |
| 862 // Update various state as if we were in fullscreen mode. |
| 863 // TODO(robertshield): This may need to be modified for metro snap |
| 864 // mode - especially the command state changes. |
| 865 browser_->WindowFullscreenStateChanged(); |
| 866 |
| 867 // Undo our anti-jankiness hacks and force the window to re-layout now that |
| 868 // it's in its final position. |
| 869 ignore_layout_ = false; |
| 870 Layout(); |
| 871 |
| 872 #if !defined(USE_AURA) |
| 873 static_cast<views::NativeWidgetWin*>( |
| 874 frame_->native_widget())->PopForceHidden(); |
| 875 #endif |
| 876 } |
| 877 #endif // defined(OS_WIN) |
| 878 |
818 void BrowserView::RestoreFocus() { | 879 void BrowserView::RestoreFocus() { |
819 WebContents* selected_web_contents = GetSelectedWebContents(); | 880 WebContents* selected_web_contents = GetSelectedWebContents(); |
820 if (selected_web_contents) | 881 if (selected_web_contents) |
821 selected_web_contents->GetView()->RestoreFocus(); | 882 selected_web_contents->GetView()->RestoreFocus(); |
822 } | 883 } |
823 | 884 |
824 void BrowserView::SetWindowSwitcherButton(views::Button* button) { | 885 void BrowserView::SetWindowSwitcherButton(views::Button* button) { |
825 if (window_switcher_button_) | 886 if (window_switcher_button_) |
826 RemoveChildView(window_switcher_button_); | 887 RemoveChildView(window_switcher_button_); |
827 window_switcher_button_ = button; | 888 window_switcher_button_ = button; |
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2099 ShowWindow(omnibox_view->m_hWnd, SW_HIDE); | 2160 ShowWindow(omnibox_view->m_hWnd, SW_HIDE); |
2100 #endif | 2161 #endif |
2101 } | 2162 } |
2102 #if defined(OS_WIN) && !defined(USE_AURA) | 2163 #if defined(OS_WIN) && !defined(USE_AURA) |
2103 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> | 2164 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> |
2104 PushForceHidden(); | 2165 PushForceHidden(); |
2105 #endif | 2166 #endif |
2106 | 2167 |
2107 // Toggle fullscreen mode. | 2168 // Toggle fullscreen mode. |
2108 frame_->SetFullscreen(fullscreen); | 2169 frame_->SetFullscreen(fullscreen); |
2109 | |
2110 browser_->WindowFullscreenStateChanged(); | 2170 browser_->WindowFullscreenStateChanged(); |
2111 | 2171 |
2112 if (fullscreen) { | 2172 if (fullscreen) { |
2113 bool is_kiosk = | 2173 bool is_kiosk = |
2114 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 2174 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
2115 if (!is_kiosk) { | 2175 if (!is_kiosk) { |
2116 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( | 2176 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( |
2117 GetWidget(), browser_.get(), url, bubble_type)); | 2177 GetWidget(), browser_.get(), url, bubble_type)); |
2118 } | 2178 } |
2119 } else { | 2179 } else { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2426 this, | 2486 this, |
2427 web_contents->GetRenderViewHost(), | 2487 web_contents->GetRenderViewHost(), |
2428 password_generator, | 2488 password_generator, |
2429 browser_.get(), | 2489 browser_.get(), |
2430 wrapper->password_manager()); | 2490 wrapper->password_manager()); |
2431 | 2491 |
2432 views::BubbleDelegateView::CreateBubble(bubble); | 2492 views::BubbleDelegateView::CreateBubble(bubble); |
2433 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 2493 bubble->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
2434 bubble->Show(); | 2494 bubble->Show(); |
2435 } | 2495 } |
OLD | NEW |