@@ -170,17 +170,18 @@ void MakeShellButton(NSRect* rect,
170170}
171171
172172void Shell::PlatformCreateWindow (int width, int height) {
173+ is_toolbar_open_ = true ;
174+ if (window_manifest_)
175+ window_manifest_->GetBoolean (switches::kmToolbar, &is_toolbar_open_);
176+ int window_height = is_toolbar_open_ ? height + kURLBarHeight : height;
177+
173178 NSRect initial_window_bounds =
174- NSMakeRect (0 , 0 , width, height + kURLBarHeight );
179+ NSMakeRect (0 , 0 , width, window_height );
175180 NSRect content_rect = initial_window_bounds;
176181 NSUInteger style_mask = NSTitledWindowMask |
177182 NSClosableWindowMask |
178183 NSMiniaturizableWindowMask |
179184 NSResizableWindowMask ;
180- if (CommandLine::ForCurrentProcess ()->HasSwitch (switches::kDumpRenderTree )) {
181- content_rect = NSOffsetRect (initial_window_bounds, -10000 , -10000 );
182- style_mask = NSBorderlessWindowMask ;
183- }
184185 CrShellWindow* window =
185186 [[CrShellWindow alloc ] initWithContentRect: content_rect
186187 styleMask: style_mask
@@ -194,7 +195,7 @@ void MakeShellButton(NSRect* rect,
194195 if (window_manifest_) {
195196 int w = width;
196197 int h = height;
197- bool set = window_manifest_->GetInteger (switches::kmMinWidth, &w) ||
198+ bool set = window_manifest_->GetInteger (switches::kmMinWidth, &w) |
198199 window_manifest_->GetInteger (switches::kmMinHeight, &h);
199200
200201 if (set) {
@@ -205,15 +206,15 @@ void MakeShellButton(NSRect* rect,
205206 [window_ setContentMinSize: min_size];
206207 }
207208
208- set = window_manifest_->GetInteger (switches::kmMaxWidth, &w) ||
209+ set = window_manifest_->GetInteger (switches::kmMaxWidth, &w) |
209210 window_manifest_->GetInteger (switches::kmMaxHeight, &h);
210211
211212 if (set) {
212213 // If the window is allowed to get too small, it will wreck the view bindings.
213- NSSize min_size = NSMakeSize (w, h);
214- min_size = [content convertSize: min_size toView: nil ];
214+ NSSize max_size = NSMakeSize (w, h);
215+ max_size = [content convertSize: max_size toView: nil ];
215216 // Note that this takes window coordinates.
216- [window_ setContentMaxSize: min_size ];
217+ [window_ setContentMaxSize: max_size ];
217218 }
218219 }
219220
@@ -235,30 +236,32 @@ void MakeShellButton(NSRect* rect,
235236 [[ContentShellWindowDelegate alloc ] initWithShell: this ];
236237 [window_ setDelegate: delegate];
237238
238- NSRect button_frame =
239- NSMakeRect (0 , NSMaxY (initial_window_bounds) - kURLBarHeight,
240- kButtonWidth, kURLBarHeight);
241-
242- MakeShellButton (&button_frame, @" Back" , content, IDC_NAV_BACK ,
243- (NSView *)delegate, @" [" , NSCommandKeyMask );
244- MakeShellButton (&button_frame, @" Forward" , content, IDC_NAV_FORWARD ,
245- (NSView *)delegate, @" ]" , NSCommandKeyMask );
246- MakeShellButton (&button_frame, @" Reload" , content, IDC_NAV_RELOAD ,
247- (NSView *)delegate, @" r" , NSCommandKeyMask );
248- MakeShellButton (&button_frame, @" Stop" , content, IDC_NAV_STOP ,
249- (NSView *)delegate, @" ." , NSCommandKeyMask );
250-
251- button_frame.size .width =
252- NSWidth (initial_window_bounds) - NSMinX(button_frame);
253- scoped_nsobject<NSTextField > url_edit_view (
254- [[NSTextField alloc ] initWithFrame: button_frame]);
255- [content addSubview: url_edit_view];
256- [url_edit_view setAutoresizingMask: (NSViewWidthSizable | NSViewMinYMargin)];
257- [url_edit_view setTarget: delegate];
258- [url_edit_view setAction: @selector (takeURLStringValueFrom: )];
259- [[url_edit_view cell ] setWraps: NO ];
260- [[url_edit_view cell ] setScrollable: YES ];
261- url_edit_view_ = url_edit_view.get ();
239+ if (is_toolbar_open_) {
240+ NSRect button_frame =
241+ NSMakeRect (0 , NSMaxY (initial_window_bounds) - kURLBarHeight,
242+ kButtonWidth, kURLBarHeight);
243+
244+ MakeShellButton (&button_frame, @" Back" , content, IDC_NAV_BACK ,
245+ (NSView *)delegate, @" [" , NSCommandKeyMask );
246+ MakeShellButton (&button_frame, @" Forward" , content, IDC_NAV_FORWARD ,
247+ (NSView *)delegate, @" ]" , NSCommandKeyMask );
248+ MakeShellButton (&button_frame, @" Reload" , content, IDC_NAV_RELOAD ,
249+ (NSView *)delegate, @" r" , NSCommandKeyMask );
250+ MakeShellButton (&button_frame, @" Stop" , content, IDC_NAV_STOP ,
251+ (NSView *)delegate, @" ." , NSCommandKeyMask );
252+
253+ button_frame.size .width =
254+ NSWidth (initial_window_bounds) - NSMinX(button_frame);
255+ scoped_nsobject<NSTextField > url_edit_view (
256+ [[NSTextField alloc ] initWithFrame: button_frame]);
257+ [content addSubview: url_edit_view];
258+ [url_edit_view setAutoresizingMask: (NSViewWidthSizable | NSViewMinYMargin)];
259+ [url_edit_view setTarget: delegate];
260+ [url_edit_view setAction: @selector (takeURLStringValueFrom: )];
261+ [[url_edit_view cell ] setWraps: NO ];
262+ [[url_edit_view cell ] setScrollable: YES ];
263+ url_edit_view_ = url_edit_view.get ();
264+ }
262265
263266 // show the window
264267 [window_ makeKeyAndOrderFront: nil ];
@@ -270,7 +273,9 @@ void MakeShellButton(NSRect* rect,
270273 [content addSubview: web_view];
271274
272275 NSRect frame = [content bounds ];
273- frame.size .height -= kURLBarHeight ;
276+ if (is_toolbar_open_) {
277+ frame.size .height -= kURLBarHeight ;
278+ }
274279 [web_view setFrame: frame];
275280 [web_view setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
276281 [web_view setNeedsDisplay: YES ];
0 commit comments