| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 50 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 51 #include "chrome/browser/ui/views/browser_dialogs.h" | 51 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 52 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" | 52 #include "chrome/browser/ui/views/download/download_in_progress_dialog_view.h" |
| 53 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 53 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
| 54 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 54 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 55 #include "chrome/browser/ui/views/frame/contents_container.h" | 55 #include "chrome/browser/ui/views/frame/contents_container.h" |
| 56 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" | 56 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" |
| 57 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 57 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 58 #include "chrome/browser/ui/views/location_bar/location_bar_container.h" | 58 #include "chrome/browser/ui/views/location_bar/location_bar_container.h" |
| 59 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 59 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 60 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" |
| 60 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 61 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 61 #include "chrome/browser/ui/views/password_generation_bubble_view.h" | 62 #include "chrome/browser/ui/views/password_generation_bubble_view.h" |
| 62 #include "chrome/browser/ui/views/status_bubble_views.h" | 63 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 63 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | 64 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" |
| 64 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 65 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 65 #include "chrome/browser/ui/views/toolbar_view.h" | 66 #include "chrome/browser/ui/views/toolbar_view.h" |
| 66 #include "chrome/browser/ui/views/update_recommended_message_box.h" | 67 #include "chrome/browser/ui/views/update_recommended_message_box.h" |
| 67 #include "chrome/browser/ui/views/website_settings_popup_view.h" | 68 #include "chrome/browser/ui/views/website_settings_popup_view.h" |
| 68 #include "chrome/browser/ui/webui/feedback_ui.h" | 69 #include "chrome/browser/ui/webui/feedback_ui.h" |
| 69 #include "chrome/browser/ui/window_sizer.h" | 70 #include "chrome/browser/ui/window_sizer.h" |
| (...skipping 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2127 FullscreenType type, | 2128 FullscreenType type, |
| 2128 const GURL& url, | 2129 const GURL& url, |
| 2129 FullscreenExitBubbleType bubble_type) { | 2130 FullscreenExitBubbleType bubble_type) { |
| 2130 // Reduce jankiness during the following position changes by: | 2131 // Reduce jankiness during the following position changes by: |
| 2131 // * Hiding the window until it's in the final position | 2132 // * Hiding the window until it's in the final position |
| 2132 // * Ignoring all intervening Layout() calls, which resize the webpage and | 2133 // * Ignoring all intervening Layout() calls, which resize the webpage and |
| 2133 // thus are slow and look ugly | 2134 // thus are slow and look ugly |
| 2134 ignore_layout_ = true; | 2135 ignore_layout_ = true; |
| 2135 LocationBarView* location_bar = GetLocationBarView(); | 2136 LocationBarView* location_bar = GetLocationBarView(); |
| 2136 #if defined(OS_WIN) && !defined(USE_AURA) | 2137 #if defined(OS_WIN) && !defined(USE_AURA) |
| 2137 OmniboxViewWin* omnibox_view = | 2138 OmniboxViewWin* omnibox_win = |
| 2138 static_cast<OmniboxViewWin*>(location_bar->GetLocationEntry()); | 2139 GetOmniboxViewWin(location_bar->GetLocationEntry()); |
| 2139 #endif | 2140 #endif |
| 2140 | 2141 |
| 2141 if (type == FOR_METRO || !fullscreen) { | 2142 if (type == FOR_METRO || !fullscreen) { |
| 2142 // Hide the fullscreen bubble as soon as possible, since the mode toggle can | 2143 // Hide the fullscreen bubble as soon as possible, since the mode toggle can |
| 2143 // take enough time for the user to notice. | 2144 // take enough time for the user to notice. |
| 2144 fullscreen_bubble_.reset(); | 2145 fullscreen_bubble_.reset(); |
| 2145 } | 2146 } |
| 2146 | 2147 |
| 2147 if (fullscreen) { | 2148 if (fullscreen) { |
| 2148 // Move focus out of the location bar if necessary. | 2149 // Move focus out of the location bar if necessary. |
| 2149 views::FocusManager* focus_manager = GetFocusManager(); | 2150 views::FocusManager* focus_manager = GetFocusManager(); |
| 2150 DCHECK(focus_manager); | 2151 DCHECK(focus_manager); |
| 2151 // Look for focus in the location bar itself or any child view. | 2152 // Look for focus in the location bar itself or any child view. |
| 2152 if (location_bar->Contains(focus_manager->GetFocusedView())) | 2153 if (location_bar->Contains(focus_manager->GetFocusedView())) |
| 2153 focus_manager->ClearFocus(); | 2154 focus_manager->ClearFocus(); |
| 2154 | 2155 |
| 2155 #if defined(OS_WIN) && !defined(USE_AURA) | 2156 #if defined(OS_WIN) && !defined(USE_AURA) |
| 2156 // If we don't hide the edit and force it to not show until we come out of | 2157 if (omnibox_win) { |
| 2157 // fullscreen, then if the user was on the New Tab Page, the edit contents | 2158 // If we don't hide the edit and force it to not show until we come out of |
| 2158 // will appear atop the web contents once we go into fullscreen mode. This | 2159 // fullscreen, then if the user was on the New Tab Page, the edit contents |
| 2159 // has something to do with how we move the main window while it's hidden; | 2160 // will appear atop the web contents once we go into fullscreen mode. This |
| 2160 // if we don't hide the main window below, we don't get this problem. | 2161 // has something to do with how we move the main window while it's hidden; |
| 2161 omnibox_view->set_force_hidden(true); | 2162 // if we don't hide the main window below, we don't get this problem. |
| 2162 ShowWindow(omnibox_view->m_hWnd, SW_HIDE); | 2163 omnibox_win->set_force_hidden(true); |
| 2164 ShowWindow(omnibox_win->m_hWnd, SW_HIDE); |
| 2165 } |
| 2163 #endif | 2166 #endif |
| 2164 } | 2167 } |
| 2165 #if defined(OS_WIN) && !defined(USE_AURA) | 2168 #if defined(OS_WIN) && !defined(USE_AURA) |
| 2166 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> | 2169 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> |
| 2167 PushForceHidden(); | 2170 PushForceHidden(); |
| 2168 #endif | 2171 #endif |
| 2169 | 2172 |
| 2170 if (type == FOR_METRO) { | 2173 if (type == FOR_METRO) { |
| 2171 #if defined(OS_WIN) && !defined(USE_AURA) | 2174 #if defined(OS_WIN) && !defined(USE_AURA) |
| 2172 // Enter metro snap mode. | 2175 // Enter metro snap mode. |
| 2173 static_cast<views::NativeWidgetWin*>( | 2176 static_cast<views::NativeWidgetWin*>( |
| 2174 frame_->native_widget())->SetMetroSnapFullscreen(fullscreen); | 2177 frame_->native_widget())->SetMetroSnapFullscreen(fullscreen); |
| 2175 #endif | 2178 #endif |
| 2176 } else { | 2179 } else { |
| 2177 // Toggle fullscreen mode. | 2180 // Toggle fullscreen mode. |
| 2178 frame_->SetFullscreen(fullscreen); | 2181 frame_->SetFullscreen(fullscreen); |
| 2179 } | 2182 } |
| 2180 | 2183 |
| 2181 browser_->WindowFullscreenStateChanged(); | 2184 browser_->WindowFullscreenStateChanged(); |
| 2182 | 2185 |
| 2183 if (fullscreen) { | 2186 if (fullscreen) { |
| 2184 bool is_kiosk = | 2187 bool is_kiosk = |
| 2185 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 2188 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
| 2186 if (!is_kiosk && type != FOR_METRO) { | 2189 if (!is_kiosk && type != FOR_METRO) { |
| 2187 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( | 2190 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( |
| 2188 GetWidget(), browser_.get(), url, bubble_type)); | 2191 GetWidget(), browser_.get(), url, bubble_type)); |
| 2189 } | 2192 } |
| 2190 } else { | 2193 } else { |
| 2191 #if defined(OS_WIN) && !defined(USE_AURA) | 2194 #if defined(OS_WIN) && !defined(USE_AURA) |
| 2192 // Show the edit again since we're no longer in fullscreen mode. | 2195 if (omnibox_win) { |
| 2193 omnibox_view->set_force_hidden(false); | 2196 // Show the edit again since we're no longer in fullscreen mode. |
| 2194 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); | 2197 omnibox_win->set_force_hidden(false); |
| 2198 ShowWindow(omnibox_win->m_hWnd, SW_SHOW); |
| 2199 } |
| 2195 #endif | 2200 #endif |
| 2196 } | 2201 } |
| 2197 | 2202 |
| 2198 // Undo our anti-jankiness hacks and force the window to re-layout now that | 2203 // Undo our anti-jankiness hacks and force the window to re-layout now that |
| 2199 // it's in its final position. | 2204 // it's in its final position. |
| 2200 ignore_layout_ = false; | 2205 ignore_layout_ = false; |
| 2201 Layout(); | 2206 Layout(); |
| 2202 #if defined(OS_WIN) && !defined(USE_AURA) | 2207 #if defined(OS_WIN) && !defined(USE_AURA) |
| 2203 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> | 2208 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> |
| 2204 PopForceHidden(); | 2209 PopForceHidden(); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 bubble->Show(); | 2512 bubble->Show(); |
| 2508 } | 2513 } |
| 2509 | 2514 |
| 2510 void BrowserView::RestackLocationBarContainer() { | 2515 void BrowserView::RestackLocationBarContainer() { |
| 2511 #if defined(USE_AURA) | 2516 #if defined(USE_AURA) |
| 2512 if (search_view_controller_.get()) | 2517 if (search_view_controller_.get()) |
| 2513 search_view_controller_->StackAtTop(); | 2518 search_view_controller_->StackAtTop(); |
| 2514 #endif | 2519 #endif |
| 2515 toolbar_->location_bar_container()->StackAtTop(); | 2520 toolbar_->location_bar_container()->StackAtTop(); |
| 2516 } | 2521 } |
| OLD | NEW |