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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/page_info_window_controller.h" 5 #import "chrome/browser/cocoa/page_info_window_controller.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #import "chrome/browser/cocoa/nswindow_local_state.h"
12 #include "chrome/browser/cocoa/page_info_window_mac.h" 11 #include "chrome/browser/cocoa/page_info_window_mac.h"
12 #include "chrome/browser/cocoa/window_size_autosaver.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "chrome/common/pref_service.h" 14 #include "chrome/common/pref_service.h"
15 #include "grit/theme_resources.h" 15 #include "grit/theme_resources.h"
16 16
17 @interface PageInfoWindowController (Private)
18 // Saves the window preference to the local state.
19 - (void)saveWindowPositionToLocalState;
20 @end
21
22 @implementation PageInfoWindowController 17 @implementation PageInfoWindowController
23 @synthesize identityImg = identityImg_; 18 @synthesize identityImg = identityImg_;
24 @synthesize connectionImg = connectionImg_; 19 @synthesize connectionImg = connectionImg_;
25 @synthesize historyImg = historyImg_; 20 @synthesize historyImg = historyImg_;
26 @synthesize identityMsg = identityMsg_; 21 @synthesize identityMsg = identityMsg_;
27 @synthesize connectionMsg = connectionMsg_; 22 @synthesize connectionMsg = connectionMsg_;
28 @synthesize historyMsg = historyMsg_; 23 @synthesize historyMsg = historyMsg_;
29 @synthesize enableCertButton = enableCertButton_; 24 @synthesize enableCertButton = enableCertButton_;
30 25
31 - (id)init { 26 - (id)init {
32 NSBundle* bundle = mac_util::MainAppBundle(); 27 NSBundle* bundle = mac_util::MainAppBundle();
33 NSString* nibpath = [bundle pathForResource:@"PageInfo" ofType:@"nib"]; 28 NSString* nibpath = [bundle pathForResource:@"PageInfo" ofType:@"nib"];
34 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { 29 if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
35 // Load the image refs. 30 // Load the image refs.
36 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 31 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
37 goodImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_GOOD) retain]); 32 goodImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_GOOD) retain]);
38 badImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_BAD) retain]); 33 badImg_.reset([rb.GetNSImageNamed(IDR_PAGEINFO_BAD) retain]);
34
35 if (g_browser_process && g_browser_process->local_state()) {
36 sizeSaver_.reset([[WindowSizeAutosaver alloc]
37 initWithWindow:[self window]
38 prefService:g_browser_process->local_state()
39 path:prefs::kPageInfoWindowPlacement
40 state:kSaveWindowPos]);
41 // Cascade again to get the offset when opening new windows.
42 NSRect frame = [[self window] frame];
43 NSPoint cascadePoint = [[self window]
44 cascadeTopLeftFromPoint:NSMakePoint(NSMinX(frame), NSMaxY(frame))];
45 [[self window] cascadeTopLeftFromPoint:cascadePoint];
46 }
39 } 47 }
40 return self; 48 return self;
41 } 49 }
42 50
43 - (void)awakeFromNib { 51 - (void)awakeFromNib {
44 if (g_browser_process && g_browser_process->local_state()) {
45 // Get the positioning information.
46 PrefService* prefs = g_browser_process->local_state();
47 [[self window] restoreWindowPositionFromPrefs:prefs
48 withPath:prefs::kPageInfoWindowPlacement];
49 }
50
51 // By default, assume we have no history information. 52 // By default, assume we have no history information.
52 [self setShowHistoryBox:NO]; 53 [self setShowHistoryBox:NO];
53 } 54 }
54 55
55 - (void)dealloc { 56 - (void)dealloc {
56 [identityImg_ release]; 57 [identityImg_ release];
57 [connectionImg_ release]; 58 [connectionImg_ release];
58 [historyImg_ release]; 59 [historyImg_ release];
59 [identityMsg_ release]; 60 [identityMsg_ release];
60 [connectionMsg_ release]; 61 [connectionMsg_ release];
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 97
97 [window setFrame:frame display:YES animate:YES]; 98 [window setFrame:frame display:YES animate:YES];
98 } 99 }
99 100
100 // If the page info window gets closed, we have nothing left to manage and we 101 // If the page info window gets closed, we have nothing left to manage and we
101 // can clean ourselves up. 102 // can clean ourselves up.
102 - (void)windowWillClose:(NSNotification*)notif { 103 - (void)windowWillClose:(NSNotification*)notif {
103 [self autorelease]; 104 [self autorelease];
104 } 105 }
105 106
106 // The last page info window that was moved will determine the location of the
107 // next new one.
108 - (void)windowDidMove:(NSNotification*)notif {
109 if (g_browser_process && g_browser_process->local_state())
110 [[self window] saveWindowPositionToPrefs:g_browser_process->local_state()
111 withPath:prefs::kPageInfoWindowPlacement];
112 }
113
114 @end 107 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698