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

Unified Diff: chrome/browser/ui/views/extensions/native_app_window_views.cc

Issue 14663010: Save and restore State for ShellWindows, including panels (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
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..826e5e98e58286c1663d1c2702233ca9379434ba 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,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
}
@@ -304,6 +312,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 +700,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;
}
« no previous file with comments | « chrome/browser/ui/views/extensions/native_app_window_views.h ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698