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

Unified Diff: chrome/browser/cocoa/page_info_window_controller.mm

Issue 536086: Mac: Save/restore task manager window pos and size. (Closed)
Patch Set: comments Created 10 years, 11 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/cocoa/page_info_window_controller.mm
diff --git a/chrome/browser/cocoa/page_info_window_controller.mm b/chrome/browser/cocoa/page_info_window_controller.mm
index 04c8049ab268673f6b0ecbbe2e85bd2a1d85a137..144cfcb4db38abeb41e1732f41f1a0eb7e7eae9a 100644
--- a/chrome/browser/cocoa/page_info_window_controller.mm
+++ b/chrome/browser/cocoa/page_info_window_controller.mm
@@ -8,17 +8,12 @@
#include "base/mac_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#import "chrome/browser/cocoa/nswindow_local_state.h"
#include "chrome/browser/cocoa/page_info_window_mac.h"
+#include "chrome/browser/cocoa/window_size_autosaver.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "grit/theme_resources.h"
-@interface PageInfoWindowController (Private)
-// Saves the window preference to the local state.
-- (void)saveWindowPositionToLocalState;
-@end
-
@implementation PageInfoWindowController
@synthesize identityImg = identityImg_;
@synthesize connectionImg = connectionImg_;
@@ -36,18 +31,24 @@
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
goodImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_GOOD) retain]);
badImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_BAD) retain]);
+
+ if (g_browser_process && g_browser_process->local_state()) {
+ sizeSaver_.reset([[WindowSizeAutosaver alloc]
+ initWithWindow:[self window]
+ prefService:g_browser_process->local_state()
+ path:prefs::kPageInfoWindowPlacement
+ state:kSaveWindowPos]);
+ // Cascade again to get the offset when opening new windows.
+ NSRect frame = [[self window] frame];
+ NSPoint cascadePoint = [[self window]
+ cascadeTopLeftFromPoint:NSMakePoint(NSMinX(frame), NSMaxY(frame))];
+ [[self window] cascadeTopLeftFromPoint:cascadePoint];
+ }
}
return self;
}
- (void)awakeFromNib {
- if (g_browser_process && g_browser_process->local_state()) {
- // Get the positioning information.
- PrefService* prefs = g_browser_process->local_state();
- [[self window] restoreWindowPositionFromPrefs:prefs
- withPath:prefs::kPageInfoWindowPlacement];
- }
-
// By default, assume we have no history information.
[self setShowHistoryBox:NO];
}
@@ -103,12 +104,4 @@
[self autorelease];
}
-// The last page info window that was moved will determine the location of the
-// next new one.
-- (void)windowDidMove:(NSNotification*)notif {
- if (g_browser_process && g_browser_process->local_state())
- [[self window] saveWindowPositionToPrefs:g_browser_process->local_state()
- withPath:prefs::kPageInfoWindowPlacement];
-}
-
@end

Powered by Google App Engine
This is Rietveld 408576698