Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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_view_tester_views.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h" | |
| 9 #include "chrome/browser/ui/views/autofill/decorated_textfield.h" | |
| 10 #include "ui/base/models/combobox_model.h" | |
| 11 #include "ui/views/controls/combobox/combobox.h" | |
| 12 #include "ui/views/controls/textfield/textfield.h" | |
| 13 #include "ui/views/controls/webview/webview.h" | |
| 14 #include "ui/views/widget/widget.h" | |
| 15 #include "ui/views/window/dialog_client_view.h" | |
| 16 | |
| 17 namespace autofill { | |
| 18 | |
| 19 scoped_ptr<AutofillDialogViewTester> AutofillDialogViewTester::For( | |
| 20 AutofillDialogView* view) { | |
| 21 return scoped_ptr<AutofillDialogViewTester>(new | |
|
Dan Beam
2014/01/28 18:04:48
nit: a dangling new is odd looking to me
Evan Stade
2014/01/28 18:45:26
better than an extra line imo
| |
| 22 AutofillDialogViewTesterViews(static_cast<AutofillDialogViews*>(view))); | |
| 23 } | |
| 24 | |
| 25 AutofillDialogViewTesterViews::AutofillDialogViewTesterViews( | |
| 26 AutofillDialogViews* view) | |
| 27 : view_(view) {} | |
| 28 | |
| 29 AutofillDialogViewTesterViews::~AutofillDialogViewTesterViews() {} | |
| 30 | |
| 31 void AutofillDialogViewTesterViews::SubmitForTesting() { | |
| 32 view_->Accept(); | |
| 33 } | |
| 34 | |
| 35 void AutofillDialogViewTesterViews::CancelForTesting() { | |
| 36 view_->GetDialogClientView()->CancelWindow(); | |
| 37 } | |
| 38 | |
| 39 base::string16 AutofillDialogViewTesterViews::GetTextContentsOfInput( | |
| 40 ServerFieldType type) { | |
| 41 views::Textfield* textfield = view_->TextfieldForType(type); | |
| 42 if (textfield) | |
| 43 return textfield->text(); | |
| 44 | |
| 45 views::Combobox* combobox = view_->ComboboxForType(type); | |
| 46 if (combobox) | |
| 47 return combobox->model()->GetItemAt(combobox->selected_index()); | |
| 48 | |
| 49 NOTREACHED(); | |
| 50 return base::string16(); | |
| 51 } | |
| 52 | |
| 53 void AutofillDialogViewTesterViews::SetTextContentsOfInput( | |
| 54 ServerFieldType type, | |
| 55 const base::string16& contents) { | |
| 56 views::Textfield* textfield = view_->TextfieldForType(type); | |
| 57 if (textfield) { | |
| 58 textfield->SetText(contents); | |
| 59 return; | |
| 60 } | |
| 61 | |
| 62 views::Combobox* combobox = view_->ComboboxForType(type); | |
| 63 if (combobox) { | |
| 64 if (!combobox->SelectValue(contents)) | |
| 65 combobox->SetSelectedIndex(combobox->model()->GetDefaultIndex()); | |
| 66 return; | |
| 67 } | |
| 68 | |
| 69 NOTREACHED(); | |
| 70 } | |
| 71 | |
| 72 void AutofillDialogViewTesterViews::SetTextContentsOfSuggestionInput( | |
| 73 DialogSection section, | |
| 74 const base::string16& text) { | |
| 75 view_->GroupForSection(section)->suggested_info->decorated_textfield()-> | |
| 76 SetText(text); | |
| 77 } | |
| 78 | |
| 79 void AutofillDialogViewTesterViews::ActivateInput(ServerFieldType type) { | |
| 80 view_->InputEditedOrActivated(type, gfx::Rect(), false); | |
| 81 } | |
| 82 | |
| 83 gfx::Size AutofillDialogViewTesterViews::GetSize() const { | |
| 84 return view_->GetWidget() ? view_->GetWidget()->GetRootView()->size() : | |
| 85 gfx::Size(); | |
| 86 } | |
| 87 | |
| 88 content::WebContents* AutofillDialogViewTesterViews::GetSignInWebContents() { | |
| 89 return view_->sign_in_web_view_->web_contents(); | |
| 90 } | |
| 91 | |
| 92 bool AutofillDialogViewTesterViews::IsShowingOverlay() const { | |
| 93 return view_->overlay_view_->visible(); | |
| 94 } | |
| 95 | |
| 96 } // namespace autofill | |
| OLD | NEW |