Index: chrome/browser/ui/views/autofill/autofill_dialog_views.cc |
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e698a21868a333d9732a526885f27c3c4be8b220 |
--- /dev/null |
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc |
@@ -0,0 +1,83 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" |
+ |
+#include "base/utf_string_conversions.h" |
+#include "chrome/browser/ui/views/constrained_window_views.h" |
+#include "ui/views/controls/label.h" |
+ |
+// static |
+AutofillDialogView* AutofillDialogView::CreateDialog( |
+ AutofillDialogController* controller) { |
+ return new AutofillDialogViews(controller); |
+} |
+ |
+AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller) |
+ : controller_(controller), |
+ window_(NULL), |
+ contents_(NULL) { |
Ilya Sherman
2012/10/23 00:39:00
nit: DCHECK(controller)?
Evan Stade
2012/10/23 01:52:04
Done.
|
+} |
+ |
+AutofillDialogViews::~AutofillDialogViews() {} |
+ |
+void AutofillDialogViews::Show() { |
+ InitChildViews(); |
+ |
+ // Ownership of |contents_| is handed off by this call. |window_| will take |
+ // 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
|
+ window_ = new ConstrainedWindowViews( |
+ controller_->web_contents(), this, |
+ true, ConstrainedWindowViews::DEFAULT_INSETS); |
+} |
+ |
+string16 AutofillDialogViews::GetWindowTitle() const { |
+ return controller_->DialogTitle(); |
+} |
+ |
+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
|
+ // |this| belongs to |controller_|. |
+ controller_->ViewClosed(false); |
+} |
+ |
+views::Widget* AutofillDialogViews::GetWidget() { |
+ return contents_->GetWidget(); |
+} |
+ |
+const views::Widget* AutofillDialogViews::GetWidget() const { |
+ return contents_->GetWidget(); |
+} |
+ |
+views::View* AutofillDialogViews::GetContentsView() { |
+ return contents_; |
+} |
+ |
+string16 AutofillDialogViews::GetDialogButtonLabel(ui::DialogButton button) |
+ const { |
+ return button == ui::DIALOG_BUTTON_OK ? |
+ controller_->ConfirmButtonText() : controller_->CancelButtonText(); |
+} |
+ |
+bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const { |
+ return button == ui::DIALOG_BUTTON_OK ? |
+ controller_->ConfirmButtonEnabled() : true; |
+} |
+ |
+bool AutofillDialogViews::UseChromeStyle() const { |
+ return true; |
+} |
+ |
+bool AutofillDialogViews::Cancel() { |
+ return true; |
+} |
+ |
+bool AutofillDialogViews::Accept() { |
+ 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
|
+ return true; |
+} |
+ |
+void AutofillDialogViews::InitChildViews() { |
+ 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
|
+ 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
|
+} |