summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 21:37:49 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-19 21:37:49 +0000
commitfb3bc70d9eb0de33d0bf9ccfa8e17f11c755e7d7 (patch)
tree883e4619432952d4011a2ab1d61d9ecc3d13efb4 /chrome/browser
parent1d1c3263f9e360765b49c33f6e232e98ecc49338 (diff)
downloadchromium_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')
-rw-r--r--chrome/browser/cocoa/browser_window_cocoa.mm6
-rw-r--r--chrome/browser/cocoa/html_dialog_window_controller.h14
-rw-r--r--chrome/browser/cocoa/html_dialog_window_controller.mm36
-rw-r--r--chrome/browser/cocoa/html_dialog_window_controller_unittest.mm4
4 files changed, 16 insertions, 44 deletions
diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm
index ee22726..d7d19d5 100644
--- a/chrome/browser/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/cocoa/browser_window_cocoa.mm
@@ -318,12 +318,8 @@ void BrowserWindowCocoa::ConfirmBrowserCloseWithPendingDownloads() {
void BrowserWindowCocoa::ShowHTMLDialog(HtmlDialogUIDelegate* delegate,
gfx::NativeWindow parent_window) {
- if (!parent_window) {
- parent_window = GetNativeHandle();
- }
[HtmlDialogWindowController showHtmlDialog:delegate
- profile:browser_->profile()
- parentWindow:parent_window];
+ profile:browser_->profile()];
}
void BrowserWindowCocoa::UserChangedTheme() {
diff --git a/chrome/browser/cocoa/html_dialog_window_controller.h b/chrome/browser/cocoa/html_dialog_window_controller.h
index f18b3f8..3996981 100644
--- a/chrome/browser/cocoa/html_dialog_window_controller.h
+++ b/chrome/browser/cocoa/html_dialog_window_controller.h
@@ -10,7 +10,6 @@
#import <Cocoa/Cocoa.h>
-#include "app/gfx/native_widget_types.h"
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/dom_ui/html_dialog_ui.h"
@@ -34,14 +33,10 @@ class TabContents;
}
// Creates and shows an HtmlDialogWindowController with the given
-// delegate, parent window, and profile, none of which may be NULL.
-// The window is automatically destroyed when it is closed.
-//
-// TODO(akalin): Handle a NULL parentWindow as HTML dialogs may be launched
-// without any browser windows being present (on OS X).
+// delegate and profile. The window is automatically destroyed when it is
+// closed.
+ (void)showHtmlDialog:(HtmlDialogUIDelegate*)delegate
- profile:(Profile*)profile
- parentWindow:(gfx::NativeWindow)parent_window;
+ profile:(Profile*)profile;
@end
@@ -50,8 +45,7 @@ class TabContents;
// This is the designated initializer. However, this is exposed only
// for testing; use showHtmlDialog instead.
- (id)initWithDelegate:(HtmlDialogUIDelegate*)delegate
- profile:(Profile*)profile
- parentWindow:(gfx::NativeWindow)parentWindow;
+ profile:(Profile*)profile;
// Loads the HTML content from the delegate; this is not a lightweight
// process which is why it is not part of the constructor. Must be
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()));
diff --git a/chrome/browser/cocoa/html_dialog_window_controller_unittest.mm b/chrome/browser/cocoa/html_dialog_window_controller_unittest.mm
index 13eb6e8..59ad8da 100644
--- a/chrome/browser/cocoa/html_dialog_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/html_dialog_window_controller_unittest.mm
@@ -79,11 +79,9 @@ TEST_F(HtmlDialogWindowControllerTest, showDialog) {
EXPECT_CALL(delegate_, OnDialogClosed(_))
.Times(1);
- NSWindow* parentWindow = cocoa_helper_.window();
HtmlDialogWindowController* html_dialog_window_controller =
[[HtmlDialogWindowController alloc] initWithDelegate:&delegate_
- profile:profile()
- parentWindow:parentWindow];
+ profile:profile()];
[html_dialog_window_controller loadDialogContents];
[html_dialog_window_controller showWindow:nil];