summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/browser.cc23
-rw-r--r--chrome/browser/ui/browser.h28
-rw-r--r--chrome/browser/ui/browser_browsertest.cc4
-rw-r--r--chrome/browser/ui/browser_window.h3
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.h4
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm56
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm4
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.mm11
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.h3
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.mm28
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_unittest.mm6
-rw-r--r--chrome/browser/ui/cocoa/framed_browser_window.mm3
-rw-r--r--chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm15
-rw-r--r--chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm3
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc23
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.h9
-rw-r--r--chrome/browser/ui/panels/panel.cc5
-rw-r--r--chrome/browser/ui/panels/panel.h1
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.cc3
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc17
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h1
21 files changed, 156 insertions, 94 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index f54bcf50..63d5c25 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -247,7 +247,7 @@ Browser::Browser(Type type, Profile* profile)
chrome_updater_factory_(this),
is_attempting_to_close_browser_(false),
cancel_download_confirmation_state_(NOT_PROMPTED),
- maximized_state_(MAXIMIZED_STATE_DEFAULT),
+ show_state_(ui::SHOW_STATE_DEFAULT),
method_factory_(this),
block_command_execution_(false),
last_blocked_command_id_(-1),
@@ -853,7 +853,8 @@ bool Browser::ShouldSaveWindowPlacement() const {
}
}
-void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) {
+void Browser::SaveWindowPlacement(const gfx::Rect& bounds,
+ ui::WindowShowState show_state) {
// Save to the session storage service, used when reloading a past session.
// Note that we don't want to be the ones who cause lazy initialization of
// the session service. This function gets called during initial window
@@ -861,7 +862,7 @@ void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) {
SessionService* session_service =
SessionServiceFactory::GetForProfileIfExisting(profile());
if (session_service)
- session_service->SetWindowBounds(session_id_, bounds, maximized);
+ session_service->SetWindowBounds(session_id_, bounds, show_state);
}
gfx::Rect Browser::GetSavedWindowBounds() const {
@@ -886,21 +887,19 @@ gfx::Rect Browser::GetSavedWindowBounds() const {
// TODO(beng): obtain maximized state some other way so we don't need to go
// through all this hassle.
-bool Browser::GetSavedMaximizedState() const {
+ui::WindowShowState Browser::GetSavedWindowShowState() const {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized))
- return true;
+ return ui::SHOW_STATE_MAXIMIZED;
- if (maximized_state_ == MAXIMIZED_STATE_MAXIMIZED)
- return true;
- if (maximized_state_ == MAXIMIZED_STATE_UNMAXIMIZED)
- return false;
+ if (show_state_ != ui::SHOW_STATE_DEFAULT)
+ return show_state_;
// An explicit maximized state was not set. Query the window sizer.
gfx::Rect restored_bounds;
bool maximized = false;
WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, this,
&restored_bounds, &maximized);
- return maximized;
+ return maximized ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL;
}
SkBitmap Browser::GetCurrentPageIcon() const {
@@ -2728,8 +2727,8 @@ Browser* Browser::CreateNewStripWithContents(
// Create an empty new browser window the same size as the old one.
Browser* browser = new Browser(TYPE_TABBED, profile_);
browser->set_override_bounds(new_window_bounds);
- browser->set_maximized_state(
- maximize ? MAXIMIZED_STATE_MAXIMIZED : MAXIMIZED_STATE_UNMAXIMIZED);
+ browser->set_show_state(
+ maximize ? ui::SHOW_STATE_MAXIMIZED : ui::SHOW_STATE_NORMAL);
browser->InitBrowserWindow();
browser->tabstrip_model()->AppendTabContents(detached_contents, true);
// Make sure the loading state is updated correctly, otherwise the throbber
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 30a8d87..cac7b21 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -43,6 +43,7 @@
#include "content/common/notification_registrar.h"
#include "content/common/page_transition_types.h"
#include "content/common/page_zoom.h"
+#include "ui/base/ui_base_types.h"
#include "ui/gfx/rect.h"
class BrowserSyncedWindowDelegate;
@@ -102,19 +103,6 @@ class Browser : public TabHandlerDelegate,
FEATURE_DOWNLOADSHELF = 128
};
- // Maximized state on creation.
- enum MaximizedState {
- // The maximized state is set to the default, which varies depending upon
- // what the user has done.
- MAXIMIZED_STATE_DEFAULT,
-
- // Maximized state is explicitly maximized.
- MAXIMIZED_STATE_MAXIMIZED,
-
- // Maximized state is explicitly not maximized (normal).
- MAXIMIZED_STATE_UNMAXIMIZED
- };
-
struct CreateParams {
CreateParams(Type type, Profile* profile);
@@ -171,8 +159,8 @@ class Browser : public TabHandlerDelegate,
void set_override_bounds(const gfx::Rect& bounds) {
override_bounds_ = bounds;
}
- void set_maximized_state(MaximizedState state) {
- maximized_state_ = state;
+ void set_show_state(ui::WindowShowState show_state) {
+ show_state_ = show_state;
}
// Return true if the initial window bounds have been overridden.
bool bounds_overridden() const {
@@ -310,9 +298,10 @@ class Browser : public TabHandlerDelegate,
// Save and restore the window position.
std::string GetWindowPlacementKey() const;
bool ShouldSaveWindowPlacement() const;
- void SaveWindowPlacement(const gfx::Rect& bounds, bool maximized);
+ void SaveWindowPlacement(const gfx::Rect& bounds,
+ ui::WindowShowState show_state);
gfx::Rect GetSavedWindowBounds() const;
- bool GetSavedMaximizedState() const;
+ ui::WindowShowState GetSavedWindowShowState() const;
// Gets the Favicon of the page in the selected tab.
SkBitmap GetCurrentPageIcon() const;
@@ -1226,13 +1215,14 @@ class Browser : public TabHandlerDelegate,
/////////////////////////////////////////////////////////////////////////////
- // Override values for the bounds of the window and its maximized state.
+ // Override values for the bounds of the window and its maximized or minimized
+ // state.
// These are supplied by callers that don't want to use the default values.
// The default values are typically loaded from local state (last session),
// obtained from the last window of the same type, or obtained from the
// shell shortcut's startup info.
gfx::Rect override_bounds_;
- MaximizedState maximized_state_;
+ ui::WindowShowState show_state_;
// The following factory is used to close the frame at a later time.
ScopedRunnableMethodFactory<Browser> method_factory_;
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index ff69a66..d8f3a25 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -772,14 +772,14 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) {
#endif // !defined(OS_MACOSX)
// Makes sure the browser doesn't crash when
-// set_maximized_state(MAXIMIZED_STATE_MAXIMIZED) has been invoked.
+// set_show_state(ui::SHOW_STATE_MAXIMIZED) has been invoked.
IN_PROC_BROWSER_TEST_F(BrowserTest, StartMaximized) {
// Can't test TYPE_PANEL as they are currently created differently (and can't
// end up maximized).
Browser::Type types[] = { Browser::TYPE_TABBED, Browser::TYPE_POPUP };
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(types); ++i) {
Browser* max_browser = new Browser(types[i], browser()->profile());
- max_browser->set_maximized_state(Browser::MAXIMIZED_STATE_MAXIMIZED);
+ max_browser->set_show_state(ui::SHOW_STATE_MAXIMIZED);
max_browser->InitBrowserWindow();
AddBlankTabAndShow(max_browser);
}
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h
index 9b9fd07..b74f9fa 100644
--- a/chrome/browser/ui/browser_window.h
+++ b/chrome/browser/ui/browser_window.h
@@ -130,6 +130,9 @@ class BrowserWindow {
// Returns true if the frame is maximized (aka zoomed).
virtual bool IsMaximized() const = 0;
+ // Returns true if the frame is minimized.
+ virtual bool IsMinimized() const = 0;
+
// Accessors for fullscreen mode state.
virtual void SetFullscreen(bool fullscreen) = 0;
virtual bool IsFullscreen() const = 0;
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h
index 410b145..327f409 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h
@@ -27,8 +27,7 @@ class BrowserWindowCocoa : public BrowserWindow,
public NotificationObserver {
public:
BrowserWindowCocoa(Browser* browser,
- BrowserWindowController* controller,
- NSWindow* window);
+ BrowserWindowController* controller);
virtual ~BrowserWindowCocoa();
// Overridden from BrowserWindow
@@ -53,6 +52,7 @@ class BrowserWindowCocoa : public BrowserWindow,
virtual gfx::Rect GetRestoredBounds() const;
virtual gfx::Rect GetBounds() const;
virtual bool IsMaximized() const;
+ virtual bool IsMinimized() const;
virtual void SetFullscreen(bool fullscreen);
virtual bool IsFullscreen() const;
virtual bool IsFullscreenBubbleVisible() const;
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 5faefc7..c87c61a 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -44,11 +44,31 @@
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util_mac.h"
+#include "ui/base/ui_base_types.h"
#include "ui/gfx/rect.h"
+// Replicate specific 10.7 SDK declarations for building with prior SDKs.
+#if !defined(MAC_OS_X_VERSION_10_7) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
+
+enum {
+ NSWindowAnimationBehaviorDefault = 0,
+ NSWindowAnimationBehaviorNone = 2,
+ NSWindowAnimationBehaviorDocumentWindow = 3,
+ NSWindowAnimationBehaviorUtilityWindow = 4,
+ NSWindowAnimationBehaviorAlertPanel = 5
+};
+typedef NSInteger NSWindowAnimationBehavior;
+
+@interface NSWindow (LionSDKDeclarations)
+- (NSWindowAnimationBehavior)animationBehavior;
+- (void)setAnimationBehavior:(NSWindowAnimationBehavior)newAnimationBehavior;
+@end
+
+#endif // MAC_OS_X_VERSION_10_7
+
BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser,
- BrowserWindowController* controller,
- NSWindow* window)
+ BrowserWindowController* controller)
: browser_(browser),
controller_(controller),
confirm_close_factory_(browser) {
@@ -73,11 +93,35 @@ void BrowserWindowCocoa::Show() {
// the previous browser instead if we don't explicitly set it here.
BrowserList::SetLastActive(browser_);
- [window() makeKeyAndOrderFront:controller_];
+ ui::WindowShowState show_state = browser_->GetSavedWindowShowState();
+ if (show_state == ui::SHOW_STATE_MINIMIZED) {
+ // Turn off swishing when restoring minimized windows. When creating
+ // windows from nibs it is necessary to |orderFront:| prior to |orderOut:|
+ // then |miniaturize:| when restoring windows in the minimized state.
+ NSWindowAnimationBehavior savedAnimationBehavior = 0;
+ if ([window() respondsToSelector:@selector(animationBehavior)] &&
+ [window() respondsToSelector:@selector(setAnimationBehavior:)]) {
+ savedAnimationBehavior = [window() animationBehavior];
+ [window() setAnimationBehavior:NSWindowAnimationBehaviorNone];
+ }
+
+ [window() makeKeyAndOrderFront:controller_];
+
+ [window() orderOut:controller_];
+ [window() miniaturize:controller_];
+
+ // Restore window animation behavior.
+ if ([window() respondsToSelector:@selector(animationBehavior)] &&
+ [window() respondsToSelector:@selector(setAnimationBehavior:)]) {
+ [window() setAnimationBehavior:savedAnimationBehavior];
+ }
+ } else {
+ [window() makeKeyAndOrderFront:controller_];
+ }
}
void BrowserWindowCocoa::ShowInactive() {
- [window() orderFront:controller_];
+ [window() orderFront:controller_];
}
void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) {
@@ -214,6 +258,10 @@ bool BrowserWindowCocoa::IsMaximized() const {
return [window() isZoomed];
}
+bool BrowserWindowCocoa::IsMinimized() const {
+ return [window() isMiniaturized];
+}
+
void BrowserWindowCocoa::SetFullscreen(bool fullscreen) {
[controller_ setFullscreen:fullscreen];
}
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm b/chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm
index 3348a5b..66fbda3 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa_unittest.mm
@@ -19,8 +19,8 @@
class BrowserWindowCocoaPong : public BrowserWindowCocoa {
public:
BrowserWindowCocoaPong(Browser* browser,
- BrowserWindowController* controller) :
- BrowserWindowCocoa(browser, controller, [controller window]) {
+ BrowserWindowController* controller)
+ : BrowserWindowCocoa(browser, controller) {
pong_ = false;
}
virtual ~BrowserWindowCocoaPong() { }
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 7f5f04e..5a7cdc2 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -156,8 +156,7 @@
@end
-// Provide the forward-declarations of new 10.7 SDK symbols so they can be
-// called when building with the 10.5 SDK.
+// Replicate specific 10.7 SDK declarations for building with prior SDKs.
#if !defined(MAC_OS_X_VERSION_10_7) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
@@ -223,7 +222,7 @@ enum {
browser_.reset(browser);
ownsBrowser_ = ownIt;
NSWindow* window = [self window];
- windowShim_.reset(new BrowserWindowCocoa(browser, self, window));
+ windowShim_.reset(new BrowserWindowCocoa(browser, self));
// Create the bar visibility lock set; 10 is arbitrary, but should hopefully
// be big enough to hold all locks that'll ever be needed.
@@ -614,6 +613,8 @@ enum {
// Called when we have been minimized.
- (void)windowDidMiniaturize:(NSNotification *)notification {
+ [self saveWindowPositionIfNeeded];
+
// Let the selected RenderWidgetHostView know, so that it can tell plugins.
if (TabContents* contents = browser_->GetSelectedTabContents()) {
if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView())
@@ -1763,6 +1764,8 @@ enum {
// Delegate method called when window is resized.
- (void)windowDidResize:(NSNotification*)notification {
+ [self saveWindowPositionIfNeeded];
+
// Resize (and possibly move) the status bubble. Note that we may get called
// when the status bubble does not exist.
if (statusBubble_) {
@@ -1803,6 +1806,8 @@ enum {
// |-windowWillMove:|, which is called less frequently than |-windowDidMove|
// instead.)
- (void)windowDidMove:(NSNotification*)notification {
+ [self saveWindowPositionIfNeeded];
+
NSWindow* window = [self window];
NSRect windowFrame = [window frame];
NSRect workarea = [[window screen] visibleFrame];
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.h b/chrome/browser/ui/cocoa/browser_window_controller_private.h
index 26c181b..39b1f38 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.h
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.h
@@ -28,9 +28,6 @@
// Saves the window's position in the local state preferences.
- (void)saveWindowPositionIfNeeded;
-// Saves the window's position to the given pref service.
-- (void)saveWindowPositionToPrefs:(PrefService*)prefs;
-
// We need to adjust where sheets come out of the window, as by default they
// erupt from the omnibox, which is rather weird.
- (NSRect)window:(NSWindow*)window
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index bd3512d..3a4b410 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -35,6 +35,7 @@
#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h"
+#include "ui/base/ui_base_types.h"
// Forward-declare symbols that are part of the 10.6 SDK.
#if !defined(MAC_OS_X_VERSION_10_6) || \
@@ -111,18 +112,9 @@ const CGFloat kLocBarBottomInset = 1;
}
- (void)saveWindowPositionIfNeeded {
- if (browser_ != BrowserList::GetLastActive())
+ if (!browser_->ShouldSaveWindowPlacement())
return;
- if (!browser_->profile()->GetPrefs() ||
- !browser_->ShouldSaveWindowPlacement()) {
- return;
- }
-
- [self saveWindowPositionToPrefs:browser_->profile()->GetPrefs()];
-}
-
-- (void)saveWindowPositionToPrefs:(PrefService*)prefs {
// If we're in fullscreen mode, save the position of the regular window
// instead.
NSWindow* window = [self isFullscreen] ? savedRegularWindow_ : [self window];
@@ -144,14 +136,20 @@ const CGFloat kLocBarBottomInset = 1;
gfx::Rect bounds(NSRectToCGRect([window frame]));
bounds.set_y(monitorFrame.size.height - bounds.y() - bounds.height());
- // We also need to save the current work area, in flipped coordinates.
+ // Browser::SaveWindowPlacement saves information for session restore.
+ ui::WindowShowState show_state = [window isMiniaturized] ?
+ ui::SHOW_STATE_MINIMIZED : ui::SHOW_STATE_NORMAL;
+ browser_->SaveWindowPlacement(bounds, show_state);
+
+ // Only save main window information to preferences.
+ PrefService* prefs = browser_->profile()->GetPrefs();
+ if (!prefs || browser_ != BrowserList::GetLastActive())
+ return;
+
+ // Save the current work area, in flipped coordinates.
gfx::Rect workArea(NSRectToCGRect([windowScreen visibleFrame]));
workArea.set_y(monitorFrame.size.height - workArea.y() - workArea.height());
- // Browser::SaveWindowPlacement is used for session restore.
- if (browser_->ShouldSaveWindowPlacement())
- browser_->SaveWindowPlacement(bounds, /*maximized=*/ false);
-
DictionaryPrefUpdate update(prefs, browser_->GetWindowPlacementKey().c_str());
DictionaryValue* windowPreferences = update.Get();
windowPreferences->SetInteger("left", bounds.x());
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
index 0bd0620..533b9a4 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
@@ -7,6 +7,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/sync/sync_ui_util.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/cocoa/browser_test_helper.h"
#include "chrome/browser/ui/cocoa/browser_window_controller.h"
@@ -19,7 +20,7 @@
@interface BrowserWindowController (JustForTesting)
// Already defined in BWC.
-- (void)saveWindowPositionToPrefs:(PrefService*)prefs;
+- (void)saveWindowPositionIfNeeded;
- (void)layoutSubviews;
@end
@@ -92,7 +93,8 @@ TEST_F(BrowserWindowControllerTest, TestSaveWindowPosition) {
// Ask the window to save its position, then check that a preference
// exists.
- [controller_ saveWindowPositionToPrefs:prefs];
+ BrowserList::SetLastActive(browser_helper_.browser());
+ [controller_ saveWindowPositionIfNeeded];
browser_window_placement =
prefs->GetDictionary(prefs::kBrowserWindowPlacement);
ASSERT_TRUE(browser_window_placement);
diff --git a/chrome/browser/ui/cocoa/framed_browser_window.mm b/chrome/browser/ui/cocoa/framed_browser_window.mm
index 712959a..296404e 100644
--- a/chrome/browser/ui/cocoa/framed_browser_window.mm
+++ b/chrome/browser/ui/cocoa/framed_browser_window.mm
@@ -13,8 +13,7 @@
#import "chrome/browser/renderer_host/render_widget_host_view_mac.h"
#include "chrome/browser/themes/theme_service.h"
-// Provide the forward-declarations of new 10.7 SDK symbols so they can be
-// called when building with the 10.5 SDK.
+// Replicate specific 10.7 SDK declarations for building with prior SDKs.
#if !defined(MAC_OS_X_VERSION_10_7) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
index d63f04f..bcc5028 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
@@ -67,21 +67,6 @@
NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged";
-// 10.7 adds public APIs for full-screen support. Provide the declaration so it
-// can be called below when building with the 10.5 SDK.
-#if !defined(MAC_OS_X_VERSION_10_7) || \
-MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
-
-@interface NSWindow (LionSDKDeclarations)
-- (void)toggleFullScreen:(id)sender;
-@end
-
-enum {
- NSWindowFullScreenButton = 7
-};
-
-#endif // MAC_OS_X_VERSION_10_7
-
namespace {
// A value to indicate tab layout should use the full available width of the
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm
index 8873af6..1a92665 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.mm
@@ -11,8 +11,7 @@
#import "chrome/browser/ui/cocoa/tabs/tab_view.h"
#import "chrome/browser/ui/cocoa/tabs/tab_window_controller.h"
-// Provide the forward-declarations of new 10.7 SDK symbols so they can be
-// called when building with the 10.5 SDK.
+// Replicate specific 10.7 SDK declarations for building with prior SDKs.
#if !defined(MAC_OS_X_VERSION_10_7) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index 4b4dea8..3b7219f 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -324,7 +324,7 @@ BrowserWindowGtk::BrowserWindowGtk(Browser* browser)
frame_cursor_(NULL),
is_active_(!ui::ActiveWindowWatcherX::WMSupportsActivation()),
last_click_time_(0),
- maximize_after_show_(false),
+ show_state_after_show_(ui::SHOW_STATE_DEFAULT),
suppress_window_raise_(false),
accel_group_(NULL),
debounce_timer_disabled_(false) {
@@ -646,9 +646,12 @@ void BrowserWindowGtk::Show() {
BrowserList::SetLastActive(browser());
gtk_window_present(window_);
- if (maximize_after_show_) {
+ if (show_state_after_show_ == ui::SHOW_STATE_MAXIMIZED) {
gtk_window_maximize(window_);
- maximize_after_show_ = false;
+ show_state_after_show_ = ui::SHOW_STATE_NORMAL;
+ } else if (show_state_after_show_ == ui::SHOW_STATE_MINIMIZED) {
+ gtk_window_iconify(window_);
+ show_state_after_show_ = ui::SHOW_STATE_NORMAL;
}
// If we have sized the window by setting a size request for the render
@@ -837,6 +840,10 @@ bool BrowserWindowGtk::IsMaximized() const {
return (state_ & GDK_WINDOW_STATE_MAXIMIZED);
}
+bool BrowserWindowGtk::IsMinimized() const {
+ return (state_ & GDK_WINDOW_STATE_ICONIFIED);
+}
+
bool BrowserWindowGtk::ShouldDrawContentDropShadow() {
return !IsMaximized() && UseCustomFrame();
}
@@ -1602,7 +1609,7 @@ void BrowserWindowGtk::SetGeometryHints() {
// confused and maximizes the window, but doesn't set the
// GDK_WINDOW_STATE_MAXIMIZED bit. So instead, we keep track of whether to
// maximize and call it after gtk_window_present.
- maximize_after_show_ = browser_->GetSavedMaximizedState();
+ show_state_after_show_ = browser_->GetSavedWindowShowState();
gfx::Rect bounds = browser_->GetSavedWindowBounds();
// We don't blindly call SetBounds here: that sets a forced position
@@ -1891,8 +1898,14 @@ void BrowserWindowGtk::UpdateCustomFrame() {
void BrowserWindowGtk::SaveWindowPosition() {
// Browser::SaveWindowPlacement is used for session restore.
+ ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL;
+ if (IsMaximized())
+ show_state = ui::SHOW_STATE_MAXIMIZED;
+ else if (IsMinimized())
+ show_state = ui::SHOW_STATE_MINIMIZED;
+
if (browser_->ShouldSaveWindowPlacement())
- browser_->SaveWindowPlacement(restored_bounds_, IsMaximized());
+ browser_->SaveWindowPlacement(restored_bounds_, show_state);
// We also need to save the placement for startup.
// This is a web of calls between views and delegates on Windows, but the
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h
index c7fd581..ecb2e3c 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.h
+++ b/chrome/browser/ui/gtk/browser_window_gtk.h
@@ -18,6 +18,7 @@
#include "chrome/browser/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/browser_window.h"
#include "ui/base/gtk/gtk_signal.h"
+#include "ui/base/ui_base_types.h"
#include "ui/base/x/active_window_watcher_x.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/rect.h"
@@ -76,6 +77,7 @@ class BrowserWindowGtk : public BrowserWindow,
virtual gfx::Rect GetRestoredBounds() const;
virtual gfx::Rect GetBounds() const;
virtual bool IsMaximized() const;
+ virtual bool IsMinimized() const;
virtual void SetFullscreen(bool fullscreen);
virtual bool IsFullscreen() const;
virtual bool IsFullscreenBubbleVisible() const;
@@ -491,9 +493,10 @@ class BrowserWindowGtk : public BrowserWindow,
guint32 last_click_time_;
gfx::Point last_click_position_;
- // If true, maximize the window after we call BrowserWindow::Show for the
- // first time. This is to work around a compiz bug.
- bool maximize_after_show_;
+ // Optionally maximize or minimize the window after we call
+ // BrowserWindow::Show for the first time. This is to work around a compiz
+ // bug.
+ ui::WindowShowState show_state_after_show_;
// If true, don't call gdk_window_raise() when we get a click in the title
// bar or window border. This is to work around a compiz bug.
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index 7fc539b..102ac60b 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -163,6 +163,11 @@ bool Panel::IsMaximized() const {
return false;
}
+bool Panel::IsMinimized() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
void Panel::SetFullscreen(bool fullscreen) {
NOTIMPLEMENTED();
}
diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h
index 3966ce3..af9b6214 100644
--- a/chrome/browser/ui/panels/panel.h
+++ b/chrome/browser/ui/panels/panel.h
@@ -68,6 +68,7 @@ class Panel : public BrowserWindow {
virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
virtual gfx::Rect GetBounds() const OVERRIDE;
virtual bool IsMaximized() const OVERRIDE;
+ virtual bool IsMinimized() const OVERRIDE;
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
virtual bool IsFullscreenBubbleVisible() const OVERRIDE;
diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc
index acaf68f..20f685a 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -48,7 +48,8 @@ void BrowserFrame::InitBrowserFrame() {
// Typed panel/popup can only return a size once the widget has been
// created.
params.bounds = browser_view_->browser()->GetSavedWindowBounds();
- params.maximize = browser_view_->browser()->GetSavedMaximizedState();
+ params.maximize = browser_view_->browser()->GetSavedWindowShowState() ==
+ ui::SHOW_STATE_MAXIMIZED;
}
Init(params);
#if defined(OS_CHROMEOS)
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 59906b5e..e206a6d 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -783,6 +783,12 @@ bool BrowserView::IsMaximized() const {
return frame_->IsMaximized();
}
+bool BrowserView::IsMinimized() const {
+ // TODO(dhollowa): Add support for session restore of minimized state.
+ // http://crbug.com/43274
+ return false;
+}
+
void BrowserView::SetFullscreen(bool fullscreen) {
if (IsFullscreen() == fullscreen)
return; // Nothing to do.
@@ -1623,12 +1629,17 @@ std::wstring BrowserView::GetWindowName() const {
void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds,
bool maximized) {
+ // TODO(dhollowa): Add support for session restore of minimized state.
+ // http://crbug.com/43274
+
// If IsFullscreen() is true, we've just changed into fullscreen mode, and
// we're catching the going-into-fullscreen sizing and positioning calls,
// which we want to ignore.
if (!IsFullscreen() && browser_->ShouldSaveWindowPlacement()) {
WidgetDelegate::SaveWindowPlacement(bounds, maximized);
- browser_->SaveWindowPlacement(bounds, maximized);
+ browser_->SaveWindowPlacement(bounds,
+ maximized ? ui::SHOW_STATE_MAXIMIZED :
+ ui::SHOW_STATE_NORMAL);
}
}
@@ -1672,7 +1683,9 @@ bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
}
bool BrowserView::GetSavedMaximizedState(bool* maximized) const {
- *maximized = browser_->GetSavedMaximizedState();
+ // TODO(dhollowa): Add support for session restore of minimized state.
+ // http://crbug.com/43274
+ *maximized = browser_->GetSavedWindowShowState() == ui::SHOW_STATE_MAXIMIZED;
return true;
}
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index 28ae5c9..66aba98 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -270,6 +270,7 @@ class BrowserView : public BrowserBubbleHost,
virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
virtual gfx::Rect GetBounds() const OVERRIDE;
virtual bool IsMaximized() const OVERRIDE;
+ virtual bool IsMinimized() const OVERRIDE;
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
virtual LocationBar* GetLocationBar() const OVERRIDE;