summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui/extensions')
-rw-r--r--chrome/browser/ui/extensions/native_app_window.h3
-rw-r--r--chrome/browser/ui/extensions/shell_window.cc42
-rw-r--r--chrome/browser/ui/extensions/shell_window.h10
3 files changed, 26 insertions, 29 deletions
diff --git a/chrome/browser/ui/extensions/native_app_window.h b/chrome/browser/ui/extensions/native_app_window.h
index 811f4ed..447a9e0 100644
--- a/chrome/browser/ui/extensions/native_app_window.h
+++ b/chrome/browser/ui/extensions/native_app_window.h
@@ -26,6 +26,9 @@ class NativeAppWindow : public BaseWindow, public WebContentsModalDialogHost {
virtual void SetFullscreen(bool fullscreen) = 0;
virtual bool IsFullscreenOrPending() const = 0;
+ // Returns true if the window is a panel that has been detached.
+ virtual bool IsDetached() const = 0;
+
// Called when the icon of the window changes.
virtual void UpdateWindowIcon() = 0;
diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
index e6c48ed..f167e74 100644
--- a/chrome/browser/ui/extensions/shell_window.cc
+++ b/chrome/browser/ui/extensions/shell_window.cc
@@ -72,7 +72,7 @@ ShellWindow::CreateParams::CreateParams()
transparent_background(false),
bounds(INT_MIN, INT_MIN, 0, 0),
creator_process_id(0),
- state(STATE_NORMAL),
+ state(ui::SHOW_STATE_DEFAULT),
hidden(false),
resizable(true),
focused(true) {
@@ -104,7 +104,7 @@ ShellWindow::ShellWindow(Profile* profile,
void ShellWindow::Init(const GURL& url,
ShellWindowContents* shell_window_contents,
- const ShellWindow::CreateParams& params) {
+ const CreateParams& params) {
// Initialize the render interface and web contents
shell_window_contents_.reset(shell_window_contents);
shell_window_contents_->Initialize(profile(), url);
@@ -130,6 +130,7 @@ void ShellWindow::Init(const GURL& url,
// If left and top are left undefined, the native shell window will center
// the window on the main screen in a platform-defined manner.
+ ui::WindowShowState cached_state = ui::SHOW_STATE_DEFAULT;
if (!params.window_key.empty()) {
window_key_ = params.window_key;
@@ -138,11 +139,12 @@ void ShellWindow::Init(const GURL& url,
shell_window_geometry_cache();
gfx::Rect cached_bounds;
if (cache->GetGeometry(extension()->id(), params.window_key,
- &cached_bounds))
+ &cached_bounds, &cached_state)) {
bounds = cached_bounds;
+ }
}
- ShellWindow::CreateParams new_params = params;
+ CreateParams new_params = params;
gfx::Size& minimum_size = new_params.minimum_size;
gfx::Size& maximum_size = new_params.maximum_size;
@@ -166,30 +168,27 @@ void ShellWindow::Init(const GURL& url,
new_params.bounds = bounds;
- native_app_window_.reset(NativeAppWindow::Create(this, new_params));
- OnNativeWindowChanged();
+ if (cached_state != ui::SHOW_STATE_DEFAULT)
+ new_params.state = cached_state;
- switch (params.state) {
- case CreateParams::STATE_NORMAL:
- break;
- case CreateParams::STATE_FULLSCREEN:
- Fullscreen();
- break;
- case CreateParams::STATE_MAXIMIZED:
- Maximize();
- break;
- case CreateParams::STATE_MINIMIZED:
- Minimize();
- break;
- }
+ native_app_window_.reset(NativeAppWindow::Create(this, new_params));
- if (!params.hidden) {
+ if (!new_params.hidden) {
if (window_type_is_panel())
GetBaseWindow()->ShowInactive(); // Panels are not activated by default.
else
GetBaseWindow()->Show();
}
+ if (new_params.state == ui::SHOW_STATE_FULLSCREEN)
+ Fullscreen();
+ else if (new_params.state == ui::SHOW_STATE_MAXIMIZED)
+ Maximize();
+ else if (new_params.state == ui::SHOW_STATE_MINIMIZED)
+ Minimize();
+
+ OnNativeWindowChanged();
+
// When the render view host is changed, the native window needs to know
// about it in case it has any setup to do to make the renderer appear
// properly. In particular, on Windows, the view's clickthrough region needs
@@ -576,7 +575,8 @@ void ShellWindow::SaveWindowPosition() {
gfx::Rect bounds = native_app_window_->GetRestoredBounds();
bounds.Inset(native_app_window_->GetFrameInsets());
- cache->SaveGeometry(extension()->id(), window_key_, bounds);
+ ui::WindowShowState window_state = native_app_window_->GetRestoredState();
+ cache->SaveGeometry(extension()->id(), window_key_, bounds, window_state);
}
// static
diff --git a/chrome/browser/ui/extensions/shell_window.h b/chrome/browser/ui/extensions/shell_window.h
index 7b28a5c..05b06ab 100644
--- a/chrome/browser/ui/extensions/shell_window.h
+++ b/chrome/browser/ui/extensions/shell_window.h
@@ -15,6 +15,7 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/console_message_level.h"
+#include "ui/base/ui_base_types.h" // WindowShowState
#include "ui/gfx/image/image.h"
#include "ui/gfx/rect.h"
@@ -102,15 +103,8 @@ class ShellWindow : public content::NotificationObserver,
// The process ID of the process that requested the create.
int32 creator_process_id;
- enum State {
- STATE_NORMAL,
- STATE_FULLSCREEN,
- STATE_MAXIMIZED,
- STATE_MINIMIZED
- };
-
// Initial state of the window.
- State state;
+ ui::WindowShowState state;
// If true, don't show the window after creation.
bool hidden;