diff options
Diffstat (limited to 'chrome/browser/ui/views')
4 files changed, 56 insertions, 9 deletions
diff --git a/chrome/browser/ui/views/extensions/native_app_window_views.cc b/chrome/browser/ui/views/extensions/native_app_window_views.cc index e981a84..6781fcd 100644 --- a/chrome/browser/ui/views/extensions/native_app_window_views.cc +++ b/chrome/browser/ui/views/extensions/native_app_window_views.cc @@ -41,7 +41,9 @@ #include "ash/wm/panels/panel_frame_view.h" #include "ash/wm/window_properties.h" #include "chrome/browser/ui/ash/ash_util.h" +#include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" +#include "ui/aura/window.h" #endif namespace { @@ -261,15 +263,21 @@ void NativeAppWindowViews::InitializePanelWindow( window_->Init(params); window_->set_focus_on_creation(create_params.focused); -#if !defined(USE_ASH) - // TODO(oshima|stevenjb): Ideally, we should be able to just pre-determine - // the exact location and size, but this doesn't work well - // on non-ash environment where we don't have full control over - // window management. - gfx::Rect window_bounds = - window_->non_client_view()->GetWindowBoundsForClientBounds( - create_params.bounds); - window_->SetBounds(window_bounds); +#if defined(USE_ASH) + if (create_params.state == ui::SHOW_STATE_DETACHED) { + gfx::Rect window_bounds(create_params.bounds.x(), + create_params.bounds.y(), + preferred_size_.width(), + preferred_size_.height()); + aura::Window* native_window = GetNativeWindow(); + native_window->SetProperty(ash::internal::kPanelAttachedKey, false); + native_window->SetDefaultParentByRootWindow( + native_window->GetRootWindow(), native_window->GetBoundsInScreen()); + window_->SetBounds(window_bounds); + } +#else + // TODO(stevenjb): NativeAppWindow panels need to be implemented for other + // platforms. #endif } @@ -299,6 +307,23 @@ gfx::Rect NativeAppWindowViews::GetRestoredBounds() const { return window_->GetRestoredBounds(); } +ui::WindowShowState NativeAppWindowViews::GetRestoredState() const { + if (IsMaximized()) + return ui::SHOW_STATE_MAXIMIZED; +#if defined(USE_ASH) + // On Ash, restore fullscreen. + if (IsFullscreen()) + return ui::SHOW_STATE_FULLSCREEN; + // Use kRestoreShowStateKey in case a window is minimized/hidden. + ui::WindowShowState restore_state = + window_->GetNativeWindow()->GetProperty( + aura::client::kRestoreShowStateKey); + if (restore_state != ui::SHOW_STATE_MINIMIZED) + return restore_state; +#endif + return ui::SHOW_STATE_NORMAL; +} + gfx::Rect NativeAppWindowViews::GetBounds() const { return window_->GetWindowBoundsInScreen(); } @@ -670,6 +695,17 @@ bool NativeAppWindowViews::IsFullscreenOrPending() const { return is_fullscreen_; } +bool NativeAppWindowViews::IsDetached() const { + if (!shell_window_->window_type_is_panel()) + return false; +#if defined(USE_ASH) + return !window_->GetNativeWindow()->GetProperty( + ash::internal::kPanelAttachedKey); +#else + return false; +#endif +} + views::View* NativeAppWindowViews::GetContentsView() { return this; } diff --git a/chrome/browser/ui/views/extensions/native_app_window_views.h b/chrome/browser/ui/views/extensions/native_app_window_views.h index 4a5cbac..90448d2 100644 --- a/chrome/browser/ui/views/extensions/native_app_window_views.h +++ b/chrome/browser/ui/views/extensions/native_app_window_views.h @@ -69,6 +69,7 @@ class NativeAppWindowViews : public NativeAppWindow, virtual bool IsFullscreen() const OVERRIDE; virtual gfx::NativeWindow GetNativeWindow() OVERRIDE; virtual gfx::Rect GetRestoredBounds() const OVERRIDE; + virtual ui::WindowShowState GetRestoredState() const OVERRIDE; virtual gfx::Rect GetBounds() const OVERRIDE; virtual void Show() OVERRIDE; virtual void ShowInactive() OVERRIDE; @@ -129,6 +130,7 @@ class NativeAppWindowViews : public NativeAppWindow, // NativeAppWindow implementation. virtual void SetFullscreen(bool fullscreen) OVERRIDE; virtual bool IsFullscreenOrPending() const OVERRIDE; + virtual bool IsDetached() const OVERRIDE; virtual void UpdateWindowIcon() OVERRIDE; virtual void UpdateWindowTitle() OVERRIDE; virtual void UpdateDraggableRegions( diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 0604615..ebe1f38 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -774,6 +774,14 @@ gfx::Rect BrowserView::GetRestoredBounds() const { return frame_->GetRestoredBounds(); } +ui::WindowShowState BrowserView::GetRestoredState() const { + if (IsMaximized()) + return ui::SHOW_STATE_MAXIMIZED; + if (IsMinimized()) + return ui::SHOW_STATE_MINIMIZED; + return ui::SHOW_STATE_NORMAL; +} + gfx::Rect BrowserView::GetBounds() const { return frame_->GetWindowBoundsInScreen(); } diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index d307e87..4744a17 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -276,6 +276,7 @@ class BrowserView : public BrowserWindow, virtual void SetStarredState(bool is_starred) OVERRIDE; virtual void ZoomChangedForActiveTab(bool can_show_bubble) OVERRIDE; virtual gfx::Rect GetRestoredBounds() const OVERRIDE; + virtual ui::WindowShowState GetRestoredState() const OVERRIDE; virtual gfx::Rect GetBounds() const OVERRIDE; virtual bool IsMaximized() const OVERRIDE; virtual bool IsMinimized() const OVERRIDE; |