| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h" | 5 #include "chrome/browser/ui/cocoa/tab_modal_confirm_dialog_mac.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "chrome/browser/ui/browser_dialogs.h" | 8 #include "chrome/browser/ui/browser_dialogs.h" |
| 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h" | 9 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_alert.h" |
| 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" | 10 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 WindowOpenDisposition disposition = | 50 WindowOpenDisposition disposition = |
| 51 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 51 ui::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
| 52 delegate_->LinkClicked(disposition); | 52 delegate_->LinkClicked(disposition); |
| 53 } | 53 } |
| 54 | 54 |
| 55 @end | 55 @end |
| 56 | 56 |
| 57 TabModalConfirmDialogMac::TabModalConfirmDialogMac( | 57 TabModalConfirmDialogMac::TabModalConfirmDialogMac( |
| 58 TabModalConfirmDialogDelegate* delegate, | 58 TabModalConfirmDialogDelegate* delegate, |
| 59 content::WebContents* web_contents) | 59 content::WebContents* web_contents) |
| 60 : delegate_(delegate) { | 60 : closing_(false), |
| 61 delegate_(delegate) { |
| 61 bridge_.reset([[TabModalConfirmDialogMacBridge alloc] | 62 bridge_.reset([[TabModalConfirmDialogMacBridge alloc] |
| 62 initWithDelegate:delegate]); | 63 initWithDelegate:delegate]); |
| 63 | 64 |
| 64 alert_.reset([[ConstrainedWindowAlert alloc] init]); | 65 alert_.reset([[ConstrainedWindowAlert alloc] init]); |
| 65 [alert_ setMessageText: | 66 [alert_ setMessageText: |
| 66 l10n_util::FixUpWindowsStyleLabel(delegate->GetTitle())]; | 67 l10n_util::FixUpWindowsStyleLabel(delegate->GetTitle())]; |
| 67 [alert_ setLinkText:l10n_util::FixUpWindowsStyleLabel( | 68 [alert_ setLinkText:l10n_util::FixUpWindowsStyleLabel( |
| 68 delegate->GetLinkText()) | 69 delegate->GetLinkText()) |
| 69 target:bridge_ | 70 target:bridge_ |
| 70 action:@selector(onLinkClicked:)]; | 71 action:@selector(onLinkClicked:)]; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 96 | 97 |
| 97 void TabModalConfirmDialogMac::AcceptTabModalDialog() { | 98 void TabModalConfirmDialogMac::AcceptTabModalDialog() { |
| 98 delegate_->Accept(); | 99 delegate_->Accept(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void TabModalConfirmDialogMac::CancelTabModalDialog() { | 102 void TabModalConfirmDialogMac::CancelTabModalDialog() { |
| 102 delegate_->Cancel(); | 103 delegate_->Cancel(); |
| 103 } | 104 } |
| 104 | 105 |
| 105 void TabModalConfirmDialogMac::CloseDialog() { | 106 void TabModalConfirmDialogMac::CloseDialog() { |
| 106 window_->CloseWebContentsModalDialog(); | 107 if (!closing_) { |
| 108 closing_ = true; |
| 109 window_->CloseWebContentsModalDialog(); |
| 110 } |
| 107 } | 111 } |
| 108 | 112 |
| 109 void TabModalConfirmDialogMac::OnConstrainedWindowClosed( | 113 void TabModalConfirmDialogMac::OnConstrainedWindowClosed( |
| 110 ConstrainedWindowMac* window) { | 114 ConstrainedWindowMac* window) { |
| 115 // Provide a disposition in case the dialog was closed without accepting or |
| 116 // cancelling. |
| 117 delegate_->Close(); |
| 111 delete this; | 118 delete this; |
| 112 } | 119 } |
| OLD | NEW |