Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 7740044: Implement fullscreen info bubble on Win and Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 ExitFullscreen();
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
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::EnterFullscreen(const GURL& url, bool ask_permission) {
754 if (IsFullscreen() == fullscreen) 754 if (IsFullscreen())
755 return; // Nothing to do. 755 return; // Nothing to do.
756 756
757 #if defined(OS_WIN) && !defined(USE_AURA) 757 #if defined(OS_WIN)
758 ProcessFullscreen(fullscreen); 758 ProcessFullscreen(true, url, ask_permission);
759 #else 759 #else
760 // On Linux changing fullscreen is async. Ask the window to change it's 760 // On Linux changing fullscreen is async. Ask the window to change it's
761 // fullscreen state, and when done invoke ProcessFullscreen. 761 // fullscreen state, and when done invoke ProcessFullscreen.
762 frame_->SetFullscreen(fullscreen); 762 frame_->SetFullscreen(true);
763 #endif 763 #endif
764 } 764 }
765 765
766 void BrowserView::ExitFullscreen() {
767 if (!IsFullscreen())
768 return; // Nothing to do.
769
770 #if defined(OS_WIN)
771 ProcessFullscreen(false, GURL(), false);
772 #else
773 // On Linux changing fullscreen is async. Ask the window to change it's
774 // fullscreen state, and when done invoke ProcessFullscreen.
775 frame_->SetFullscreen(false);
776 #endif
777 }
778
766 bool BrowserView::IsFullscreen() const { 779 bool BrowserView::IsFullscreen() const {
767 return frame_->IsFullscreen(); 780 return frame_->IsFullscreen();
768 } 781 }
769 782
770 bool BrowserView::IsFullscreenBubbleVisible() const { 783 bool BrowserView::IsFullscreenBubbleVisible() const {
771 return fullscreen_bubble_.get() ? true : false; 784 return fullscreen_bubble_.get() ? true : false;
772 } 785 }
773 786
774 void BrowserView::FullScreenStateChanged() { 787 void BrowserView::FullScreenStateChanged() {
775 ProcessFullscreen(IsFullscreen()); 788 ProcessFullscreen(IsFullscreen(), GURL(), false);
776 } 789 }
777 790
778 void BrowserView::RestoreFocus() { 791 void BrowserView::RestoreFocus() {
779 TabContents* selected_tab_contents = GetSelectedTabContents(); 792 TabContents* selected_tab_contents = GetSelectedTabContents();
780 if (selected_tab_contents) 793 if (selected_tab_contents)
781 selected_tab_contents->view()->RestoreFocus(); 794 selected_tab_contents->view()->RestoreFocus();
782 } 795 }
783 796
784 LocationBar* BrowserView::GetLocationBar() const { 797 LocationBar* BrowserView::GetLocationBar() const {
785 return GetLocationBarView(); 798 return GetLocationBarView();
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 } else if (new_view) { 2158 } else if (new_view) {
2146 DCHECK_EQ(0, new_height); 2159 DCHECK_EQ(0, new_height);
2147 // The heights are the same, but the old view is null. This only happens 2160 // The heights are the same, but the old view is null. This only happens
2148 // when the height is zero. Zero out the bounds. 2161 // when the height is zero. Zero out the bounds.
2149 new_view->SetBounds(0, 0, 0, 0); 2162 new_view->SetBounds(0, 0, 0, 0);
2150 } 2163 }
2151 *old_view = new_view; 2164 *old_view = new_view;
2152 return changed; 2165 return changed;
2153 } 2166 }
2154 2167
2155 void BrowserView::ProcessFullscreen(bool fullscreen) { 2168 void BrowserView::ProcessFullscreen(bool fullscreen,
2169 const GURL& url,
2170 bool ask_permission) {
2156 // Reduce jankiness during the following position changes by: 2171 // Reduce jankiness during the following position changes by:
2157 // * Hiding the window until it's in the final position 2172 // * Hiding the window until it's in the final position
2158 // * Ignoring all intervening Layout() calls, which resize the webpage and 2173 // * Ignoring all intervening Layout() calls, which resize the webpage and
2159 // thus are slow and look ugly 2174 // thus are slow and look ugly
2160 ignore_layout_ = true; 2175 ignore_layout_ = true;
2161 LocationBarView* location_bar = GetLocationBarView(); 2176 LocationBarView* location_bar = GetLocationBarView();
2162 #if defined(OS_WIN) && !defined(USE_AURA) 2177 #if defined(OS_WIN) && !defined(USE_AURA)
2163 OmniboxViewWin* omnibox_view = 2178 OmniboxViewWin* omnibox_view =
2164 static_cast<OmniboxViewWin*>(location_bar->location_entry()); 2179 static_cast<OmniboxViewWin*>(location_bar->location_entry());
2165 #endif 2180 #endif
(...skipping 28 matching lines...) Expand all
2194 frame_->SetFullscreen(fullscreen); 2209 frame_->SetFullscreen(fullscreen);
2195 #endif // No need to invoke SetFullscreen for linux as this code is executed 2210 #endif // No need to invoke SetFullscreen for linux as this code is executed
2196 // once we're already fullscreen on linux. 2211 // once we're already fullscreen on linux.
2197 2212
2198 browser_->WindowFullscreenStateChanged(); 2213 browser_->WindowFullscreenStateChanged();
2199 2214
2200 if (fullscreen) { 2215 if (fullscreen) {
2201 bool is_kiosk = 2216 bool is_kiosk =
2202 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); 2217 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode);
2203 if (!is_kiosk) { 2218 if (!is_kiosk) {
2204 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(GetWidget(), 2219 fullscreen_bubble_.reset(new FullscreenExitBubbleViews(
2205 browser_.get())); 2220 GetWidget(), browser_.get(), url, ask_permission));
2206 } 2221 }
2207 } else { 2222 } else {
2208 #if defined(OS_WIN) && !defined(USE_AURA) 2223 #if defined(OS_WIN) && !defined(USE_AURA)
2209 // Show the edit again since we're no longer in fullscreen mode. 2224 // Show the edit again since we're no longer in fullscreen mode.
2210 omnibox_view->set_force_hidden(false); 2225 omnibox_view->set_force_hidden(false);
2211 ShowWindow(omnibox_view->m_hWnd, SW_SHOW); 2226 ShowWindow(omnibox_view->m_hWnd, SW_SHOW);
2212 #endif 2227 #endif
2213 } 2228 }
2214 2229
2215 // Undo our anti-jankiness hacks and force the window to re-layout now that 2230 // Undo our anti-jankiness hacks and force the window to re-layout now that
2216 // it's in its final position. 2231 // it's in its final position.
2217 ignore_layout_ = false; 2232 ignore_layout_ = false;
2218 Layout(); 2233 Layout();
2219 #if defined(OS_WIN) && !defined(USE_AURA) 2234 #if defined(OS_WIN) && !defined(USE_AURA)
2220 static_cast<views::NativeWidgetWin*>(frame_->native_widget())-> 2235 static_cast<views::NativeWidgetWin*>(frame_->native_widget())->
2221 PopForceHidden(); 2236 PopForceHidden();
2222 #endif 2237 #endif
2223 } 2238 }
2224 2239
2225
2226 void BrowserView::LoadAccelerators() { 2240 void BrowserView::LoadAccelerators() {
2227 #if defined(USE_AURA) 2241 #if defined(USE_AURA)
2228 // TODO(beng): 2242 // TODO(beng):
2229 NOTIMPLEMENTED(); 2243 NOTIMPLEMENTED();
2230 #elif defined(OS_WIN) 2244 #elif defined(OS_WIN)
2231 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME); 2245 HACCEL accelerator_table = AtlLoadAccelerators(IDR_MAINFRAME);
2232 DCHECK(accelerator_table); 2246 DCHECK(accelerator_table);
2233 2247
2234 // We have to copy the table to access its contents. 2248 // We have to copy the table to access its contents.
2235 int count = CopyAcceleratorTable(accelerator_table, 0, 0); 2249 int count = CopyAcceleratorTable(accelerator_table, 0, 0);
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin); 2557 views::View::ConvertPointToScreen(GetTabContentsContainerView(), &origin);
2544 gfx::Rect bounds; 2558 gfx::Rect bounds;
2545 bounds.set_origin(origin); 2559 bounds.set_origin(origin);
2546 2560
2547 AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_.get()); 2561 AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_.get());
2548 // Bubble::Show() takes ownership of the view. 2562 // Bubble::Show() takes ownership of the view.
2549 Bubble::Show(this->GetWidget(), bounds, 2563 Bubble::Show(this->GetWidget(), bounds,
2550 views::BubbleBorder::TOP_RIGHT, 2564 views::BubbleBorder::TOP_RIGHT,
2551 bubble_view, bubble_view); 2565 bubble_view, bubble_view);
2552 } 2566 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698