Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1611)

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_view_tester_views.cc

Issue 1931043002: Remove requestAutocomplete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/expanding_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 std::unique_ptr<AutofillDialogViewTester> AutofillDialogViewTester::For(
20 AutofillDialogView* view) {
21 return std::unique_ptr<AutofillDialogViewTester>(
22 new AutofillDialogViewTesterViews(
23 static_cast<AutofillDialogViews*>(view)));
24 }
25
26 AutofillDialogViewTesterViews::AutofillDialogViewTesterViews(
27 AutofillDialogViews* view)
28 : view_(view) {}
29
30 AutofillDialogViewTesterViews::~AutofillDialogViewTesterViews() {}
31
32 void AutofillDialogViewTesterViews::SubmitForTesting() {
33 view_->Accept();
34 }
35
36 void AutofillDialogViewTesterViews::CancelForTesting() {
37 view_->GetDialogClientView()->CancelWindow();
38 }
39
40 base::string16 AutofillDialogViewTesterViews::GetTextContentsOfInput(
41 ServerFieldType type) {
42 ExpandingTextfield* textfield = view_->TextfieldForType(type);
43 if (textfield)
44 return textfield->GetText();
45
46 views::Combobox* combobox = view_->ComboboxForType(type);
47 if (combobox)
48 return combobox->model()->GetItemAt(combobox->selected_index());
49
50 NOTREACHED();
51 return base::string16();
52 }
53
54 void AutofillDialogViewTesterViews::SetTextContentsOfInput(
55 ServerFieldType type,
56 const base::string16& contents) {
57 ExpandingTextfield* textfield = view_->TextfieldForType(type);
58 if (textfield) {
59 textfield->SetText(contents);
60 return;
61 }
62
63 views::Combobox* combobox = view_->ComboboxForType(type);
64 if (combobox) {
65 if (!combobox->SelectValue(contents))
66 combobox->SetSelectedIndex(combobox->model()->GetDefaultIndex());
67 return;
68 }
69
70 NOTREACHED();
71 }
72
73 void AutofillDialogViewTesterViews::SetTextContentsOfSuggestionInput(
74 DialogSection section,
75 const base::string16& text) {
76 view_->GroupForSection(section)->suggested_info->textfield()->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 bool AutofillDialogViewTesterViews::IsShowingSection(DialogSection section)
89 const {
90 return view_->GroupForSection(section)->container->visible();
91 }
92
93 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698