OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/autofill/autofill_dialog_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | 11 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
12 #import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h" | 12 #import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h" |
13 #import "chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.h" | 13 #import "chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.h" |
14 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" | 14 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
15 | 15 |
16 namespace autofill { | 16 namespace autofill { |
17 | 17 |
18 // static | 18 // static |
19 AutofillDialogView* AutofillDialogView::Create( | 19 AutofillDialogView* AutofillDialogView::Create( |
20 AutofillDialogViewDelegate* delegate) { | 20 AutofillDialogViewDelegate* delegate) { |
21 return new AutofillDialogCocoa(delegate); | 21 return new AutofillDialogCocoa(delegate); |
22 } | 22 } |
23 | 23 |
24 AutofillDialogCocoa::AutofillDialogCocoa(AutofillDialogViewDelegate* delegate) | 24 AutofillDialogCocoa::AutofillDialogCocoa(AutofillDialogViewDelegate* delegate) |
25 : close_weak_ptr_factory_(this), | 25 : close_weak_ptr_factory_(this), |
26 delegate_(delegate) { | 26 delegate_(delegate) { |
27 } | 27 } |
28 | 28 |
29 AutofillDialogCocoa::~AutofillDialogCocoa() { | 29 AutofillDialogCocoa::~AutofillDialogCocoa() { |
30 // Cancel potential relayout requests, since the AutofillDialogController | |
31 // is about to go away, but relayout requests assume it will still exist. | |
32 [sheet_delegate_ cancelRelayout]; | |
33 } | 30 } |
34 | 31 |
35 void AutofillDialogCocoa::Show() { | 32 void AutofillDialogCocoa::Show() { |
36 // This should only be called once. | 33 // This should only be called once. |
37 DCHECK(!sheet_delegate_.get()); | 34 DCHECK(!sheet_delegate_.get()); |
38 sheet_delegate_.reset([[AutofillDialogWindowController alloc] | 35 sheet_delegate_.reset([[AutofillDialogWindowController alloc] |
39 initWithWebContents:delegate_->GetWebContents() | 36 initWithWebContents:delegate_->GetWebContents() |
40 dialog:this]); | 37 dialog:this]); |
41 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( | 38 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
42 [[CustomConstrainedWindowSheet alloc] | 39 [[CustomConstrainedWindowSheet alloc] |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 195 } |
199 | 196 |
200 void AutofillDialogCocoa::OnConstrainedWindowClosed( | 197 void AutofillDialogCocoa::OnConstrainedWindowClosed( |
201 ConstrainedWindowMac* window) { | 198 ConstrainedWindowMac* window) { |
202 constrained_window_.reset(); | 199 constrained_window_.reset(); |
203 // |this| belongs to |delegate_|, so no self-destruction here. | 200 // |this| belongs to |delegate_|, so no self-destruction here. |
204 delegate_->ViewClosed(); | 201 delegate_->ViewClosed(); |
205 } | 202 } |
206 | 203 |
207 } // autofill | 204 } // autofill |
OLD | NEW |