OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" | |
6 | |
7 #include "base/utf_string_conversions.h" | |
8 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | |
9 #include "chrome/browser/ui/views/constrained_window_views.h" | |
10 #include "ui/views/controls/label.h" | |
11 | |
12 // static | |
13 AutofillDialogView* AutofillDialogView::CreateDialog( | |
14 AutofillDialogController* controller) { | |
15 return new AutofillDialogViews(controller); | |
16 } | |
17 | |
18 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller) | |
19 : controller_(controller), | |
20 contents_(NULL) { | |
21 DCHECK(controller); | |
22 } | |
23 | |
24 AutofillDialogViews::~AutofillDialogViews() {} | |
sky
2012/10/23 19:53:54
If this is deleted with the constrained window ope
Evan Stade
2012/10/23 20:58:58
yea, but the plan is not to let that happen (i.e.
| |
25 | |
26 void AutofillDialogViews::Show() { | |
27 InitChildViews(); | |
28 | |
29 // Ownership of |contents_| is handed off by this call. The ConstrainedWindow | |
30 // will take care of deleting itself after calling DeleteDelegate(). | |
31 new ConstrainedWindowViews( | |
32 controller_->web_contents(), this, | |
33 true, ConstrainedWindowViews::DEFAULT_INSETS); | |
34 } | |
35 | |
36 string16 AutofillDialogViews::GetWindowTitle() const { | |
37 return controller_->DialogTitle(); | |
38 } | |
39 | |
40 void AutofillDialogViews::DeleteDelegate() { | |
41 // |this| belongs to |controller_|. | |
42 controller_->ViewClosed(AutofillDialogController::AUTOFILL_ACTION_ABORT); | |
43 } | |
44 | |
45 views::Widget* AutofillDialogViews::GetWidget() { | |
46 return contents_->GetWidget(); | |
47 } | |
48 | |
49 const views::Widget* AutofillDialogViews::GetWidget() const { | |
50 return contents_->GetWidget(); | |
51 } | |
52 | |
53 views::View* AutofillDialogViews::GetContentsView() { | |
54 return contents_; | |
55 } | |
56 | |
57 string16 AutofillDialogViews::GetDialogButtonLabel(ui::DialogButton button) | |
58 const { | |
59 return button == ui::DIALOG_BUTTON_OK ? | |
60 controller_->ConfirmButtonText() : controller_->CancelButtonText(); | |
61 } | |
62 | |
63 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const { | |
64 return button == ui::DIALOG_BUTTON_OK ? | |
65 controller_->ConfirmButtonEnabled() : true; | |
66 } | |
67 | |
68 bool AutofillDialogViews::UseChromeStyle() const { | |
69 return true; | |
70 } | |
71 | |
72 bool AutofillDialogViews::Cancel() { | |
73 return true; | |
74 } | |
75 | |
76 bool AutofillDialogViews::Accept() { | |
77 NOTREACHED(); | |
78 return true; | |
79 } | |
80 | |
81 void AutofillDialogViews::InitChildViews() { | |
82 contents_ = new views::View(); | |
83 contents_->AddChildView(new views::Label(ASCIIToUTF16("Hello, world."))); | |
84 } | |
OLD | NEW |