OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 591 |
592 browser()->OnWindowDidShow(); | 592 browser()->OnWindowDidShow(); |
593 } | 593 } |
594 | 594 |
595 void BrowserView::ShowInactive() { | 595 void BrowserView::ShowInactive() { |
596 if (!frame_->IsVisible()) | 596 if (!frame_->IsVisible()) |
597 frame_->ShowInactive(); | 597 frame_->ShowInactive(); |
598 } | 598 } |
599 | 599 |
600 void BrowserView::SetBounds(const gfx::Rect& bounds) { | 600 void BrowserView::SetBounds(const gfx::Rect& bounds) { |
601 SetFullscreen(false); | 601 ExitFullscreen(); |
602 GetWidget()->SetBounds(bounds); | 602 GetWidget()->SetBounds(bounds); |
603 } | 603 } |
604 | 604 |
605 void BrowserView::Close() { | 605 void BrowserView::Close() { |
606 BrowserBubbleHost::Close(); | 606 BrowserBubbleHost::Close(); |
607 | 607 |
608 frame_->Close(); | 608 frame_->Close(); |
609 } | 609 } |
610 | 610 |
611 void BrowserView::Activate() { | 611 void BrowserView::Activate() { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 } | 752 } |
753 | 753 |
754 bool BrowserView::IsMaximized() const { | 754 bool BrowserView::IsMaximized() const { |
755 return frame_->IsMaximized(); | 755 return frame_->IsMaximized(); |
756 } | 756 } |
757 | 757 |
758 bool BrowserView::IsMinimized() const { | 758 bool BrowserView::IsMinimized() const { |
759 return frame_->IsMinimized(); | 759 return frame_->IsMinimized(); |
760 } | 760 } |
761 | 761 |
762 void BrowserView::SetFullscreen(bool fullscreen) { | 762 void BrowserView::EnterFullscreen(const GURL& url, bool ask_permission) { |
763 if (IsFullscreen() == fullscreen) | 763 if (IsFullscreen()) |
764 return; // Nothing to do. | 764 return; // Nothing to do. |
765 | 765 |
766 #if defined(OS_WIN) && !defined(USE_AURA) | 766 #if defined(OS_WIN) |
767 ProcessFullscreen(fullscreen); | 767 ProcessFullscreen(true, url, ask_permission); |
768 #else | 768 #else |
769 // On Linux changing fullscreen is async. Ask the window to change it's | 769 // On Linux changing fullscreen is async. Ask the window to change it's |
770 // fullscreen state, and when done invoke ProcessFullscreen. | 770 // fullscreen state, and when done invoke ProcessFullscreen. |
771 frame_->SetFullscreen(fullscreen); | 771 frame_->SetFullscreen(true); |
772 #endif | 772 #endif |
773 } | 773 } |
774 | 774 |
| 775 void BrowserView::ExitFullscreen() { |
| 776 if (!IsFullscreen()) |
| 777 return; // Nothing to do. |
| 778 |
| 779 #if defined(OS_WIN) |
| 780 ProcessFullscreen(false, GURL(), false); |
| 781 #else |
| 782 // On Linux changing fullscreen is async. Ask the window to change it's |
| 783 // fullscreen state, and when done invoke ProcessFullscreen. |
| 784 frame_->SetFullscreen(false); |
| 785 #endif |
| 786 } |
| 787 |
775 bool BrowserView::IsFullscreen() const { | 788 bool BrowserView::IsFullscreen() const { |
776 return frame_->IsFullscreen(); | 789 return frame_->IsFullscreen(); |
777 } | 790 } |
778 | 791 |
779 bool BrowserView::IsFullscreenBubbleVisible() const { | 792 bool BrowserView::IsFullscreenBubbleVisible() const { |
780 return fullscreen_bubble_.get() ? true : false; | 793 return fullscreen_bubble_.get() ? true : false; |
781 } | 794 } |
782 | 795 |
783 void BrowserView::FullScreenStateChanged() { | 796 void BrowserView::FullScreenStateChanged() { |
784 ProcessFullscreen(IsFullscreen()); | 797 ProcessFullscreen(IsFullscreen(), GURL(), false); |
785 } | 798 } |
786 | 799 |
787 void BrowserView::RestoreFocus() { | 800 void BrowserView::RestoreFocus() { |
788 TabContents* selected_tab_contents = GetSelectedTabContents(); | 801 TabContents* selected_tab_contents = GetSelectedTabContents(); |
789 if (selected_tab_contents) | 802 if (selected_tab_contents) |
790 selected_tab_contents->view()->RestoreFocus(); | 803 selected_tab_contents->view()->RestoreFocus(); |
791 } | 804 } |
792 | 805 |
793 LocationBar* BrowserView::GetLocationBar() const { | 806 LocationBar* BrowserView::GetLocationBar() const { |
794 return GetLocationBarView(); | 807 return GetLocationBarView(); |
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2157 } else if (new_view) { | 2170 } else if (new_view) { |
2158 DCHECK_EQ(0, new_height); | 2171 DCHECK_EQ(0, new_height); |
2159 // The heights are the same, but the old view is null. This only happens | 2172 // The heights are the same, but the old view is null. This only happens |
2160 // when the height is zero. Zero out the bounds. | 2173 // when the height is zero. Zero out the bounds. |
2161 new_view->SetBounds(0, 0, 0, 0); | 2174 new_view->SetBounds(0, 0, 0, 0); |
2162 } | 2175 } |
2163 *old_view = new_view; | 2176 *old_view = new_view; |
2164 return changed; | 2177 return changed; |
2165 } | 2178 } |
2166 | 2179 |
2167 void BrowserView::ProcessFullscreen(bool fullscreen) { | 2180 void BrowserView::ProcessFullscreen(bool fullscreen, |
| 2181 const GURL& url, |
| 2182 bool ask_permission) { |
2168 // Reduce jankiness during the following position changes by: | 2183 // Reduce jankiness during the following position changes by: |
2169 // * Hiding the window until it's in the final position | 2184 // * Hiding the window until it's in the final position |
2170 // * Ignoring all intervening Layout() calls, which resize the webpage and | 2185 // * Ignoring all intervening Layout() calls, which resize the webpage and |
2171 // thus are slow and look ugly | 2186 // thus are slow and look ugly |
2172 ignore_layout_ = true; | 2187 ignore_layout_ = true; |
2173 LocationBarView* location_bar = GetLocationBarView(); | 2188 LocationBarView* location_bar = GetLocationBarView(); |
2174 #if defined(OS_WIN) && !defined(USE_AURA) | 2189 #if defined(OS_WIN) && !defined(USE_AURA) |
2175 OmniboxViewWin* omnibox_view = | 2190 OmniboxViewWin* omnibox_view = |
2176 static_cast<OmniboxViewWin*>(location_bar->location_entry()); | 2191 static_cast<OmniboxViewWin*>(location_bar->location_entry()); |
2177 #endif | 2192 #endif |
(...skipping 28 matching lines...) Expand all Loading... |
2206 frame_->SetFullscreen(fullscreen); | 2221 frame_->SetFullscreen(fullscreen); |
2207 #endif // No need to invoke SetFullscreen for linux as this code is executed | 2222 #endif // No need to invoke SetFullscreen for linux as this code is executed |
2208 // once we're already fullscreen on linux. | 2223 // once we're already fullscreen on linux. |
2209 | 2224 |
2210 browser_->WindowFullscreenStateChanged(); | 2225 browser_->WindowFullscreenStateChanged(); |
2211 | 2226 |
2212 if (fullscreen) { | 2227 if (fullscreen) { |
2213 bool is_kiosk = | 2228 bool is_kiosk = |
2214 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 2229 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
2215 if (!is_kiosk) { | 2230 if (!is_kiosk) { |
2216 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(GetWidget(), | 2231 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( |
2217 browser_.get())); | 2232 GetWidget(), browser_.get(), url, ask_permission)); |
2218 } | 2233 } |
2219 } else { | 2234 } else { |
2220 #if defined(OS_WIN) && !defined(USE_AURA) | 2235 #if defined(OS_WIN) && !defined(USE_AURA) |
2221 // Show the edit again since we're no longer in fullscreen mode. | 2236 // Show the edit again since we're no longer in fullscreen mode. |
2222 omnibox_view->set_force_hidden(false); | 2237 omnibox_view->set_force_hidden(false); |
2223 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); | 2238 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); |
2224 #endif | 2239 #endif |
2225 } | 2240 } |
2226 | 2241 |
2227 // Undo our anti-jankiness hacks and force the window to re-layout now that | 2242 // Undo our anti-jankiness hacks and force the window to re-layout now that |
2228 // it's in its final position. | 2243 // it's in its final position. |
2229 ignore_layout_ = false; | 2244 ignore_layout_ = false; |
2230 Layout(); | 2245 Layout(); |
2231 #if defined(OS_WIN) && !defined(USE_AURA) | 2246 #if defined(OS_WIN) && !defined(USE_AURA) |
2232 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> | 2247 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> |
2233 PopForceHidden(); | 2248 PopForceHidden(); |
2234 #endif | 2249 #endif |
2235 } | 2250 } |
2236 | 2251 |
2237 | |
2238 void BrowserView::LoadAccelerators() { | 2252 void BrowserView::LoadAccelerators() { |
2239 #if defined(USE_AURA) | 2253 #if defined(USE_AURA) |
2240 // TODO(beng): | 2254 // TODO(beng): |
2241 NOTIMPLEMENTED(); | 2255 NOTIMPLEMENTED(); |
2242 #elif defined(OS_WIN) | 2256 #elif defined(OS_WIN) |
2243 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME); | 2257 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME); |
2244 DCHECK(accelerator_table); | 2258 DCHECK(accelerator_table); |
2245 | 2259 |
2246 // We have to copy the table to access its contents. | 2260 // We have to copy the table to access its contents. |
2247 int count = CopyAcceleratorTable(accelerator_table, 0, 0); | 2261 int count = CopyAcceleratorTable(accelerator_table, 0, 0); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2555 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); | 2569 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); |
2556 gfx::Rect bounds; | 2570 gfx::Rect bounds; |
2557 bounds.set_origin(origin); | 2571 bounds.set_origin(origin); |
2558 | 2572 |
2559 AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_.get()); | 2573 AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_.get()); |
2560 // Bubble::Show() takes ownership of the view. | 2574 // Bubble::Show() takes ownership of the view. |
2561 Bubble::Show(this->GetWidget(), bounds, | 2575 Bubble::Show(this->GetWidget(), bounds, |
2562 views::BubbleBorder::TOP_RIGHT, | 2576 views::BubbleBorder::TOP_RIGHT, |
2563 bubble_view, bubble_view); | 2577 bubble_view, bubble_view); |
2564 } | 2578 } |
OLD | NEW |