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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 | 589 |
590 browser()->OnWindowDidShow(); | 590 browser()->OnWindowDidShow(); |
591 } | 591 } |
592 | 592 |
593 void BrowserView::ShowInactive() { | 593 void BrowserView::ShowInactive() { |
594 if (!frame_->IsVisible()) | 594 if (!frame_->IsVisible()) |
595 frame_->ShowInactive(); | 595 frame_->ShowInactive(); |
596 } | 596 } |
597 | 597 |
598 void BrowserView::SetBounds(const gfx::Rect& bounds) { | 598 void BrowserView::SetBounds(const gfx::Rect& bounds) { |
599 SetFullscreen(false); | 599 SetFullscreen(false, GURL(), false); |
600 GetWidget()->SetBounds(bounds); | 600 GetWidget()->SetBounds(bounds); |
601 } | 601 } |
602 | 602 |
603 void BrowserView::Close() { | 603 void BrowserView::Close() { |
604 BrowserBubbleHost::Close(); | 604 BrowserBubbleHost::Close(); |
605 | 605 |
606 frame_->Close(); | 606 frame_->Close(); |
607 } | 607 } |
608 | 608 |
609 void BrowserView::Activate() { | 609 void BrowserView::Activate() { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 } | 750 } |
751 | 751 |
752 bool BrowserView::IsMaximized() const { | 752 bool BrowserView::IsMaximized() const { |
753 return frame_->IsMaximized(); | 753 return frame_->IsMaximized(); |
754 } | 754 } |
755 | 755 |
756 bool BrowserView::IsMinimized() const { | 756 bool BrowserView::IsMinimized() const { |
757 return frame_->IsMinimized(); | 757 return frame_->IsMinimized(); |
758 } | 758 } |
759 | 759 |
760 void BrowserView::SetFullscreen(bool fullscreen) { | 760 void BrowserView::SetFullscreen(bool fullscreen, const GURL& url, bool show_butt
ons) { |
761 if (IsFullscreen() == fullscreen) | 761 if (IsFullscreen() == fullscreen) |
762 return; // Nothing to do. | 762 return; // Nothing to do. |
763 | 763 |
764 #if defined(OS_WIN) && !defined(USE_AURA) | 764 #if defined(OS_WIN) |
765 ProcessFullscreen(fullscreen); | 765 ProcessFullscreen(fullscreen, url, show_buttons); |
766 #else | 766 #else |
767 // On Linux changing fullscreen is async. Ask the window to change it's | 767 // On Linux changing fullscreen is async. Ask the window to change it's |
768 // fullscreen state, and when done invoke ProcessFullscreen. | 768 // fullscreen state, and when done invoke ProcessFullscreen. |
769 frame_->SetFullscreen(fullscreen); | 769 frame_->SetFullscreen(fullscreen); |
770 #endif | 770 #endif |
771 } | 771 } |
772 | 772 |
773 bool BrowserView::IsFullscreen() const { | 773 bool BrowserView::IsFullscreen() const { |
774 return frame_->IsFullscreen(); | 774 return frame_->IsFullscreen(); |
775 } | 775 } |
776 | 776 |
777 bool BrowserView::IsFullscreenBubbleVisible() const { | 777 bool BrowserView::IsFullscreenBubbleVisible() const { |
778 return fullscreen_bubble_.get() ? true : false; | 778 return fullscreen_bubble_.get() ? true : false; |
779 } | 779 } |
780 | 780 |
781 void BrowserView::FullScreenStateChanged() { | 781 void BrowserView::FullScreenStateChanged() { |
782 ProcessFullscreen(IsFullscreen()); | 782 ProcessFullscreen(IsFullscreen(), GURL(), false); |
783 } | 783 } |
784 | 784 |
785 void BrowserView::RestoreFocus() { | 785 void BrowserView::RestoreFocus() { |
786 TabContents* selected_tab_contents = GetSelectedTabContents(); | 786 TabContents* selected_tab_contents = GetSelectedTabContents(); |
787 if (selected_tab_contents) | 787 if (selected_tab_contents) |
788 selected_tab_contents->view()->RestoreFocus(); | 788 selected_tab_contents->view()->RestoreFocus(); |
789 } | 789 } |
790 | 790 |
791 LocationBar* BrowserView::GetLocationBar() const { | 791 LocationBar* BrowserView::GetLocationBar() const { |
792 return GetLocationBarView(); | 792 return GetLocationBarView(); |
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 } else if (new_view) { | 2174 } else if (new_view) { |
2175 DCHECK_EQ(0, new_height); | 2175 DCHECK_EQ(0, new_height); |
2176 // The heights are the same, but the old view is null. This only happens | 2176 // The heights are the same, but the old view is null. This only happens |
2177 // when the height is zero. Zero out the bounds. | 2177 // when the height is zero. Zero out the bounds. |
2178 new_view->SetBounds(0, 0, 0, 0); | 2178 new_view->SetBounds(0, 0, 0, 0); |
2179 } | 2179 } |
2180 *old_view = new_view; | 2180 *old_view = new_view; |
2181 return changed; | 2181 return changed; |
2182 } | 2182 } |
2183 | 2183 |
2184 void BrowserView::ProcessFullscreen(bool fullscreen) { | 2184 void BrowserView::ProcessFullscreen(bool fullscreen, const GURL& url, bool show_
buttons) { |
2185 // Reduce jankiness during the following position changes by: | 2185 // Reduce jankiness during the following position changes by: |
2186 // * Hiding the window until it's in the final position | 2186 // * Hiding the window until it's in the final position |
2187 // * Ignoring all intervening Layout() calls, which resize the webpage and | 2187 // * Ignoring all intervening Layout() calls, which resize the webpage and |
2188 // thus are slow and look ugly | 2188 // thus are slow and look ugly |
2189 ignore_layout_ = true; | 2189 ignore_layout_ = true; |
2190 LocationBarView* location_bar = GetLocationBarView(); | 2190 LocationBarView* location_bar = GetLocationBarView(); |
2191 #if defined(OS_WIN) && !defined(USE_AURA) | 2191 #if defined(OS_WIN) && !defined(USE_AURA) |
2192 OmniboxViewWin* omnibox_view = | 2192 OmniboxViewWin* omnibox_view = |
2193 static_cast<OmniboxViewWin*>(location_bar->location_entry()); | 2193 static_cast<OmniboxViewWin*>(location_bar->location_entry()); |
2194 #endif | 2194 #endif |
(...skipping 29 matching lines...) Expand all Loading... |
2224 #endif // No need to invoke SetFullscreen for linux as this code is executed | 2224 #endif // No need to invoke SetFullscreen for linux as this code is executed |
2225 // once we're already fullscreen on linux. | 2225 // once we're already fullscreen on linux. |
2226 | 2226 |
2227 browser_->WindowFullscreenStateChanged(); | 2227 browser_->WindowFullscreenStateChanged(); |
2228 | 2228 |
2229 if (fullscreen) { | 2229 if (fullscreen) { |
2230 bool is_kiosk = | 2230 bool is_kiosk = |
2231 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 2231 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
2232 if (!is_kiosk) { | 2232 if (!is_kiosk) { |
2233 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(GetWidget(), | 2233 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(GetWidget(), |
2234 browser_.get())); | 2234 browser_.get(), |
| 2235 url, |
| 2236 show_buttons)); |
2235 } | 2237 } |
2236 } else { | 2238 } else { |
2237 #if defined(OS_WIN) && !defined(USE_AURA) | 2239 #if defined(OS_WIN) && !defined(USE_AURA) |
2238 // Show the edit again since we're no longer in fullscreen mode. | 2240 // Show the edit again since we're no longer in fullscreen mode. |
2239 omnibox_view->set_force_hidden(false); | 2241 omnibox_view->set_force_hidden(false); |
2240 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); | 2242 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); |
2241 #endif | 2243 #endif |
2242 } | 2244 } |
2243 | 2245 |
2244 // Undo our anti-jankiness hacks and force the window to re-layout now that | 2246 // Undo our anti-jankiness hacks and force the window to re-layout now that |
2245 // it's in its final position. | 2247 // it's in its final position. |
2246 ignore_layout_ = false; | 2248 ignore_layout_ = false; |
2247 Layout(); | 2249 Layout(); |
2248 #if defined(OS_WIN) && !defined(USE_AURA) | 2250 #if defined(OS_WIN) && !defined(USE_AURA) |
2249 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> | 2251 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> |
2250 PopForceHidden(); | 2252 PopForceHidden(); |
2251 #endif | 2253 #endif |
2252 } | 2254 } |
2253 | 2255 |
2254 | |
2255 void BrowserView::LoadAccelerators() { | 2256 void BrowserView::LoadAccelerators() { |
2256 #if defined(USE_AURA) | 2257 #if defined(USE_AURA) |
2257 // TODO(beng): | 2258 // TODO(beng): |
2258 NOTIMPLEMENTED(); | 2259 NOTIMPLEMENTED(); |
2259 #elif defined(OS_WIN) | 2260 #elif defined(OS_WIN) |
2260 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME); | 2261 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME); |
2261 DCHECK(accelerator_table); | 2262 DCHECK(accelerator_table); |
2262 | 2263 |
2263 // We have to copy the table to access its contents. | 2264 // We have to copy the table to access its contents. |
2264 int count = CopyAcceleratorTable(accelerator_table, 0, 0); | 2265 int count = CopyAcceleratorTable(accelerator_table, 0, 0); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2558 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2559 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
2559 // Create the view and the frame. The frame will attach itself via the view | 2560 // Create the view and the frame. The frame will attach itself via the view |
2560 // so we don't need to do anything with the pointer. | 2561 // so we don't need to do anything with the pointer. |
2561 BrowserView* view = new BrowserView(browser); | 2562 BrowserView* view = new BrowserView(browser); |
2562 (new BrowserFrame(view))->InitBrowserFrame(); | 2563 (new BrowserFrame(view))->InitBrowserFrame(); |
2563 view->GetWidget()->non_client_view()->SetAccessibleName( | 2564 view->GetWidget()->non_client_view()->SetAccessibleName( |
2564 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 2565 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
2565 return view; | 2566 return view; |
2566 } | 2567 } |
2567 #endif | 2568 #endif |
OLD | NEW |