diff options
28 files changed, 563 insertions, 117 deletions
diff --git a/apps/shell_window.cc b/apps/shell_window.cc index 5e4098f..2c0b3fac 100644 --- a/apps/shell_window.cc +++ b/apps/shell_window.cc @@ -141,8 +141,7 @@ ShellWindow::ShellWindow(Profile* profile, window_type_(WINDOW_TYPE_DEFAULT), delegate_(delegate), image_loader_ptr_factory_(this), - fullscreen_for_window_api_(false), - fullscreen_for_tab_(false), + fullscreen_types_(FULLSCREEN_TYPE_NONE), show_on_first_paint_(false), first_paint_complete_(false) { } @@ -404,8 +403,8 @@ void ShellWindow::Fullscreen() { if (!profile()->GetPrefs()->GetBoolean(prefs::kAppFullscreenAllowed)) return; #endif - fullscreen_for_window_api_ = true; - GetBaseWindow()->SetFullscreen(true); + fullscreen_types_ |= FULLSCREEN_TYPE_WINDOW_API; + GetBaseWindow()->SetFullscreen(fullscreen_types_); } void ShellWindow::Maximize() { @@ -417,15 +416,24 @@ void ShellWindow::Minimize() { } void ShellWindow::Restore() { - fullscreen_for_window_api_ = false; - fullscreen_for_tab_ = false; - if (GetBaseWindow()->IsFullscreenOrPending()) { - GetBaseWindow()->SetFullscreen(false); + if (fullscreen_types_ != FULLSCREEN_TYPE_NONE) { + fullscreen_types_ = FULLSCREEN_TYPE_NONE; + GetBaseWindow()->SetFullscreen(fullscreen_types_); } else { GetBaseWindow()->Restore(); } } +void ShellWindow::OSFullscreen() { +#if !defined(OS_MACOSX) + // Do not enter fullscreen mode if disallowed by pref. + if (!profile()->GetPrefs()->GetBoolean(prefs::kAppFullscreenAllowed)) + return; +#endif + fullscreen_types_ |= FULLSCREEN_TYPE_OS; + GetBaseWindow()->SetFullscreen(fullscreen_types_); +} + void ShellWindow::SetMinimumSize(const gfx::Size& min_size) { size_constraints_.set_minimum_size(min_size); OnSizeConstraintsChanged(); @@ -585,18 +593,16 @@ void ShellWindow::ToggleFullscreenModeForTab(content::WebContents* source, return; } - fullscreen_for_tab_ = enter_fullscreen; - - if (enter_fullscreen) { - native_app_window_->SetFullscreen(true); - } else if (!fullscreen_for_window_api_) { - native_app_window_->SetFullscreen(false); - } + if (enter_fullscreen) + fullscreen_types_ |= FULLSCREEN_TYPE_HTML_API; + else + fullscreen_types_ &= ~FULLSCREEN_TYPE_HTML_API; + GetBaseWindow()->SetFullscreen(fullscreen_types_); } bool ShellWindow::IsFullscreenForTabOrPending( const content::WebContents* source) const { - return fullscreen_for_tab_; + return ((fullscreen_types_ & FULLSCREEN_TYPE_HTML_API) != 0); } void ShellWindow::Observe(int type, diff --git a/apps/shell_window.h b/apps/shell_window.h index c236a1d..9890038 100644 --- a/apps/shell_window.h +++ b/apps/shell_window.h @@ -92,6 +92,21 @@ class ShellWindow : public content::NotificationObserver, FRAME_NONE, // Frameless window. }; + enum FullscreenType { + // Not fullscreen. + FULLSCREEN_TYPE_NONE = 0, + + // Fullscreen entered by the app.window api. + FULLSCREEN_TYPE_WINDOW_API = 1 << 0, + + // Fullscreen entered by HTML requestFullscreen(). + FULLSCREEN_TYPE_HTML_API = 1 << 1, + + // Fullscreen entered by the OS. ChromeOS uses this type of fullscreen to + // enter immersive fullscreen when the user hits the <F4> key. + FULLSCREEN_TYPE_OS = 1 << 2 + }; + class SizeConstraints { public: // The value SizeConstraints uses to represent an unbounded width or height. @@ -284,6 +299,9 @@ class ShellWindow : public content::NotificationObserver, void Minimize(); void Restore(); + // Transitions to OS fullscreen. See FULLSCREEN_TYPE_OS for more details. + void OSFullscreen(); + // Set the minimum and maximum size that this window is allowed to be. void SetMinimumSize(const gfx::Size& min_size); void SetMaximumSize(const gfx::Size& max_size); @@ -444,10 +462,8 @@ class ShellWindow : public content::NotificationObserver, base::WeakPtrFactory<ShellWindow> image_loader_ptr_factory_; - // Fullscreen entered by app.window api. - bool fullscreen_for_window_api_; - // Fullscreen entered by HTML requestFullscreen. - bool fullscreen_for_tab_; + // Bit field of FullscreenType. + int fullscreen_types_; // Size constraints on the window. SizeConstraints size_constraints_; diff --git a/apps/ui/native_app_window.h b/apps/ui/native_app_window.h index 222a680..73f6f88 100644 --- a/apps/ui/native_app_window.h +++ b/apps/ui/native_app_window.h @@ -18,8 +18,11 @@ namespace apps { class NativeAppWindow : public ui::BaseWindow, public web_modal::WebContentsModalDialogHost { public: - // Fullscreen changes may be asynchronous on some platforms. - virtual void SetFullscreen(bool fullscreen) = 0; + // Sets whether the window is fullscreen and the type of fullscreen. + // |fullscreen_types| is a bit field of ShellWindow::FullscreenType. + virtual void SetFullscreen(int fullscreen_types) = 0; + + // Returns whether the window is fullscreen or about to enter fullscreen. virtual bool IsFullscreenOrPending() const = 0; // Returns true if the window is a panel that has been detached. diff --git a/ash/ash.gyp b/ash/ash.gyp index 3331bef..c9900cb 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -428,6 +428,7 @@ 'wm/caption_buttons/frame_caption_button_container_view.h', 'wm/caption_buttons/frame_maximize_button.cc', 'wm/caption_buttons/frame_maximize_button.h', + 'wm/caption_buttons/frame_maximize_button_observer.h', 'wm/caption_buttons/maximize_bubble_controller.cc', 'wm/caption_buttons/maximize_bubble_controller.h', 'wm/caption_buttons/maximize_bubble_frame_state.h', diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc index 039a0a0..88f569d 100644 --- a/ash/ash_switches.cc +++ b/ash/ash_switches.cc @@ -99,6 +99,10 @@ const char kAshDisableDockedWindows[] = "ash-disable-docked-windows"; // Disable dragging items off the shelf to unpin them. const char kAshDisableDragOffShelf[] = "ash-disable-drag-off-shelf"; +// Enables putting all windows into immersive fullscreen via <F4>. +const char kAshEnableImmersiveFullscreenForAllWindows[] = + "ash-enable-immersive-all-windows"; + #if defined(OS_CHROMEOS) // Enables the "full multi profile mode" - as it was in M-31. const char kAshEnableFullMultiProfileMode[] = diff --git a/ash/ash_switches.h b/ash/ash_switches.h index ed9e413..3a9cff8 100644 --- a/ash/ash_switches.h +++ b/ash/ash_switches.h @@ -43,6 +43,7 @@ ASH_EXPORT extern const char kAshEnableAudioDeviceMenu[]; ASH_EXPORT extern const char kAshEnableAdvancedGestures[]; ASH_EXPORT extern const char kAshEnableAlternateFrameCaptionButtonStyle[]; ASH_EXPORT extern const char kAshEnableBrightnessControl[]; +ASH_EXPORT extern const char kAshEnableImmersiveFullscreenForAllWindows[]; #if defined(OS_CHROMEOS) ASH_EXPORT extern const char kAshEnableFullMultiProfileMode[]; #endif diff --git a/ash/wm/caption_buttons/frame_caption_button_container_view.cc b/ash/wm/caption_buttons/frame_caption_button_container_view.cc index d0b0b96..41f9e08 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view.cc +++ b/ash/wm/caption_buttons/frame_caption_button_container_view.cc @@ -114,6 +114,12 @@ FrameCaptionButtonContainerView::FrameCaptionButtonContainerView( FrameCaptionButtonContainerView::~FrameCaptionButtonContainerView() { } +FrameMaximizeButton* +FrameCaptionButtonContainerView::GetOldStyleSizeButton() { + return switches::UseAlternateFrameCaptionButtonStyle() ? + NULL : static_cast<FrameMaximizeButton*>(size_button_); +} + void FrameCaptionButtonContainerView::ResetWindowControls() { minimize_button_->SetState(views::CustomButton::STATE_NORMAL); size_button_->SetState(views::CustomButton::STATE_NORMAL); diff --git a/ash/wm/caption_buttons/frame_caption_button_container_view.h b/ash/wm/caption_buttons/frame_caption_button_container_view.h index a88ea94..6dd9521 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view.h +++ b/ash/wm/caption_buttons/frame_caption_button_container_view.h @@ -16,6 +16,7 @@ class Widget; } namespace ash { +class FrameMaximizeButton; // Container view for the frame caption buttons. It performs the appropriate // action when a caption button is clicked. @@ -74,6 +75,10 @@ class ASH_EXPORT FrameCaptionButtonContainerView DISALLOW_COPY_AND_ASSIGN(TestApi); }; + // Returns the size button if using the old caption button style, returns NULL + // otherwise. + FrameMaximizeButton* GetOldStyleSizeButton(); + // Tell the window controls to reset themselves to the normal state. void ResetWindowControls(); diff --git a/ash/wm/caption_buttons/frame_maximize_button.cc b/ash/wm/caption_buttons/frame_maximize_button.cc index 81995c2..14526a0 100644 --- a/ash/wm/caption_buttons/frame_maximize_button.cc +++ b/ash/wm/caption_buttons/frame_maximize_button.cc @@ -10,6 +10,7 @@ #include "ash/shell.h" #include "ash/shell_delegate.h" #include "ash/touch/touch_uma.h" +#include "ash/wm/caption_buttons/frame_maximize_button_observer.h" #include "ash/wm/caption_buttons/maximize_bubble_controller.h" #include "ash/wm/window_animations.h" #include "ash/wm/window_state.h" @@ -101,6 +102,15 @@ FrameMaximizeButton::~FrameMaximizeButton() { OnWindowDestroying(frame_->GetNativeWindow()); } +void FrameMaximizeButton::AddObserver(FrameMaximizeButtonObserver* observer) { + observer_list_.AddObserver(observer); +} + +void FrameMaximizeButton::RemoveObserver( + FrameMaximizeButtonObserver* observer) { + observer_list_.RemoveObserver(observer); +} + void FrameMaximizeButton::SnapButtonHovered(SnapType type) { // Make sure to only show hover operations when no button is pressed and // a similar snap operation in progress does not get re-applied. @@ -157,6 +167,12 @@ void FrameMaximizeButton::ExecuteSnapAndCloseMenu(SnapType snap_type) { Snap(snap_sizer.get()); } +void FrameMaximizeButton::OnMaximizeBubbleShown(views::Widget* bubble) { + FOR_EACH_OBSERVER(FrameMaximizeButtonObserver, + observer_list_, + OnMaximizeBubbleShown(bubble)); +} + void FrameMaximizeButton::DestroyMaximizeMenu() { Cancel(false); } diff --git a/ash/wm/caption_buttons/frame_maximize_button.h b/ash/wm/caption_buttons/frame_maximize_button.h index 1539833..c60f7a5 100644 --- a/ash/wm/caption_buttons/frame_maximize_button.h +++ b/ash/wm/caption_buttons/frame_maximize_button.h @@ -9,6 +9,7 @@ #include "ash/wm/caption_buttons/maximize_bubble_frame_state.h" #include "ash/wm/workspace/snap_types.h" #include "base/memory/scoped_ptr.h" +#include "base/observer_list.h" #include "base/timer/timer.h" #include "ui/aura/window_observer.h" #include "ui/views/controls/button/image_button.h" @@ -19,6 +20,7 @@ class Widget; } namespace ash { +class FrameMaximizeButtonObserver; namespace internal { class PhantomWindowController; @@ -36,6 +38,9 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, views::Widget* frame); virtual ~FrameMaximizeButton(); + void AddObserver(FrameMaximizeButtonObserver* observer); + void RemoveObserver(FrameMaximizeButtonObserver* observer); + // Updates |snap_type_| based on a a given snap type. This is used by // external hover events from the button menu. void SnapButtonHovered(SnapType type); @@ -44,6 +49,9 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, // which will at the same time close the window. void ExecuteSnapAndCloseMenu(SnapType type); + // Called by the MaximizeBubbleController when the maximize bubble is shown. + void OnMaximizeBubbleShown(views::Widget* bubble); + // Remove the maximize menu from the screen (and destroy it). void DestroyMaximizeMenu(); @@ -175,6 +183,8 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, // The delay of the bubble appearance. int bubble_appearance_delay_ms_; + ObserverList<FrameMaximizeButtonObserver> observer_list_; + DISALLOW_COPY_AND_ASSIGN(FrameMaximizeButton); }; diff --git a/ash/wm/caption_buttons/frame_maximize_button_observer.h b/ash/wm/caption_buttons/frame_maximize_button_observer.h new file mode 100644 index 0000000..1962f60 --- /dev/null +++ b/ash/wm/caption_buttons/frame_maximize_button_observer.h @@ -0,0 +1,26 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_OBSERVER_H_ +#define ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_OBSERVER_H_ + +#include "ash/ash_export.h" + +namespace views { +class Widget; +} + +namespace ash { + +class ASH_EXPORT FrameMaximizeButtonObserver { + public: + virtual ~FrameMaximizeButtonObserver() {} + + // Called when the maximize button's help bubble is shown. + virtual void OnMaximizeBubbleShown(views::Widget* bubble) = 0; +}; + +} // namespace ash + +#endif // ASH_WM_CAPTION_BUTTONS_FRAME_MAXIMIZE_BUTTON_OBSERVER_H_ diff --git a/ash/wm/caption_buttons/maximize_bubble_controller.cc b/ash/wm/caption_buttons/maximize_bubble_controller.cc index 413cc0e..6148e17 100644 --- a/ash/wm/caption_buttons/maximize_bubble_controller.cc +++ b/ash/wm/caption_buttons/maximize_bubble_controller.cc @@ -818,8 +818,10 @@ void MaximizeBubbleController::RequestDestructionThroughOwner() { } void MaximizeBubbleController::CreateBubble() { - if (!bubble_) + if (!bubble_) { bubble_ = new Bubble(this, appearance_delay_ms_, snap_type_for_creation_); + frame_maximize_button_->OnMaximizeBubbleShown(bubble_->GetWidget()); + } timer_->Stop(); } diff --git a/ash/wm/custom_frame_view_ash.cc b/ash/wm/custom_frame_view_ash.cc index f03026c..571f1c7 100644 --- a/ash/wm/custom_frame_view_ash.cc +++ b/ash/wm/custom_frame_view_ash.cc @@ -5,16 +5,21 @@ #include "ash/wm/custom_frame_view_ash.h" #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" +#include "ash/wm/caption_buttons/frame_maximize_button.h" +#include "ash/wm/caption_buttons/frame_maximize_button_observer.h" #include "ash/wm/frame_border_hit_test_controller.h" #include "ash/wm/header_painter.h" +#include "ash/wm/immersive_fullscreen_controller.h" #include "grit/ash_resources.h" #include "ui/gfx/canvas.h" #include "ui/gfx/font.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" +#include "ui/views/view.h" #include "ui/views/widget/native_widget_aura.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" +#include "ui/views/widget/widget_deletion_observer.h" namespace { @@ -29,35 +34,287 @@ const gfx::Font& GetTitleFont() { namespace ash { -// static -const char CustomFrameViewAsh::kViewClassName[] = "CustomFrameViewAsh"; +/////////////////////////////////////////////////////////////////////////////// +// CustomFrameViewAsh::HeaderView -//////////////////////////////////////////////////////////////////////////////// -// CustomFrameViewAsh, public: -CustomFrameViewAsh::CustomFrameViewAsh(views::Widget* frame) +// View which paints the header. It slides off and on screen in immersive +// fullscreen. +class CustomFrameViewAsh::HeaderView + : public views::View, + public ImmersiveFullscreenController::Delegate, + public FrameMaximizeButtonObserver { + public: + // |frame| is the widget that the caption buttons act on. + explicit HeaderView(views::Widget* frame); + virtual ~HeaderView(); + + // Schedules a repaint for the entire title. + void SchedulePaintForTitle(); + + // Tells the window controls to reset themselves to the normal state. + void ResetWindowControls(); + + // Returns the amount of the view's pixels which should be on screen. + int GetPreferredOnScreenHeight() const; + + // Returns the view's preferred height. + int GetPreferredHeight() const; + + // Returns the view's minimum width. + int GetMinimumWidth() const; + + // views::View overrides: + virtual void Layout() OVERRIDE; + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; + + // Sets whether the header should be painted as active. + void set_paint_as_active(bool paint_as_active) { + paint_as_active_ = paint_as_active; + } + + HeaderPainter* header_painter() { + return header_painter_.get(); + } + + private: + // ImmersiveFullscreenController::Delegate overrides: + virtual void OnImmersiveRevealStarted() OVERRIDE; + virtual void OnImmersiveRevealEnded() OVERRIDE; + virtual void OnImmersiveFullscreenExited() OVERRIDE; + virtual void SetVisibleFraction(double visible_fraction) OVERRIDE; + virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() const OVERRIDE; + + // FrameMaximizeButtonObserver overrides: + virtual void OnMaximizeBubbleShown(views::Widget* bubble) OVERRIDE; + + // The widget that the caption buttons act on. + views::Widget* frame_; + + // Helper for painting the header. + scoped_ptr<HeaderPainter> header_painter_; + + // View which contains the window caption buttons. + FrameCaptionButtonContainerView* caption_button_container_; + + // The maximize bubble widget. |maximize_bubble_| may be non-NULL but have + // been already destroyed. + views::Widget* maximize_bubble_; + + // Keeps track of whether |maximize_bubble_| is still alive. + scoped_ptr<views::WidgetDeletionObserver> maximize_bubble_lifetime_observer_; + + // Whether the header should be painted as active. + bool paint_as_active_; + + // The fraction of the header's height which is visible while in fullscreen. + // This value is meaningless when not in fullscreen. + double fullscreen_visible_fraction_; + + DISALLOW_COPY_AND_ASSIGN(HeaderView); +}; + +CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame) : frame_(frame), - caption_button_container_(NULL), header_painter_(new ash::HeaderPainter), - frame_border_hit_test_controller_( - new FrameBorderHitTestController(frame_)) { + caption_button_container_(NULL), + maximize_bubble_(NULL), + paint_as_active_(false), + fullscreen_visible_fraction_(0) { // Unfortunately, there is no views::WidgetDelegate::CanMinimize(). Assume // that the window frame can be minimized if it can be maximized. FrameCaptionButtonContainerView::MinimizeAllowed minimize_allowed = frame_->widget_delegate()->CanMaximize() ? FrameCaptionButtonContainerView::MINIMIZE_ALLOWED : FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED; - caption_button_container_ = new FrameCaptionButtonContainerView(frame, + caption_button_container_ = new FrameCaptionButtonContainerView(frame_, minimize_allowed); AddChildView(caption_button_container_); + FrameMaximizeButton* frame_maximize_button = + caption_button_container_->GetOldStyleSizeButton(); + if (frame_maximize_button) + frame_maximize_button->AddObserver(this); header_painter_->Init(frame_, this, NULL, caption_button_container_); } +CustomFrameViewAsh::HeaderView::~HeaderView() { + FrameMaximizeButton* frame_maximize_button = + caption_button_container_->GetOldStyleSizeButton(); + if (frame_maximize_button) + frame_maximize_button->RemoveObserver(this); +} + +void CustomFrameViewAsh::HeaderView::SchedulePaintForTitle() { + header_painter_->SchedulePaintForTitle(GetTitleFont()); +} + +void CustomFrameViewAsh::HeaderView::ResetWindowControls() { + caption_button_container_->ResetWindowControls(); +} + +int CustomFrameViewAsh::HeaderView::GetPreferredOnScreenHeight() const { + if (frame_->IsFullscreen()) { + return static_cast<int>( + GetPreferredHeight() * fullscreen_visible_fraction_); + } + return GetPreferredHeight(); +} + +int CustomFrameViewAsh::HeaderView::GetPreferredHeight() const { + // Reserve enough space to see the buttons and the separator line. + return caption_button_container_->bounds().bottom() + + header_painter_->HeaderContentSeparatorSize(); +} + +int CustomFrameViewAsh::HeaderView::GetMinimumWidth() const { + return header_painter_->GetMinimumHeaderWidth(); +} + +void CustomFrameViewAsh::HeaderView::Layout() { + header_painter_->LayoutHeader(true); + header_painter_->set_header_height(GetPreferredHeight()); +} + +void CustomFrameViewAsh::HeaderView::OnPaint(gfx::Canvas* canvas) { + int theme_image_id = 0; + if (header_painter_->ShouldUseMinimalHeaderStyle(HeaderPainter::THEMED_NO)) + theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_MINIMAL; + else if (paint_as_active_) + theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_ACTIVE; + else + theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; + + header_painter_->PaintHeader( + canvas, + paint_as_active_ ? HeaderPainter::ACTIVE : HeaderPainter::INACTIVE, + theme_image_id, + 0); + header_painter_->PaintTitleBar(canvas, GetTitleFont()); + header_painter_->PaintHeaderContentSeparator(canvas); +} + +void CustomFrameViewAsh::HeaderView::OnImmersiveRevealStarted() { + fullscreen_visible_fraction_ = 0; + SetPaintToLayer(true); + parent()->Layout(); +} + +void CustomFrameViewAsh::HeaderView::OnImmersiveRevealEnded() { + fullscreen_visible_fraction_ = 0; + SetPaintToLayer(false); + parent()->Layout(); +} + +void CustomFrameViewAsh::HeaderView::OnImmersiveFullscreenExited() { + fullscreen_visible_fraction_ = 0; + SetPaintToLayer(false); + parent()->Layout(); +} + +void CustomFrameViewAsh::HeaderView::SetVisibleFraction( + double visible_fraction) { + if (fullscreen_visible_fraction_ != visible_fraction) { + fullscreen_visible_fraction_ = visible_fraction; + parent()->Layout(); + } +} + +std::vector<gfx::Rect> +CustomFrameViewAsh::HeaderView::GetVisibleBoundsInScreen() const { + // TODO(pkotwicz): Implement views::View::ConvertRectToScreen(). + gfx::Rect visible_bounds(GetVisibleBounds()); + gfx::Point visible_origin_in_screen(visible_bounds.origin()); + views::View::ConvertPointToScreen(this, &visible_origin_in_screen); + std::vector<gfx::Rect> bounds_in_screen; + bounds_in_screen.push_back( + gfx::Rect(visible_origin_in_screen, visible_bounds.size())); + if (maximize_bubble_lifetime_observer_.get() && + maximize_bubble_lifetime_observer_->IsWidgetAlive()) { + bounds_in_screen.push_back(maximize_bubble_->GetWindowBoundsInScreen()); + } + return bounds_in_screen; +} + +void CustomFrameViewAsh::HeaderView::OnMaximizeBubbleShown( + views::Widget* bubble) { + maximize_bubble_ = bubble; + maximize_bubble_lifetime_observer_.reset( + new views::WidgetDeletionObserver(bubble)); +} + +/////////////////////////////////////////////////////////////////////////////// +// CustomFrameViewAsh::OverlayView + +// View which takes up the entire widget and contains the HeaderView. HeaderView +// is a child of OverlayView to avoid creating a larger texture than necessary +// when painting the HeaderView to its own layer. +class CustomFrameViewAsh::OverlayView : public views::View { + public: + explicit OverlayView(HeaderView* header_view); + virtual ~OverlayView(); + + // views::View override: + virtual void Layout() OVERRIDE; + virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; + + private: + HeaderView* header_view_; + + DISALLOW_COPY_AND_ASSIGN(OverlayView); +}; + +CustomFrameViewAsh::OverlayView::OverlayView(HeaderView* header_view) + : header_view_(header_view) { + AddChildView(header_view); +} + +CustomFrameViewAsh::OverlayView::~OverlayView() { +} + +void CustomFrameViewAsh::OverlayView::Layout() { + int onscreen_height = header_view_->GetPreferredOnScreenHeight(); + if (onscreen_height == 0) { + header_view_->SetVisible(false); + } else { + int height = header_view_->GetPreferredHeight(); + header_view_->SetBounds(0, onscreen_height - height, width(), height); + header_view_->SetVisible(true); + } +} + +bool CustomFrameViewAsh::OverlayView::HitTestRect(const gfx::Rect& rect) const { + // Grab events in the header view. Return false for other events so that they + // can be handled by the client view. + return header_view_->HitTestRect(rect); +} + +//////////////////////////////////////////////////////////////////////////////// +// CustomFrameViewAsh, public: + +// static +const char CustomFrameViewAsh::kViewClassName[] = "CustomFrameViewAsh"; + +CustomFrameViewAsh::CustomFrameViewAsh(views::Widget* frame) + : frame_(frame), + header_view_(new HeaderView(frame)), + frame_border_hit_test_controller_( + new FrameBorderHitTestController(frame_)) { + // |header_view_| is set as the non client view's overlay view so that it can + // overlay the web contents in immersive fullscreen. + frame->non_client_view()->SetOverlayView(new OverlayView(header_view_)); +} + CustomFrameViewAsh::~CustomFrameViewAsh() { } +void CustomFrameViewAsh::InitImmersiveFullscreenControllerForView( + ImmersiveFullscreenController* immersive_fullscreen_controller) { + immersive_fullscreen_controller->Init(header_view_, frame_, header_view_); +} + //////////////////////////////////////////////////////////////////////////////// // CustomFrameViewAsh, views::NonClientFrameView overrides: + gfx::Rect CustomFrameViewAsh::GetBoundsForClientView() const { int top_height = NonClientTopBorderHeight(); return HeaderPainter::GetBoundsForClientView(top_height, bounds()); @@ -72,7 +329,7 @@ gfx::Rect CustomFrameViewAsh::GetWindowBoundsForClientBounds( int CustomFrameViewAsh::NonClientHitTest(const gfx::Point& point) { return FrameBorderHitTestController::NonClientHitTest(this, - header_painter_.get(), point); + header_view_->header_painter(), point); } void CustomFrameViewAsh::GetWindowMask(const gfx::Size& size, @@ -81,14 +338,14 @@ void CustomFrameViewAsh::GetWindowMask(const gfx::Size& size, } void CustomFrameViewAsh::ResetWindowControls() { - caption_button_container_->ResetWindowControls(); + header_view_->ResetWindowControls(); } void CustomFrameViewAsh::UpdateWindowIcon() { } void CustomFrameViewAsh::UpdateWindowTitle() { - header_painter_->SchedulePaintForTitle(GetTitleFont()); + header_view_->SchedulePaintForTitle(); } //////////////////////////////////////////////////////////////////////////////// @@ -101,40 +358,6 @@ gfx::Size CustomFrameViewAsh::GetPreferredSize() { bounds).size(); } -void CustomFrameViewAsh::Layout() { - // Use the shorter maximized layout headers. - header_painter_->LayoutHeader(true); - header_painter_->set_header_height(NonClientTopBorderHeight()); -} - -void CustomFrameViewAsh::OnPaint(gfx::Canvas* canvas) { - if (frame_->IsFullscreen()) - return; - - // Prevent bleeding paint onto the client area below the window frame, which - // may become visible when the WebContent is transparent. - canvas->Save(); - canvas->ClipRect(gfx::Rect(0, 0, width(), NonClientTopBorderHeight())); - - bool paint_as_active = ShouldPaintAsActive(); - int theme_image_id = 0; - if (header_painter_->ShouldUseMinimalHeaderStyle(HeaderPainter::THEMED_NO)) - theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_MINIMAL; - else if (paint_as_active) - theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_ACTIVE; - else - theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; - - header_painter_->PaintHeader( - canvas, - paint_as_active ? HeaderPainter::ACTIVE : HeaderPainter::INACTIVE, - theme_image_id, - 0); - header_painter_->PaintTitleBar(canvas, GetTitleFont()); - header_painter_->PaintHeaderContentSeparator(canvas); - canvas->Restore(); -} - const char* CustomFrameViewAsh::GetClassName() const { return kViewClassName; } @@ -142,8 +365,7 @@ const char* CustomFrameViewAsh::GetClassName() const { gfx::Size CustomFrameViewAsh::GetMinimumSize() { gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize()); return gfx::Size( - std::max(header_painter_->GetMinimumHeaderWidth(), - min_client_view_size.width()), + std::max(header_view_->GetMinimumWidth(), min_client_view_size.width()), NonClientTopBorderHeight() + min_client_view_size.height()); } @@ -151,17 +373,24 @@ gfx::Size CustomFrameViewAsh::GetMaximumSize() { return frame_->client_view()->GetMaximumSize(); } +void CustomFrameViewAsh::SchedulePaintInRect(const gfx::Rect& r) { + // The HeaderView is not a child of CustomFrameViewAsh. Redirect the paint to + // HeaderView instead. + header_view_->set_paint_as_active(ShouldPaintAsActive()); + header_view_->SchedulePaint(); +} + +bool CustomFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { + // NonClientView hit tests the NonClientFrameView first instead of going in + // z-order. Return false so that events get to the OverlayView. + return false; +} + //////////////////////////////////////////////////////////////////////////////// // CustomFrameViewAsh, private: int CustomFrameViewAsh::NonClientTopBorderHeight() const { - if (frame_->IsFullscreen()) - return 0; - - // Reserve enough space to see the buttons, including any offset from top and - // reserving space for the separator line. - return caption_button_container_->bounds().bottom() + - header_painter_->HeaderContentSeparatorSize(); + return frame_->IsFullscreen() ? 0 : header_view_->GetPreferredHeight(); } } // namespace ash diff --git a/ash/wm/custom_frame_view_ash.h b/ash/wm/custom_frame_view_ash.h index 9593abb..7c58a1e 100644 --- a/ash/wm/custom_frame_view_ash.h +++ b/ash/wm/custom_frame_view_ash.h @@ -12,6 +12,7 @@ namespace ash { class FrameBorderHitTestController; class HeaderPainter; +class ImmersiveFullscreenController; } namespace gfx { class Font; @@ -22,10 +23,12 @@ class Widget; namespace ash { -class FrameCaptionButtonContainerView; - -// A NonClientFrameView used for dialogs and other non-browser windows. -// See also views::CustomFrameView and BrowserNonClientFrameViewAsh. +// A NonClientFrameView used for packaged apps, dialogs and other non-browser +// windows. It supports immersive fullscreen. When in immersive fullscreen, the +// client view takes up the entire widget and the window header is an overlay. +// The window header overlay slides onscreen when the user hovers the mouse at +// the top of the screen. See also views::CustomFrameView and +// BrowserNonClientFrameViewAsh. class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView { public: // Internal class name. @@ -34,6 +37,13 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView { explicit CustomFrameViewAsh(views::Widget* frame); virtual ~CustomFrameViewAsh(); + // Inits |immersive_fullscreen_controller| so that the controller reveals + // and hides |header_view_| in immersive fullscreen. + // CustomFrameViewAsh does not take ownership of + // |immersive_fullscreen_controller|. + void InitImmersiveFullscreenControllerForView( + ImmersiveFullscreenController* immersive_fullscreen_controller); + // views::NonClientFrameView overrides: virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; virtual gfx::Rect GetWindowBoundsForClientBounds( @@ -47,24 +57,24 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView { // views::View overrides: virtual gfx::Size GetPreferredSize() OVERRIDE; - virtual void Layout() OVERRIDE; virtual const char* GetClassName() const OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; virtual gfx::Size GetMinimumSize() OVERRIDE; virtual gfx::Size GetMaximumSize() OVERRIDE; + virtual void SchedulePaintInRect(const gfx::Rect& r) OVERRIDE; + virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; private: + class OverlayView; + // Height from top of window to top of client area. int NonClientTopBorderHeight() const; // Not owned. views::Widget* frame_; - // View which contains the window controls. - FrameCaptionButtonContainerView* caption_button_container_; - - // Helper class for painting the header. - scoped_ptr<HeaderPainter> header_painter_; + // View which contains the title and window controls. + class HeaderView; + HeaderView* header_view_; // Updates the hittest bounds overrides based on the window show type. scoped_ptr<FrameBorderHitTestController> frame_border_hit_test_controller_; diff --git a/ash/wm/immersive_fullscreen_controller.h b/ash/wm/immersive_fullscreen_controller.h index 420c486..9d0f757 100644 --- a/ash/wm/immersive_fullscreen_controller.h +++ b/ash/wm/immersive_fullscreen_controller.h @@ -66,7 +66,7 @@ class ASH_EXPORT ImmersiveFullscreenController // The returned list is used for hittesting when the top-of-window views // are revealed. GetVisibleBoundsInScreen() must return a valid value when // not in immersive fullscreen for the sake of SetupForTest(). - virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() = 0; + virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() const = 0; protected: virtual ~Delegate() {} diff --git a/ash/wm/immersive_fullscreen_controller_unittest.cc b/ash/wm/immersive_fullscreen_controller_unittest.cc index c25f9ee..9d0b21b 100644 --- a/ash/wm/immersive_fullscreen_controller_unittest.cc +++ b/ash/wm/immersive_fullscreen_controller_unittest.cc @@ -54,7 +54,7 @@ class MockImmersiveFullscreenControllerDelegate virtual void SetVisibleFraction(double visible_fraction) OVERRIDE { visible_fraction_ = visible_fraction; } - virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() OVERRIDE { + virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() const OVERRIDE { std::vector<gfx::Rect> bounds_in_screen; bounds_in_screen.push_back(top_container_view_->GetBoundsInScreen()); return bounds_in_screen; diff --git a/ash/wm/window_state_delegate.h b/ash/wm/window_state_delegate.h index 7b9a8ba..53badcf 100644 --- a/ash/wm/window_state_delegate.h +++ b/ash/wm/window_state_delegate.h @@ -17,9 +17,12 @@ class ASH_EXPORT WindowStateDelegate { WindowStateDelegate(); virtual ~WindowStateDelegate(); - // Invoked when the user uses Shift+F4/F4 to toggle the window - // fullscreen state. The caller (ash::wm::WindowState) falls backs - // to the default implementation if this returns false. + // Invoked when the user uses Shift+F4/F4 to toggle the window fullscreen + // state. If the window is not fullscreen and the window supports immersive + // fullscreen ToggleFullscreen() should put the window into immersive + // fullscreen instead of the default fullscreen type. The caller + // (ash::wm::WindowState) falls backs to the default implementation if this + // returns false. virtual bool ToggleFullscreen(WindowState* window_state); private: diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 4c89f40..6150f66 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6556,6 +6556,12 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAGS_DOCKED_WINDOWS_DESCRIPTION" desc="Description for the flag to disable docked windows feature."> Turns off docking of windows near screen edges, a feature that provides an easier way to interact with panel and other small windows. </message> + <message name="IDS_FLAGS_IMMERSIVE_FULLSCREEN_FOR_ALL_WINDOWS_NAME" desc="Name for the flag to enable immersive fullscreen for all windows."> + Enable immersive fullscreen for non browser windows. + </message> + <message name="IDS_FLAGS_IMMERSIVE_FULLSCREEN_FOR_ALL_WINDOWS_DESCRIPTION" desc="Description for the flag enable immersive fullscreen for all windows."> + Sets non-browser windows (apps, task manager) to use immersive fullscreen when fullscreened via the F4 key. + </message> <message name="IDS_FLAGS_SHOW_SHELF_ALIGNMENT_MENU_NAME" desc="Name for the flag to show a menu that lets you change the alignment of the shelf."> Show shelf alignment menu. </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index c545a77..b7755d3 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -987,6 +987,13 @@ const Experiment kExperiments[] = { kOsCrOS, SINGLE_VALUE_TYPE(ash::switches::kAshDisableDockedWindows) }, + { + "ash-enable-immersive-fullscreen-all-windows", + IDS_FLAGS_IMMERSIVE_FULLSCREEN_FOR_ALL_WINDOWS_NAME, + IDS_FLAGS_IMMERSIVE_FULLSCREEN_FOR_ALL_WINDOWS_DESCRIPTION, + kOsCrOS, + SINGLE_VALUE_TYPE(ash::switches::kAshEnableImmersiveFullscreenForAllWindows) + }, #endif { "enable-download-resumption", diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h index d082559..ad05cc9 100644 --- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h +++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h @@ -113,7 +113,7 @@ class NativeAppWindowCocoa : public apps::NativeAppWindow, protected: // NativeAppWindow implementation. - virtual void SetFullscreen(bool fullscreen) OVERRIDE; + virtual void SetFullscreen(int fullscreen_types) OVERRIDE; virtual bool IsFullscreenOrPending() const OVERRIDE; virtual bool IsDetached() const OVERRIDE; virtual void UpdateWindowIcon() OVERRIDE; diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm index 30ef4a6..e8a6c2b 100644 --- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm +++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm @@ -427,7 +427,8 @@ bool NativeAppWindowCocoa::IsFullscreen() const { return is_fullscreen_; } -void NativeAppWindowCocoa::SetFullscreen(bool fullscreen) { +void NativeAppWindowCocoa::SetFullscreen(int fullscreen_types) { + bool fullscreen = (fullscreen_types != ShellWindow::FULLSCREEN_TYPE_NONE); if (fullscreen == is_fullscreen_) return; is_fullscreen_ = fullscreen; diff --git a/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc b/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc index c76619e..5a7624a 100644 --- a/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc +++ b/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc @@ -593,9 +593,10 @@ gboolean NativeAppWindowGtk::OnButtonPress(GtkWidget* widget, // NativeAppWindow implementation: -void NativeAppWindowGtk::SetFullscreen(bool fullscreen) { +void NativeAppWindowGtk::SetFullscreen(int fullscreen_types) { + bool fullscreen = (fullscreen_types != ShellWindow::FULLSCREEN_TYPE_NONE); content_thinks_its_fullscreen_ = fullscreen; - if (fullscreen){ + if (fullscreen) { if (resizable_) { gtk_window_fullscreen(window_); } else { diff --git a/chrome/browser/ui/gtk/apps/native_app_window_gtk.h b/chrome/browser/ui/gtk/apps/native_app_window_gtk.h index 21f2030..eae32df 100644 --- a/chrome/browser/ui/gtk/apps/native_app_window_gtk.h +++ b/chrome/browser/ui/gtk/apps/native_app_window_gtk.h @@ -67,7 +67,7 @@ class NativeAppWindowGtk : public apps::NativeAppWindow, private: // NativeAppWindow implementation. - virtual void SetFullscreen(bool fullscreen) OVERRIDE; + virtual void SetFullscreen(int fullscreen_types) OVERRIDE; virtual bool IsFullscreenOrPending() const OVERRIDE; virtual bool IsDetached() const OVERRIDE; virtual void UpdateWindowIcon() OVERRIDE; diff --git a/chrome/browser/ui/views/apps/native_app_window_views.cc b/chrome/browser/ui/views/apps/native_app_window_views.cc index 6bf1222..11f50a0 100644 --- a/chrome/browser/ui/views/apps/native_app_window_views.cc +++ b/chrome/browser/ui/views/apps/native_app_window_views.cc @@ -43,16 +43,20 @@ #if defined(USE_ASH) #include "ash/ash_constants.h" +#include "ash/ash_switches.h" #include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/wm/custom_frame_view_ash.h" +#include "ash/wm/immersive_fullscreen_controller.h" #include "ash/wm/panels/panel_frame_view.h" #include "ash/wm/window_state.h" #include "ash/wm/window_state_delegate.h" +#include "ash/wm/window_state_observer.h" #include "chrome/browser/ui/ash/ash_util.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/window_tree_client.h" #include "ui/aura/window.h" +#include "ui/aura/window_observer.h" #endif #if defined(USE_AURA) @@ -129,14 +133,31 @@ void CreateIconAndSetRelaunchDetails( #if defined(USE_ASH) // This class handles a user's fullscreen request (Shift+F4/F4). -class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate { +class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate, + public ash::wm::WindowStateObserver, + public aura::WindowObserver { public: - explicit NativeAppWindowStateDelegate(ShellWindow* shell_window) - : shell_window_(shell_window) { - DCHECK(shell_window_); + NativeAppWindowStateDelegate(ShellWindow* shell_window, + apps::NativeAppWindow* native_app_window) + : shell_window_(shell_window), + window_state_( + ash::wm::GetWindowState(native_app_window->GetNativeWindow())) { + // Add a window state observer to exit fullscreen properly in case + // fullscreen is exited without going through ShellWindow::Restore(). This + // is the case when exiting immersive fullscreen via the "Restore" window + // control. + // TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048 + window_state_->AddObserver(this); + window_state_->window()->AddObserver(this); + } + virtual ~NativeAppWindowStateDelegate(){ + if (window_state_) { + window_state_->RemoveObserver(this); + window_state_->window()->RemoveObserver(this); + } } - virtual ~NativeAppWindowStateDelegate(){} + private: // Overridden from ash::wm::WindowStateDelegate. virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE { // Windows which cannot be maximized should not be fullscreened. @@ -144,12 +165,36 @@ class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate { if (window_state->IsFullscreen()) shell_window_->Restore(); else if (window_state->CanMaximize()) - shell_window_->Fullscreen(); + shell_window_->OSFullscreen(); return true; } - private: - ShellWindow* shell_window_; // not owned. + // Overridden from ash::wm::WindowStateObserver: + virtual void OnWindowShowTypeChanged( + ash::wm::WindowState* window_state, + ash::wm::WindowShowType old_type) OVERRIDE { + if (!window_state->IsFullscreen() && + !window_state->IsMinimized() && + shell_window_->GetBaseWindow()->IsFullscreenOrPending()) { + shell_window_->Restore(); + // Usually OnNativeWindowChanged() is called when the window bounds are + // changed as a result of a show type change. Because the change in show + // type has already occurred, we need to call OnNativeWindowChanged() + // explicitly. + shell_window_->OnNativeWindowChanged(); + } + } + + // Overridden from aura::WindowObserver: + virtual void OnWindowDestroying(aura::Window* window) OVERRIDE { + window_state_->RemoveObserver(this); + window_state_->window()->RemoveObserver(this); + window_state_ = NULL; + } + + // Not owned. + ShellWindow* shell_window_; + ash::wm::WindowState* window_state_; DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); }; @@ -191,7 +236,7 @@ NativeAppWindowViews::NativeAppWindowViews( chrome::HOST_DESKTOP_TYPE_ASH) { ash::wm::GetWindowState(GetNativeWindow())->SetDelegate( scoped_ptr<ash::wm::WindowStateDelegate>( - new NativeAppWindowStateDelegate(shell_window)).Pass()); + new NativeAppWindowStateDelegate(shell_window, this)).Pass()); } #endif } @@ -676,7 +721,21 @@ views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( return new ash::PanelFrameView(widget, frame_type); } if (!frameless_) { - return new ash::CustomFrameViewAsh(widget); + ash::CustomFrameViewAsh* custom_frame_view = + new ash::CustomFrameViewAsh(widget); +#if defined(OS_CHROMEOS) + // Non-frameless app windows can be put into immersive fullscreen. + // TODO(pkotwicz): Investigate if immersive fullscreen can be enabled for + // Windows Ash. + if (CommandLine::ForCurrentProcess()->HasSwitch( + ash::switches::kAshEnableImmersiveFullscreenForAllWindows)) { + immersive_fullscreen_controller_.reset( + new ash::ImmersiveFullscreenController()); + custom_frame_view->InitImmersiveFullscreenControllerForView( + immersive_fullscreen_controller_.get()); + } +#endif + return custom_frame_view; } } #endif @@ -800,12 +859,30 @@ bool NativeAppWindowViews::AcceleratorPressed( // NativeAppWindow implementation. -void NativeAppWindowViews::SetFullscreen(bool fullscreen) { +void NativeAppWindowViews::SetFullscreen(int fullscreen_types) { // Fullscreen not supported by panels. if (shell_window_->window_type_is_panel()) return; - is_fullscreen_ = fullscreen; - window_->SetFullscreen(fullscreen); + is_fullscreen_ = (fullscreen_types != ShellWindow::FULLSCREEN_TYPE_NONE); + window_->SetFullscreen(is_fullscreen_); + +#if defined(USE_ASH) + if (immersive_fullscreen_controller_.get()) { + // |immersive_fullscreen_controller_| should only be set if immersive + // fullscreen is the fullscreen type used by the OS. + immersive_fullscreen_controller_->SetEnabled( + (fullscreen_types & ShellWindow::FULLSCREEN_TYPE_OS) != 0); + // Autohide the shelf instead of hiding the shelf completely when only in + // OS fullscreen. + ash::wm::WindowState* window_state = + ash::wm::GetWindowState(window_->GetNativeWindow()); + window_state->set_hide_shelf_when_fullscreen( + fullscreen_types != ShellWindow::FULLSCREEN_TYPE_OS); + DCHECK(ash::Shell::HasInstance()); + ash::Shell::GetInstance()->UpdateShelfVisibility(); + } +#endif + // TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we // ever drop the window out of fullscreen in response to something that // wasn't the app calling webkitCancelFullScreen(). diff --git a/chrome/browser/ui/views/apps/native_app_window_views.h b/chrome/browser/ui/views/apps/native_app_window_views.h index 172b020..3198b57 100644 --- a/chrome/browser/ui/views/apps/native_app_window_views.h +++ b/chrome/browser/ui/views/apps/native_app_window_views.h @@ -21,6 +21,12 @@ #include "chrome/browser/shell_integration.h" #endif +#if defined(USE_ASH) +namespace ash { +class ImmersiveFullscreenController; +} +#endif + class ExtensionKeybindingRegistryViews; class Profile; @@ -152,7 +158,7 @@ class NativeAppWindowViews : public apps::NativeAppWindow, virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; // NativeAppWindow implementation. - virtual void SetFullscreen(bool fullscreen) OVERRIDE; + virtual void SetFullscreen(int fullscreen_types) OVERRIDE; virtual bool IsFullscreenOrPending() const OVERRIDE; virtual bool IsDetached() const OVERRIDE; virtual void UpdateWindowIcon() OVERRIDE; @@ -203,10 +209,19 @@ class NativeAppWindowViews : public apps::NativeAppWindow, views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_; - base::WeakPtrFactory<NativeAppWindowViews> weak_ptr_factory_; +#if defined(USE_ASH) + // Used to put non-frameless windows into immersive fullscreen on ChromeOS. In + // immersive fullscreen, the window header (title bar and window controls) + // slides onscreen as an overlay when the mouse is hovered at the top of the + // screen. + scoped_ptr<ash::ImmersiveFullscreenController> + immersive_fullscreen_controller_; +#endif ObserverList<web_modal::ModalDialogHostObserver> observer_list_; + base::WeakPtrFactory<NativeAppWindowViews> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(NativeAppWindowViews); }; diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc index 8182b7c..26927f8 100644 --- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc +++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.cc @@ -208,7 +208,7 @@ void ImmersiveModeControllerAsh::SetVisibleFraction(double visible_fraction) { } std::vector<gfx::Rect> -ImmersiveModeControllerAsh::GetVisibleBoundsInScreen() { +ImmersiveModeControllerAsh::GetVisibleBoundsInScreen() const { views::View* top_container_view = browser_view_->top_container(); gfx::Rect top_container_view_bounds = top_container_view->GetVisibleBounds(); // TODO(tdanderson): Implement View::ConvertRectToScreen(). diff --git a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h index 22fe147..93412e8 100644 --- a/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h +++ b/chrome/browser/ui/views/frame/immersive_mode_controller_ash.h @@ -65,7 +65,7 @@ class ImmersiveModeControllerAsh virtual void OnImmersiveRevealEnded() OVERRIDE; virtual void OnImmersiveFullscreenExited() OVERRIDE; virtual void SetVisibleFraction(double visible_fraction) OVERRIDE; - virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() OVERRIDE; + virtual std::vector<gfx::Rect> GetVisibleBoundsInScreen() const OVERRIDE; // ash::wm::WindowStateObserver override: virtual void OnWindowShowTypeChanged( diff --git a/ui/views/widget/widget_deletion_observer.h b/ui/views/widget/widget_deletion_observer.h index 1956e7f..7182d2d 100644 --- a/ui/views/widget/widget_deletion_observer.h +++ b/ui/views/widget/widget_deletion_observer.h @@ -7,13 +7,14 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "ui/views/views_export.h" #include "ui/views/widget/widget_observer.h" namespace views { class Widget; // A simple WidgetObserver that can be probed for the life of a widget. -class WidgetDeletionObserver : public WidgetObserver { +class VIEWS_EXPORT WidgetDeletionObserver : public WidgetObserver { public: explicit WidgetDeletionObserver(Widget* widget); virtual ~WidgetDeletionObserver(); |