Chromium Code Reviews| Index: chrome/browser/ui/views/extensions/native_app_window_views.cc |
| 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 41315a2bdb9bfa25abea66ec77fa64334df10201..5496f2ed3db612c0dbca74fcac53b6b9999f2149 100644 |
| --- a/chrome/browser/ui/views/extensions/native_app_window_views.cc |
| +++ b/chrome/browser/ui/views/extensions/native_app_window_views.cc |
| @@ -40,7 +40,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 { |
| @@ -266,15 +268,22 @@ 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* win = GetNativeWindow(); |
|
Mr4D (OOO till 08-26)
2013/05/06 21:40:16
Please no abbrev
stevenjb
2013/05/07 16:06:32
Done.
|
| + win->SetProperty(ash::internal::kPanelAttachedKey, false); |
| + win->SetDefaultParentByRootWindow( |
| + win->GetRootWindow(), |
| + win->GetBoundsInScreen()); |
| + window_->SetBounds(window_bounds); |
| + } |
| +#else |
| + // TODO(stevenjb): NativeAppWindow panels need to be implemented for other |
| + // platforms. |
| #endif |
| } |
| @@ -304,6 +313,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(); |
| } |
| @@ -675,6 +701,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; |
| } |