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

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_web_dialog_sheet.mm

Issue 2275413002: Make the MediaRouterDialogDelegate set initial dialog size in OSX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use kWindowSizeDeterminedLater Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/cocoa/constrained_window/constrained_window_web_dialo g_sheet.h" 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_web_dialo g_sheet.h"
6 6
7 #import "ui/base/cocoa/window_size_constants.h"
7 #include "ui/gfx/geometry/size.h" 8 #include "ui/gfx/geometry/size.h"
8 #include "ui/web_dialogs/web_dialog_delegate.h" 9 #include "ui/web_dialogs/web_dialog_delegate.h"
9 10
10 @implementation WebDialogConstrainedWindowSheet 11 @implementation WebDialogConstrainedWindowSheet
11 12
12 - (id)initWithCustomWindow:(NSWindow*)customWindow 13 - (id)initWithCustomWindow:(NSWindow*)customWindow
13 webDialogDelegate:(ui::WebDialogDelegate*)delegate { 14 webDialogDelegate:(ui::WebDialogDelegate*)delegate {
14 if (self = [super initWithCustomWindow:customWindow]) { 15 if (self = [super initWithCustomWindow:customWindow]) {
16 current_size_ = ui::kWindowSizeDeterminedLater.size;
15 web_dialog_delegate_ = delegate; 17 web_dialog_delegate_ = delegate;
16 } 18 }
17 19
18 return self; 20 return self;
19 } 21 }
20 22
21 - (void)updateSheetPosition { 23 - (void)updateSheetPosition {
22 if (web_dialog_delegate_) { 24 if (web_dialog_delegate_) {
23 gfx::Size size; 25 gfx::Size size;
24 web_dialog_delegate_->GetDialogSize(&size); 26 web_dialog_delegate_->GetDialogSize(&size);
25 27
26 // If the dialog has autoresizing enabled, |size| will be empty. Use the 28 // If the dialog has autoresizing enabled, |size| will be empty. Use the
27 // last known dialog size. 29 // last known dialog size.
28 NSSize content_size = size.IsEmpty() ? current_size_ : 30 NSSize content_size = size.IsEmpty() ? current_size_ :
29 NSMakeSize(size.width(), size.height()); 31 NSMakeSize(size.width(), size.height());
30 [customWindow_ setContentSize:content_size]; 32 [customWindow_ setContentSize:content_size];
31 } 33 }
32 [super updateSheetPosition]; 34 [super updateSheetPosition];
33 } 35 }
34 36
35 - (void)resizeWithNewSize:(NSSize)size { 37 - (void)resizeWithNewSize:(NSSize)size {
38 DCHECK(size.height > 0 && size.width > 0);
36 current_size_ = size; 39 current_size_ = size;
37 [customWindow_ setContentSize:current_size_]; 40 [customWindow_ setContentSize:current_size_];
38 41
39 // self's updateSheetPosition() sets |customWindow_|'s contentSize to a 42 // self's updateSheetPosition() sets |customWindow_|'s contentSize to a
40 // fixed dialog size. Here, we want to resize to |size| instead. Use 43 // fixed dialog size. Here, we want to resize to |size| instead. Use
41 // super rather than self to bypass the setContentSize() call for the fixed 44 // super rather than self to bypass the setContentSize() call for the fixed
42 // size. 45 // size.
43 [super updateSheetPosition]; 46 [super updateSheetPosition];
44 } 47 }
45 48
46 @end 49 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698