diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 21:37:49 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 21:37:49 +0000 |
commit | fb3bc70d9eb0de33d0bf9ccfa8e17f11c755e7d7 (patch) | |
tree | 883e4619432952d4011a2ab1d61d9ecc3d13efb4 /chrome/browser/cocoa/html_dialog_window_controller.mm | |
parent | 1d1c3263f9e360765b49c33f6e232e98ecc49338 (diff) | |
download | chromium_src-fb3bc70d9eb0de33d0bf9ccfa8e17f11c755e7d7.zip chromium_src-fb3bc70d9eb0de33d0bf9ccfa8e17f11c755e7d7.tar.gz chromium_src-fb3bc70d9eb0de33d0bf9ccfa8e17f11c755e7d7.tar.bz2 |
Removed parentWindow parameter from HtmlDialogWindowController.
Center HTML dialogs using [window screen].
BUG=
TEST=manual
Review URL: http://codereview.chromium.org/407010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32549 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/html_dialog_window_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/html_dialog_window_controller.mm | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/chrome/browser/cocoa/html_dialog_window_controller.mm b/chrome/browser/cocoa/html_dialog_window_controller.mm index 15ad812..73c30cd 100644 --- a/chrome/browser/cocoa/html_dialog_window_controller.mm +++ b/chrome/browser/cocoa/html_dialog_window_controller.mm @@ -120,7 +120,9 @@ bool HtmlDialogWindowDelegateBridge::DelegateOnDialogClosed( // to NULL when the window is closed. bool HtmlDialogWindowDelegateBridge::IsDialogModal() const { - // TODO(akalin): Support modal dialog boxes. + // TODO(akalin): Support modal dialog boxes. Or remove support for modal + // dialog boxes entirely, since both users of HTML dialogs don't require + // modal dialogs. if (delegate_ && delegate_->IsDialogModal()) { LOG(WARNING) << "Modal HTML dialogs are not supported yet"; } @@ -241,45 +243,26 @@ void HtmlDialogWindowDelegateBridge::UpdateTargetURL( @implementation HtmlDialogWindowController + (void)showHtmlDialog:(HtmlDialogUIDelegate*)delegate - profile:(Profile*)profile - parentWindow:(gfx::NativeWindow)parentWindow { + profile:(Profile*)profile { HtmlDialogWindowController* htmlDialogWindowController = [[HtmlDialogWindowController alloc] initWithDelegate:delegate - profile:profile - parentWindow:parentWindow]; + profile:profile]; [htmlDialogWindowController loadDialogContents]; [htmlDialogWindowController showWindow:nil]; } - (id)initWithDelegate:(HtmlDialogUIDelegate*)delegate - profile:(Profile*)profile - parentWindow:(gfx::NativeWindow)parentWindow { + profile:(Profile*)profile { DCHECK(delegate); DCHECK(profile); - DCHECK(parentWindow); - // Put the dialog box in the center of the window. - // - // TODO(akalin): Surely there must be a cleaner way to do this. - // - // TODO(akalin): Perhaps use [window center] instead, which centers - // the dialog to the screen, although it doesn't match the Windows - // behavior. - NSRect parentWindowFrame = [parentWindow frame]; - NSPoint parentWindowOrigin = parentWindowFrame.origin; - NSSize parentWindowSize = parentWindowFrame.size; gfx::Size dialogSize; delegate->GetDialogSize(&dialogSize); - NSRect dialogRect = - NSMakeRect(parentWindowOrigin.x + - (parentWindowSize.width - dialogSize.width()) / 2, - parentWindowOrigin.y + - (parentWindowSize.height - dialogSize.height()) / 2, - dialogSize.width(), - dialogSize.height()); + NSRect dialogRect = NSMakeRect(0, 0, dialogSize.width(), dialogSize.height()); // TODO(akalin): Make the window resizable (but with the minimum size being // dialog_size and always on top (but not modal) to match the Windows - // behavior. + // behavior. On the other hand, the fact that HTML dialogs on Windows + // are resizable could just be an accident. Investigate futher... NSUInteger style = NSTitledWindowMask | NSClosableWindowMask; scoped_nsobject<ChromeEventProcessingWindow> window( [[ChromeEventProcessingWindow alloc] @@ -297,6 +280,7 @@ void HtmlDialogWindowDelegateBridge::UpdateTargetURL( [window setWindowController:self]; [window setDelegate:self]; [window setTitle:base::SysWideToNSString(delegate->GetDialogTitle())]; + [window center]; browser_.reset(new Browser(Browser::TYPE_NORMAL, profile)); delegate_.reset( new HtmlDialogWindowDelegateBridge(self, delegate, browser_.get())); |