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::Create( |
| 14 AutofillDialogController* controller) { |
| 15 return new AutofillDialogViews(controller); |
| 16 } |
| 17 |
| 18 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller) |
| 19 : controller_(controller), |
| 20 window_(NULL), |
| 21 contents_(NULL) { |
| 22 DCHECK(controller); |
| 23 } |
| 24 |
| 25 AutofillDialogViews::~AutofillDialogViews() { |
| 26 DCHECK(!window_); |
| 27 } |
| 28 |
| 29 void AutofillDialogViews::Show() { |
| 30 InitChildViews(); |
| 31 |
| 32 // Ownership of |contents_| is handed off by this call. The ConstrainedWindow |
| 33 // will take care of deleting itself after calling DeleteDelegate(). |
| 34 window_ = new ConstrainedWindowViews( |
| 35 controller_->web_contents(), this, |
| 36 true, ConstrainedWindowViews::DEFAULT_INSETS); |
| 37 } |
| 38 |
| 39 string16 AutofillDialogViews::GetWindowTitle() const { |
| 40 return controller_->DialogTitle(); |
| 41 } |
| 42 |
| 43 void AutofillDialogViews::DeleteDelegate() { |
| 44 window_ = NULL; |
| 45 // |this| belongs to |controller_|. |
| 46 controller_->ViewClosed(AutofillDialogController::AUTOFILL_ACTION_ABORT); |
| 47 } |
| 48 |
| 49 views::Widget* AutofillDialogViews::GetWidget() { |
| 50 return contents_->GetWidget(); |
| 51 } |
| 52 |
| 53 const views::Widget* AutofillDialogViews::GetWidget() const { |
| 54 return contents_->GetWidget(); |
| 55 } |
| 56 |
| 57 views::View* AutofillDialogViews::GetContentsView() { |
| 58 return contents_; |
| 59 } |
| 60 |
| 61 string16 AutofillDialogViews::GetDialogButtonLabel(ui::DialogButton button) |
| 62 const { |
| 63 return button == ui::DIALOG_BUTTON_OK ? |
| 64 controller_->ConfirmButtonText() : controller_->CancelButtonText(); |
| 65 } |
| 66 |
| 67 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const { |
| 68 return button == ui::DIALOG_BUTTON_OK ? |
| 69 controller_->ConfirmButtonEnabled() : true; |
| 70 } |
| 71 |
| 72 bool AutofillDialogViews::UseChromeStyle() const { |
| 73 return true; |
| 74 } |
| 75 |
| 76 bool AutofillDialogViews::Cancel() { |
| 77 return true; |
| 78 } |
| 79 |
| 80 bool AutofillDialogViews::Accept() { |
| 81 NOTREACHED(); |
| 82 return true; |
| 83 } |
| 84 |
| 85 void AutofillDialogViews::InitChildViews() { |
| 86 contents_ = new views::View(); |
| 87 contents_->AddChildView(new views::Label(ASCIIToUTF16("Hello, world."))); |
| 88 } |
OLD | NEW |