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, const GURL& url, |
Peter Kasting
2011/10/11 23:08:32
Nit: One arg per line, aligned
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
754 bool ask_permission) { | |
754 if (IsFullscreen() == fullscreen) | 755 if (IsFullscreen() == fullscreen) |
755 return; // Nothing to do. | 756 return; // Nothing to do. |
756 | 757 |
757 #if defined(OS_WIN) && !defined(USE_AURA) | 758 #if defined(OS_WIN) |
758 ProcessFullscreen(fullscreen); | 759 ProcessFullscreen(fullscreen, url, ask_permission); |
759 #else | 760 #else |
760 // On Linux changing fullscreen is async. Ask the window to change it's | 761 // On Linux changing fullscreen is async. Ask the window to change it's |
761 // fullscreen state, and when done invoke ProcessFullscreen. | 762 // fullscreen state, and when done invoke ProcessFullscreen. |
762 frame_->SetFullscreen(fullscreen); | 763 frame_->SetFullscreen(fullscreen); |
763 #endif | 764 #endif |
764 } | 765 } |
765 | 766 |
766 bool BrowserView::IsFullscreen() const { | 767 bool BrowserView::IsFullscreen() const { |
767 return frame_->IsFullscreen(); | 768 return frame_->IsFullscreen(); |
768 } | 769 } |
769 | 770 |
770 bool BrowserView::IsFullscreenBubbleVisible() const { | 771 bool BrowserView::IsFullscreenBubbleVisible() const { |
771 return fullscreen_bubble_.get() ? true : false; | 772 return fullscreen_bubble_.get() ? true : false; |
772 } | 773 } |
773 | 774 |
774 void BrowserView::FullScreenStateChanged() { | 775 void BrowserView::FullScreenStateChanged() { |
775 ProcessFullscreen(IsFullscreen()); | 776 ProcessFullscreen(IsFullscreen(), GURL(), false); |
776 } | 777 } |
777 | 778 |
778 void BrowserView::RestoreFocus() { | 779 void BrowserView::RestoreFocus() { |
779 TabContents* selected_tab_contents = GetSelectedTabContents(); | 780 TabContents* selected_tab_contents = GetSelectedTabContents(); |
780 if (selected_tab_contents) | 781 if (selected_tab_contents) |
781 selected_tab_contents->view()->RestoreFocus(); | 782 selected_tab_contents->view()->RestoreFocus(); |
782 } | 783 } |
783 | 784 |
784 LocationBar* BrowserView::GetLocationBar() const { | 785 LocationBar* BrowserView::GetLocationBar() const { |
785 return GetLocationBarView(); | 786 return GetLocationBarView(); |
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2159 } else if (new_view) { | 2160 } else if (new_view) { |
2160 DCHECK_EQ(0, new_height); | 2161 DCHECK_EQ(0, new_height); |
2161 // The heights are the same, but the old view is null. This only happens | 2162 // The heights are the same, but the old view is null. This only happens |
2162 // when the height is zero. Zero out the bounds. | 2163 // when the height is zero. Zero out the bounds. |
2163 new_view->SetBounds(0, 0, 0, 0); | 2164 new_view->SetBounds(0, 0, 0, 0); |
2164 } | 2165 } |
2165 *old_view = new_view; | 2166 *old_view = new_view; |
2166 return changed; | 2167 return changed; |
2167 } | 2168 } |
2168 | 2169 |
2169 void BrowserView::ProcessFullscreen(bool fullscreen) { | 2170 void BrowserView::ProcessFullscreen(bool fullscreen, const GURL& url, |
Peter Kasting
2011/10/11 23:08:32
Nit: One arg per line, aligned
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
2171 bool ask_permission) { | |
2170 // Reduce jankiness during the following position changes by: | 2172 // Reduce jankiness during the following position changes by: |
2171 // * Hiding the window until it's in the final position | 2173 // * Hiding the window until it's in the final position |
2172 // * Ignoring all intervening Layout() calls, which resize the webpage and | 2174 // * Ignoring all intervening Layout() calls, which resize the webpage and |
2173 // thus are slow and look ugly | 2175 // thus are slow and look ugly |
2174 ignore_layout_ = true; | 2176 ignore_layout_ = true; |
2175 LocationBarView* location_bar = GetLocationBarView(); | 2177 LocationBarView* location_bar = GetLocationBarView(); |
2176 #if defined(OS_WIN) && !defined(USE_AURA) | 2178 #if defined(OS_WIN) && !defined(USE_AURA) |
2177 OmniboxViewWin* omnibox_view = | 2179 OmniboxViewWin* omnibox_view = |
2178 static_cast<OmniboxViewWin*>(location_bar->location_entry()); | 2180 static_cast<OmniboxViewWin*>(location_bar->location_entry()); |
2179 #endif | 2181 #endif |
(...skipping 29 matching lines...) Expand all Loading... | |
2209 #endif // No need to invoke SetFullscreen for linux as this code is executed | 2211 #endif // No need to invoke SetFullscreen for linux as this code is executed |
2210 // once we're already fullscreen on linux. | 2212 // once we're already fullscreen on linux. |
2211 | 2213 |
2212 browser_->WindowFullscreenStateChanged(); | 2214 browser_->WindowFullscreenStateChanged(); |
2213 | 2215 |
2214 if (fullscreen) { | 2216 if (fullscreen) { |
2215 bool is_kiosk = | 2217 bool is_kiosk = |
2216 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 2218 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
2217 if (!is_kiosk) { | 2219 if (!is_kiosk) { |
2218 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(GetWidget(), | 2220 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(GetWidget(), |
2219 browser_.get())); | 2221 browser_.get(), |
Peter Kasting
2011/10/11 23:08:32
Nit: I'd just put all these on one line and indent
koz (OOO until 15th September)
2011/10/12 05:38:23
Done.
| |
2222 url, | |
2223 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 |