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

Unified Diff: chrome/browser/cocoa/repost_form_warning_mac.mm

Issue 969003: Make repost form warning tab-modal on Mac. (Closed)
Patch Set: Remove an unnecessary line. Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/repost_form_warning_mac.h ('k') | chrome/browser/cocoa/toolbar_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/repost_form_warning_mac.mm
diff --git a/chrome/browser/cocoa/repost_form_warning_mac.mm b/chrome/browser/cocoa/repost_form_warning_mac.mm
index 2ca64d8e74ee06bd8819bd1dfa85a00050871dbe..31292c04a160e84b4e5b884c10a807ffd7bd4e65 100644
--- a/chrome/browser/cocoa/repost_form_warning_mac.mm
+++ b/chrome/browser/cocoa/repost_form_warning_mac.mm
@@ -41,64 +41,84 @@
RepostFormWarningMac::RepostFormWarningMac(
NSWindow* parent,
- NavigationController* navigation_controller)
- : navigation_controller_(navigation_controller),
- alert_([[NSAlert alloc] init]),
- delegate_([[RepostDelegate alloc] initWithWarning:this]) {
- [alert_ setMessageText:
+ TabContents* tab_contents)
+ : ConstrainedWindowMacDelegateSystemSheet(
+ [[[RepostDelegate alloc] initWithWarning:this] autorelease],
+ @selector(alertDidEnd:returnCode:contextInfo:)),
+ navigation_controller_(&tab_contents->controller()) {
+ scoped_nsobject<NSAlert> alert([[NSAlert alloc] init]);
+ [alert setMessageText:
l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING_TITLE)];
- [alert_ setInformativeText:
+ [alert setInformativeText:
l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING)];
- [alert_ addButtonWithTitle:
+ [alert addButtonWithTitle:
l10n_util::GetNSStringWithFixup(IDS_HTTP_POST_WARNING_RESEND)];
- [alert_ addButtonWithTitle:
+ [alert addButtonWithTitle:
l10n_util::GetNSStringWithFixup(IDS_CANCEL)];
- [alert_ beginSheetModalForWindow:parent
- modalDelegate:delegate_.get()
- didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
- contextInfo:nil];
+ set_sheet(alert);
registrar_.Add(this, NotificationType::LOAD_START,
Source<NavigationController>(navigation_controller_));
registrar_.Add(this, NotificationType::TAB_CLOSING,
Source<NavigationController>(navigation_controller_));
+ registrar_.Add(this, NotificationType::RELOADING,
+ Source<NavigationController>(navigation_controller_));
+ window_ = tab_contents->CreateConstrainedDialog(this);
}
RepostFormWarningMac::~RepostFormWarningMac() {
}
+void RepostFormWarningMac::DeleteDelegate() {
+ window_ = NULL;
+ Dismiss();
+ delete this;
+}
+
void RepostFormWarningMac::Confirm() {
+ if (navigation_controller_) {
+ navigation_controller_->ContinuePendingReload();
+ }
Destroy();
- if (navigation_controller_)
- navigation_controller_->Reload(false);
}
void RepostFormWarningMac::Cancel() {
+ if (navigation_controller_) {
+ navigation_controller_->CancelPendingReload();
+ }
Destroy();
}
+void RepostFormWarningMac::Dismiss() {
+ if (sheet() && is_sheet_open()) {
+ // This will call |Cancel()|.
+ [NSApp endSheet:[(NSAlert*)sheet() window]
+ returnCode:NSAlertSecondButtonReturn];
+ }
+}
+
void RepostFormWarningMac::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
// Close the dialog if we load a page (because reloading might not apply to
// the same page anymore) or if the tab is closed, because then we won't have
// a navigation controller anymore.
- if (alert_ && navigation_controller_ &&
- (type == NotificationType::LOAD_START ||
- type == NotificationType::TAB_CLOSING)) {
+ if ((type == NotificationType::LOAD_START ||
+ type == NotificationType::TAB_CLOSING ||
+ type == NotificationType::RELOADING)) {
DCHECK_EQ(Source<NavigationController>(source).ptr(),
navigation_controller_);
- navigation_controller_ = NULL;
-
- // This will call |Cancel()|.
- [NSApp endSheet:[alert_ window] returnCode:NSAlertSecondButtonReturn];
+ Dismiss();
}
}
void RepostFormWarningMac::Destroy() {
- if (alert_) {
- alert_.reset(NULL);
- MessageLoop::current()->DeleteSoon(FROM_HERE, this);
+ navigation_controller_ = NULL;
+ if (sheet()) {
+ set_sheet(nil);
+ }
+ if (window_) {
+ window_->CloseConstrainedWindow();
}
}
« no previous file with comments | « chrome/browser/cocoa/repost_form_warning_mac.h ('k') | chrome/browser/cocoa/toolbar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698