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/views/constrained_window_views.h" | |
9 #include "ui/views/controls/label.h" | |
10 | |
11 // static | |
12 AutofillDialogView* AutofillDialogView::CreateDialog( | |
13 AutofillDialogController* controller) { | |
14 return new AutofillDialogViews(controller); | |
15 } | |
16 | |
17 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller) | |
18 : controller_(controller), | |
19 window_(NULL), | |
20 contents_(NULL) { | |
Ilya Sherman
2012/10/23 00:39:00
nit: DCHECK(controller)?
Evan Stade
2012/10/23 01:52:04
Done.
| |
21 } | |
22 | |
23 AutofillDialogViews::~AutofillDialogViews() {} | |
24 | |
25 void AutofillDialogViews::Show() { | |
26 InitChildViews(); | |
27 | |
28 // Ownership of |contents_| is handed off by this call. |window_| will take | |
29 // care of deleting itself after calling DeleteDelegate(). | |
Ilya Sherman
2012/10/23 00:39:00
How does this pass ownership of |contents_|? |con
Ilya Sherman
2012/10/23 00:39:00
Is DeleteDelegate() guaranteed to be called in all
Evan Stade
2012/10/23 01:52:04
because constrainedwindowviews calls GetContentsVi
Evan Stade
2012/10/23 01:52:04
yes it is, and this memory management model is com
| |
30 window_ = new ConstrainedWindowViews( | |
31 controller_->web_contents(), this, | |
32 true, ConstrainedWindowViews::DEFAULT_INSETS); | |
33 } | |
34 | |
35 string16 AutofillDialogViews::GetWindowTitle() const { | |
36 return controller_->DialogTitle(); | |
37 } | |
38 | |
39 void AutofillDialogViews::DeleteDelegate() { | |
Ilya Sherman
2012/10/23 00:39:00
Should window_ be set to |null|? (Perhaps even ear
Evan Stade
2012/10/23 01:52:04
what is WindowClosing? Actually it seems we don't
| |
40 // |this| belongs to |controller_|. | |
41 controller_->ViewClosed(false); | |
42 } | |
43 | |
44 views::Widget* AutofillDialogViews::GetWidget() { | |
45 return contents_->GetWidget(); | |
46 } | |
47 | |
48 const views::Widget* AutofillDialogViews::GetWidget() const { | |
49 return contents_->GetWidget(); | |
50 } | |
51 | |
52 views::View* AutofillDialogViews::GetContentsView() { | |
53 return contents_; | |
54 } | |
55 | |
56 string16 AutofillDialogViews::GetDialogButtonLabel(ui::DialogButton button) | |
57 const { | |
58 return button == ui::DIALOG_BUTTON_OK ? | |
59 controller_->ConfirmButtonText() : controller_->CancelButtonText(); | |
60 } | |
61 | |
62 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const { | |
63 return button == ui::DIALOG_BUTTON_OK ? | |
64 controller_->ConfirmButtonEnabled() : true; | |
65 } | |
66 | |
67 bool AutofillDialogViews::UseChromeStyle() const { | |
68 return true; | |
69 } | |
70 | |
71 bool AutofillDialogViews::Cancel() { | |
72 return true; | |
73 } | |
74 | |
75 bool AutofillDialogViews::Accept() { | |
76 NOTREACHED(); | |
Ilya Sherman
2012/10/23 00:39:00
nit: Please add TODOs to implement this and other
Evan Stade
2012/10/23 01:52:04
I'm not sure a TODO in every function that is not
Ilya Sherman
2012/10/23 04:52:29
I think it's likely to be useful when some of the
| |
77 return true; | |
78 } | |
79 | |
80 void AutofillDialogViews::InitChildViews() { | |
81 contents_ = new views::View(); | |
Ilya Sherman
2012/10/23 00:39:00
It looks like this can leak if Show() is never cal
Evan Stade
2012/10/23 01:52:04
This function was supposed to be private and only
Ilya Sherman
2012/10/23 04:52:29
Ah, ok, that makes more sense. Since it's only tw
Evan Stade
2012/10/23 18:48:04
right now it is two lines. In the future it will b
| |
82 contents_->AddChildView(new views::Label(ASCIIToUTF16("Hello, world."))); | |
Ilya Sherman
2012/10/23 00:39:00
Does this pass ownership of the child view? It do
Evan Stade
2012/10/23 01:52:04
yes
| |
83 } | |
OLD | NEW |