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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 582 |
583 browser()->OnWindowDidShow(); | 583 browser()->OnWindowDidShow(); |
584 } | 584 } |
585 | 585 |
586 void BrowserView::ShowInactive() { | 586 void BrowserView::ShowInactive() { |
587 if (!frame_->IsVisible()) | 587 if (!frame_->IsVisible()) |
588 frame_->ShowInactive(); | 588 frame_->ShowInactive(); |
589 } | 589 } |
590 | 590 |
591 void BrowserView::SetBounds(const gfx::Rect& bounds) { | 591 void BrowserView::SetBounds(const gfx::Rect& bounds) { |
592 SetFullscreen(false); | 592 SetFullscreen(false, GURL(), false); |
593 GetWidget()->SetBounds(bounds); | 593 GetWidget()->SetBounds(bounds); |
594 } | 594 } |
595 | 595 |
596 void BrowserView::Close() { | 596 void BrowserView::Close() { |
597 BrowserBubbleHost::Close(); | 597 BrowserBubbleHost::Close(); |
598 | 598 |
599 frame_->Close(); | 599 frame_->Close(); |
600 } | 600 } |
601 | 601 |
602 void BrowserView::Activate() { | 602 void BrowserView::Activate() { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 } | 743 } |
744 | 744 |
745 bool BrowserView::IsMaximized() const { | 745 bool BrowserView::IsMaximized() const { |
746 return frame_->IsMaximized(); | 746 return frame_->IsMaximized(); |
747 } | 747 } |
748 | 748 |
749 bool BrowserView::IsMinimized() const { | 749 bool BrowserView::IsMinimized() const { |
750 return frame_->IsMinimized(); | 750 return frame_->IsMinimized(); |
751 } | 751 } |
752 | 752 |
753 void BrowserView::SetFullscreen(bool fullscreen) { | 753 void BrowserView::SetFullscreen(bool fullscreen, |
| 754 const GURL& url, |
| 755 bool ask_permission) { |
754 if (IsFullscreen() == fullscreen) | 756 if (IsFullscreen() == fullscreen) |
755 return; // Nothing to do. | 757 return; // Nothing to do. |
756 | 758 |
757 #if defined(OS_WIN) && !defined(USE_AURA) | 759 #if defined(OS_WIN) |
758 ProcessFullscreen(fullscreen); | 760 ProcessFullscreen(fullscreen, url, ask_permission); |
759 #else | 761 #else |
760 // On Linux changing fullscreen is async. Ask the window to change it's | 762 // On Linux changing fullscreen is async. Ask the window to change it's |
761 // fullscreen state, and when done invoke ProcessFullscreen. | 763 // fullscreen state, and when done invoke ProcessFullscreen. |
762 frame_->SetFullscreen(fullscreen); | 764 frame_->SetFullscreen(fullscreen); |
763 #endif | 765 #endif |
764 } | 766 } |
765 | 767 |
766 bool BrowserView::IsFullscreen() const { | 768 bool BrowserView::IsFullscreen() const { |
767 return frame_->IsFullscreen(); | 769 return frame_->IsFullscreen(); |
768 } | 770 } |
769 | 771 |
770 bool BrowserView::IsFullscreenBubbleVisible() const { | 772 bool BrowserView::IsFullscreenBubbleVisible() const { |
771 return fullscreen_bubble_.get() ? true : false; | 773 return fullscreen_bubble_.get() ? true : false; |
772 } | 774 } |
773 | 775 |
774 void BrowserView::FullScreenStateChanged() { | 776 void BrowserView::FullScreenStateChanged() { |
775 ProcessFullscreen(IsFullscreen()); | 777 ProcessFullscreen(IsFullscreen(), GURL(), false); |
776 } | 778 } |
777 | 779 |
778 void BrowserView::RestoreFocus() { | 780 void BrowserView::RestoreFocus() { |
779 TabContents* selected_tab_contents = GetSelectedTabContents(); | 781 TabContents* selected_tab_contents = GetSelectedTabContents(); |
780 if (selected_tab_contents) | 782 if (selected_tab_contents) |
781 selected_tab_contents->view()->RestoreFocus(); | 783 selected_tab_contents->view()->RestoreFocus(); |
782 } | 784 } |
783 | 785 |
784 LocationBar* BrowserView::GetLocationBar() const { | 786 LocationBar* BrowserView::GetLocationBar() const { |
785 return GetLocationBarView(); | 787 return GetLocationBarView(); |
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2159 } else if (new_view) { | 2161 } else if (new_view) { |
2160 DCHECK_EQ(0, new_height); | 2162 DCHECK_EQ(0, new_height); |
2161 // The heights are the same, but the old view is null. This only happens | 2163 // The heights are the same, but the old view is null. This only happens |
2162 // when the height is zero. Zero out the bounds. | 2164 // when the height is zero. Zero out the bounds. |
2163 new_view->SetBounds(0, 0, 0, 0); | 2165 new_view->SetBounds(0, 0, 0, 0); |
2164 } | 2166 } |
2165 *old_view = new_view; | 2167 *old_view = new_view; |
2166 return changed; | 2168 return changed; |
2167 } | 2169 } |
2168 | 2170 |
2169 void BrowserView::ProcessFullscreen(bool fullscreen) { | 2171 void BrowserView::ProcessFullscreen(bool fullscreen, |
| 2172 const GURL& url, |
| 2173 bool ask_permission) { |
2170 // Reduce jankiness during the following position changes by: | 2174 // Reduce jankiness during the following position changes by: |
2171 // * Hiding the window until it's in the final position | 2175 // * Hiding the window until it's in the final position |
2172 // * Ignoring all intervening Layout() calls, which resize the webpage and | 2176 // * Ignoring all intervening Layout() calls, which resize the webpage and |
2173 // thus are slow and look ugly | 2177 // thus are slow and look ugly |
2174 ignore_layout_ = true; | 2178 ignore_layout_ = true; |
2175 LocationBarView* location_bar = GetLocationBarView(); | 2179 LocationBarView* location_bar = GetLocationBarView(); |
2176 #if defined(OS_WIN) && !defined(USE_AURA) | 2180 #if defined(OS_WIN) && !defined(USE_AURA) |
2177 OmniboxViewWin* omnibox_view = | 2181 OmniboxViewWin* omnibox_view = |
2178 static_cast<OmniboxViewWin*>(location_bar->location_entry()); | 2182 static_cast<OmniboxViewWin*>(location_bar->location_entry()); |
2179 #endif | 2183 #endif |
(...skipping 28 matching lines...) Expand all Loading... |
2208 frame_->SetFullscreen(fullscreen); | 2212 frame_->SetFullscreen(fullscreen); |
2209 #endif // No need to invoke SetFullscreen for linux as this code is executed | 2213 #endif // No need to invoke SetFullscreen for linux as this code is executed |
2210 // once we're already fullscreen on linux. | 2214 // once we're already fullscreen on linux. |
2211 | 2215 |
2212 browser_->WindowFullscreenStateChanged(); | 2216 browser_->WindowFullscreenStateChanged(); |
2213 | 2217 |
2214 if (fullscreen) { | 2218 if (fullscreen) { |
2215 bool is_kiosk = | 2219 bool is_kiosk = |
2216 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 2220 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
2217 if (!is_kiosk) { | 2221 if (!is_kiosk) { |
2218 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(GetWidget(), | 2222 fullscreen_bubble_.reset(new FullscreenExitBubbleViews( |
2219 browser_.get())); | 2223 GetWidget(), browser_.get(), url, ask_permission)); |
2220 } | 2224 } |
2221 } else { | 2225 } else { |
2222 #if defined(OS_WIN) && !defined(USE_AURA) | 2226 #if defined(OS_WIN) && !defined(USE_AURA) |
2223 // Show the edit again since we're no longer in fullscreen mode. | 2227 // Show the edit again since we're no longer in fullscreen mode. |
2224 omnibox_view->set_force_hidden(false); | 2228 omnibox_view->set_force_hidden(false); |
2225 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); | 2229 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); |
2226 #endif | 2230 #endif |
2227 } | 2231 } |
2228 | 2232 |
2229 // Undo our anti-jankiness hacks and force the window to re-layout now that | 2233 // Undo our anti-jankiness hacks and force the window to re-layout now that |
2230 // it's in its final position. | 2234 // it's in its final position. |
2231 ignore_layout_ = false; | 2235 ignore_layout_ = false; |
2232 Layout(); | 2236 Layout(); |
2233 #if defined(OS_WIN) && !defined(USE_AURA) | 2237 #if defined(OS_WIN) && !defined(USE_AURA) |
2234 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> | 2238 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> |
2235 PopForceHidden(); | 2239 PopForceHidden(); |
2236 #endif | 2240 #endif |
2237 } | 2241 } |
2238 | 2242 |
2239 | |
2240 void BrowserView::LoadAccelerators() { | 2243 void BrowserView::LoadAccelerators() { |
2241 #if defined(USE_AURA) | 2244 #if defined(USE_AURA) |
2242 // TODO(beng): | 2245 // TODO(beng): |
2243 NOTIMPLEMENTED(); | 2246 NOTIMPLEMENTED(); |
2244 #elif defined(OS_WIN) | 2247 #elif defined(OS_WIN) |
2245 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME); | 2248 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME); |
2246 DCHECK(accelerator_table); | 2249 DCHECK(accelerator_table); |
2247 | 2250 |
2248 // We have to copy the table to access its contents. | 2251 // We have to copy the table to access its contents. |
2249 int count = CopyAcceleratorTable(accelerator_table, 0, 0); | 2252 int count = CopyAcceleratorTable(accelerator_table, 0, 0); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2557 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); | 2560 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); |
2558 gfx::Rect bounds; | 2561 gfx::Rect bounds; |
2559 bounds.set_origin(origin); | 2562 bounds.set_origin(origin); |
2560 | 2563 |
2561 AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_.get()); | 2564 AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_.get()); |
2562 // Bubble::Show() takes ownership of the view. | 2565 // Bubble::Show() takes ownership of the view. |
2563 Bubble::Show(this->GetWidget(), bounds, | 2566 Bubble::Show(this->GetWidget(), bounds, |
2564 views::BubbleBorder::TOP_RIGHT, | 2567 views::BubbleBorder::TOP_RIGHT, |
2565 bubble_view, bubble_view); | 2568 bubble_view, bubble_view); |
2566 } | 2569 } |
OLD | NEW |