Commit f6343a2b authored by estade@chromium.org's avatar estade@chromium.org

requestAutocomplete: change comboboxes to dropdown menus

Change comboboxes to dropdown menus, per the latest mocks. Allow users to switch between manual entry and pre-fill modes.

lots of TODOs, but this seems like a good stopping point.

BUG=157270,157273

Review URL: https://chromiumcodereview.appspot.com/11743036

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175439 0039d316-1c4b-4281-b951-d872f2087c98
parent 1566fbab
......@@ -119,6 +119,10 @@ AutofillDialogController::AutofillDialogController(
source_url_(source_url),
ssl_status_(ssl_status),
callback_(callback),
ALLOW_THIS_IN_INITIALIZER_LIST(suggested_email_(this)),
ALLOW_THIS_IN_INITIALIZER_LIST(suggested_cc_(this)),
ALLOW_THIS_IN_INITIALIZER_LIST(suggested_billing_(this)),
ALLOW_THIS_IN_INITIALIZER_LIST(suggested_shipping_(this)),
popup_controller_(NULL) {
// TODO(estade): |this| should observe PersonalDataManager.
// TODO(estade): remove duplicates from |form|?
......@@ -192,7 +196,7 @@ void AutofillDialogController::Show() {
arraysize(kShippingInputs),
&requested_shipping_fields_);
GenerateComboboxModels();
GenerateSuggestionsModels();
// TODO(estade): don't show the dialog if the site didn't specify the right
// fields. First we must figure out what the "right" fields are.
......@@ -320,9 +324,36 @@ ui::ComboboxModel* AutofillDialogController::ComboboxModelForAutofillType(
}
}
ui::ComboboxModel* AutofillDialogController::ComboboxModelForSection(
ui::MenuModel* AutofillDialogController::MenuModelForSection(
DialogSection section) {
return SuggestionsModelForSection(section);
return SuggestionsMenuModelForSection(section);
}
string16 AutofillDialogController::SuggestionTextForSection(
DialogSection section) {
SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section);
std::string item_key = model->GetItemKeyAt(model->checked_item());
if (item_key.empty())
return string16();
// TODO(estade): This doesn't display as much info as it should (for example,
// it should show full addresses rather than just a summary).
if (section == SECTION_CC) {
CreditCard* card = GetManager()->GetCreditCardByGUID(item_key);
if (card)
return card->Label();
} else {
AutofillProfile* profile = GetManager()->GetProfileByGUID(item_key);
if (profile) {
const std::string app_locale = AutofillCountry::ApplicationLocale();
return section == SECTION_EMAIL ?
profile->GetInfo(EMAIL_ADDRESS, app_locale) : profile->Label();
}
}
// TODO(estade): The FormGroup was likely deleted while menu was showing. We
// should not let this happen.
return string16();
}
void AutofillDialogController::ViewClosed(DialogAction action) {
......@@ -428,13 +459,18 @@ void AutofillDialogController::ControllerDestroyed() {
popup_controller_ = NULL;
}
void AutofillDialogController::GenerateComboboxModels() {
void AutofillDialogController::SuggestionItemSelected(
const SuggestionsMenuModel& model) {
view_->UpdateSection(SectionForSuggestionsMenuModel(model));
}
void AutofillDialogController::GenerateSuggestionsModels() {
PersonalDataManager* manager = GetManager();
const std::vector<CreditCard*>& cards = manager->credit_cards();
for (size_t i = 0; i < cards.size(); ++i) {
suggested_cc_.AddItem(cards[i]->guid(), cards[i]->Label());
suggested_cc_.AddKeyedItem(cards[i]->guid(), cards[i]->Label());
}
suggested_cc_.AddItem("", ASCIIToUTF16("Enter new card"));
suggested_cc_.AddKeyedItem("", ASCIIToUTF16("Enter new card"));
const std::vector<AutofillProfile*>& profiles = manager->GetProfiles();
const std::string app_locale = AutofillCountry::ApplicationLocale();
......@@ -445,16 +481,15 @@ void AutofillDialogController::GenerateComboboxModels() {
string16 email = profiles[i]->GetInfo(EMAIL_ADDRESS, app_locale);
if (!email.empty())
suggested_email_.AddItem(profiles[i]->guid(), email);
suggested_billing_.AddItem(profiles[i]->guid(), profiles[i]->Label());
suggested_shipping_.AddItem(profiles[i]->guid(), profiles[i]->Label());
suggested_email_.AddKeyedItem(profiles[i]->guid(), email);
suggested_billing_.AddKeyedItem(profiles[i]->guid(), profiles[i]->Label());
suggested_shipping_.AddKeyedItem(profiles[i]->guid(), profiles[i]->Label());
}
suggested_billing_.AddItem("", ASCIIToUTF16("Enter new billing"));
suggested_email_.AddItem("", ASCIIToUTF16("Enter new email"));
suggested_shipping_.AddItem("", ASCIIToUTF16("Enter new shipping"));
suggested_billing_.AddKeyedItem("", ASCIIToUTF16("Enter new billing"));
suggested_email_.AddKeyedItem("", ASCIIToUTF16("Enter new email"));
suggested_shipping_.AddKeyedItem("", ASCIIToUTF16("Enter new shipping"));
}
bool AutofillDialogController::IsCompleteProfile(
const AutofillProfile& profile) {
const std::string app_locale = AutofillCountry::ApplicationLocale();
......@@ -470,11 +505,10 @@ bool AutofillDialogController::IsCompleteProfile(
void AutofillDialogController::FillOutputForSectionWithComparator(
DialogSection section, const InputFieldComparator& compare) {
int suggestion_selection = view_->GetSuggestionSelection(section);
SuggestionsComboboxModel* model = SuggestionsModelForSection(section);
SuggestionsMenuModel* model = SuggestionsMenuModelForSection(section);
std::string guid = model->GetItemKeyAt(model->checked_item());
PersonalDataManager* manager = GetManager();
if (suggestion_selection < model->GetItemCount() - 1) {
std::string guid = model->GetItemKeyAt(suggestion_selection);
if (!guid.empty()) {
FormGroup* form_group = section == SECTION_CC ?
static_cast<FormGroup*>(manager->GetCreditCardByGUID(guid)) :
static_cast<FormGroup*>(manager->GetProfileByGUID(guid));
......@@ -541,7 +575,7 @@ void AutofillDialogController::FillFormStructureForSection(
}
}
SuggestionsComboboxModel* AutofillDialogController::SuggestionsModelForSection(
SuggestionsMenuModel* AutofillDialogController::SuggestionsMenuModelForSection(
DialogSection section) {
switch (section) {
case SECTION_EMAIL:
......@@ -558,6 +592,21 @@ SuggestionsComboboxModel* AutofillDialogController::SuggestionsModelForSection(
return NULL;
}
DialogSection AutofillDialogController::SectionForSuggestionsMenuModel(
const SuggestionsMenuModel& model) {
if (&model == &suggested_email_)
return SECTION_EMAIL;
if (&model == &suggested_cc_)
return SECTION_CC;
if (&model == &suggested_billing_)
return SECTION_BILLING;
DCHECK_EQ(&model, &suggested_shipping_);
return SECTION_SHIPPING;
}
PersonalDataManager* AutofillDialogController::GetManager() {
return PersonalDataManagerFactory::GetForProfile(profile_);
}
......
......@@ -16,11 +16,12 @@
#include "chrome/browser/autofill/field_types.h"
#include "chrome/browser/autofill/form_structure.h"
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/ui/autofill/autofill_dialog_comboboxes.h"
#include "chrome/browser/ui/autofill/autofill_dialog_models.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
#include "chrome/browser/ui/autofill/autofill_popup_delegate.h"
#include "content/public/common/ssl_status.h"
#include "ui/base/models/combobox_model.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/gfx/native_widget_types.h"
class AutofillPopupControllerImpl;
......@@ -80,7 +81,8 @@ typedef std::map<const DetailInput*, string16> DetailOutputMap;
// This class drives the dialog that appears when a site uses the imperative
// autocomplete API to fill out a form.
class AutofillDialogController : public AutofillPopupDelegate {
class AutofillDialogController : public AutofillPopupDelegate,
public SuggestionsMenuModelDelegate {
public:
AutofillDialogController(
content::WebContents* contents,
......@@ -109,9 +111,12 @@ class AutofillDialogController : public AutofillPopupDelegate {
// Returns the set of inputs the page has requested which fall under
// |section|.
const DetailInputs& RequestedFieldsForSection(DialogSection section) const;
// Returns the combobox model for inputs of type |type|, or NULL if the input
// should be a text field.
ui::ComboboxModel* ComboboxModelForAutofillType(AutofillFieldType type);
// Returns the model for suggestions for fields that fall under |section|.
ui::ComboboxModel* ComboboxModelForSection(DialogSection section);
ui::MenuModel* MenuModelForSection(DialogSection section);
string16 SuggestionTextForSection(DialogSection section);
// Called when the view has been closed. The value for |action| indicates
// whether the Autofill operation should be aborted.
......@@ -135,6 +140,10 @@ class AutofillDialogController : public AutofillPopupDelegate {
virtual void ClearPreviewedForm() OVERRIDE;
virtual void ControllerDestroyed() OVERRIDE;
// SuggestionsMenuModelDelegate implementation.
virtual void SuggestionItemSelected(const SuggestionsMenuModel& model)
OVERRIDE;
content::WebContents* web_contents() { return contents_; }
private:
......@@ -149,7 +158,7 @@ class AutofillDialogController : public AutofillPopupDelegate {
bool ShouldShowSecurityWarning() const;
// Initializes |suggested_email_| et al.
void GenerateComboboxModels();
void GenerateSuggestionsModels();
// Returns whether |profile| is complete, i.e. can fill out all the relevant
// address info. Incomplete profiles will not be displayed in the dropdown
......@@ -170,8 +179,11 @@ class AutofillDialogController : public AutofillPopupDelegate {
DialogSection section,
const InputFieldComparator& compare);
// Gets the SuggestionsComboboxModel for |section|.
SuggestionsComboboxModel* SuggestionsModelForSection(DialogSection section);
// Gets the SuggestionsMenuModel for |section|.
SuggestionsMenuModel* SuggestionsMenuModelForSection(DialogSection section);
// And the reverse.
DialogSection SectionForSuggestionsMenuModel(
const SuggestionsMenuModel& model);
// Loads profiles that can suggest data for |type|. |field_contents| is the
// part the user has already typed. |inputs| is the rest of section.
......@@ -215,10 +227,10 @@ class AutofillDialogController : public AutofillPopupDelegate {
YearComboboxModel cc_exp_year_combobox_model_;
// Models for the suggestion views.
SuggestionsComboboxModel suggested_email_;
SuggestionsComboboxModel suggested_cc_;
SuggestionsComboboxModel suggested_billing_;
SuggestionsComboboxModel suggested_shipping_;
SuggestionsMenuModel suggested_email_;
SuggestionsMenuModel suggested_cc_;
SuggestionsMenuModel suggested_billing_;
SuggestionsMenuModel suggested_shipping_;
// The GUIDs for the currently showing unverified profiles popup.
std::vector<PersonalDataManager::GUIDPair> popup_guids_;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/autofill/autofill_dialog_comboboxes.h"
#include "chrome/browser/ui/autofill/autofill_dialog_models.h"
#include "base/string_number_conversions.h"
#include "base/stringprintf.h"
......@@ -11,27 +11,47 @@
namespace autofill {
// SuggestionsComboboxModel ----------------------------------------------------
SuggestionsMenuModelDelegate::~SuggestionsMenuModelDelegate() {}
SuggestionsComboboxModel::SuggestionsComboboxModel() {}
// SuggestionsMenuModel ----------------------------------------------------
SuggestionsComboboxModel::~SuggestionsComboboxModel() {}
SuggestionsMenuModel::SuggestionsMenuModel(
SuggestionsMenuModelDelegate* delegate)
: ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
delegate_(delegate),
checked_item_(0) {}
void SuggestionsComboboxModel::AddItem(
SuggestionsMenuModel::~SuggestionsMenuModel() {}
void SuggestionsMenuModel::AddKeyedItem(
const std::string& key, const string16& item) {
items_.push_back(std::make_pair(key, item));
AddCheckItem(items_.size() - 1, item);
}
std::string SuggestionsComboboxModel::GetItemKeyAt(int index) const {
std::string SuggestionsMenuModel::GetItemKeyAt(int index) const {
return items_[index].first;
}
int SuggestionsComboboxModel::GetItemCount() const {
return items_.size();
bool SuggestionsMenuModel::IsCommandIdChecked(
int command_id) const {
return checked_item_ == command_id;
}
bool SuggestionsMenuModel::IsCommandIdEnabled(
int command_id) const {
return true;
}
bool SuggestionsMenuModel::GetAcceleratorForCommandId(
int command_id,
ui::Accelerator* accelerator) {
return false;
}
string16 SuggestionsComboboxModel::GetItemAt(int index) {
return items_[index].second;
void SuggestionsMenuModel::ExecuteCommand(int command_id) {
checked_item_ = command_id;
delegate_->SuggestionItemSelected(*this);
}
// MonthComboboxModel ----------------------------------------------------------
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMBOBOXES_H_
#define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMBOBOXES_H_
#ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_
#define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_
#include <string>
#include <vector>
......@@ -12,25 +12,44 @@
#include "base/compiler_specific.h"
#include "base/string16.h"
#include "ui/base/models/combobox_model.h"
#include "ui/base/models/simple_menu_model.h"
namespace autofill {
// A model for the comboboxes that allow the user to select from different sets
// of known data.
class SuggestionsComboboxModel : public ui::ComboboxModel {
class SuggestionsMenuModel;
class SuggestionsMenuModelDelegate {
public:
virtual ~SuggestionsMenuModelDelegate();
// Called when a menu item has been activated.
virtual void SuggestionItemSelected(const SuggestionsMenuModel& model) = 0;
};
// A model for the dropdowns that allow the user to select from different
// sets of known data. It wraps a SimpleMenuModel, providing a mapping between
// index and item GUID.
class SuggestionsMenuModel : public ui::SimpleMenuModel,
public ui::SimpleMenuModel::Delegate {
public:
SuggestionsComboboxModel();
virtual ~SuggestionsComboboxModel();
explicit SuggestionsMenuModel(SuggestionsMenuModelDelegate* delegate);
virtual ~SuggestionsMenuModel();
// Adds an item and its identifying key to the model.
void AddItem(const std::string& key, const string16& display_label);
void AddKeyedItem(const std::string& key, const string16& display_label);
// Returns the ID key for the item at |index|.
std::string GetItemKeyAt(int index) const;
// ui::Combobox implementation:
virtual int GetItemCount() const OVERRIDE;
virtual string16 GetItemAt(int index) OVERRIDE;
int checked_item() { return checked_item_; }
// ui::SimpleMenuModel::Delegate implementation.
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE;
virtual bool GetAcceleratorForCommandId(
int command_id,
ui::Accelerator* accelerator) OVERRIDE;
virtual void ExecuteCommand(int command_id) OVERRIDE;
private:
// The items this model represents, in presentation order. The first
......@@ -38,7 +57,12 @@ class SuggestionsComboboxModel : public ui::ComboboxModel {
// display string for the item.
std::vector<std::pair<std::string, string16> > items_;
DISALLOW_COPY_AND_ASSIGN(SuggestionsComboboxModel);
SuggestionsMenuModelDelegate* delegate_;
// The command id (and index) of the item which is currently checked.
int checked_item_;
DISALLOW_COPY_AND_ASSIGN(SuggestionsMenuModel);
};
// A model for possible months in the Gregorian calendar.
......@@ -74,4 +98,4 @@ class YearComboboxModel : public ui::ComboboxModel {
} // autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMBOBOXES_H_
#endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_MODELS_H_
......@@ -21,9 +21,6 @@ class AutofillDialogView {
// Called when the contents of a section have changed.
virtual void UpdateSection(DialogSection section) = 0;
// Returns the index into the suggestion model for |section|.
virtual int GetSuggestionSelection(DialogSection section) = 0;
// Fills |output| with data the user manually input.
virtual void GetUserInput(DialogSection section, DetailOutputMap* output) = 0;
......
......@@ -12,8 +12,11 @@
#include "third_party/skia/include/core/SkColor.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/controls/separator.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/box_layout.h"
......@@ -79,7 +82,11 @@ AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller)
: controller_(controller),
did_submit_(false),
window_(NULL),
contents_(NULL) {
contents_(NULL),
email_(SECTION_EMAIL),
cc_(SECTION_CC),
billing_(SECTION_BILLING),
shipping_(SECTION_SHIPPING) {
DCHECK(controller);
}
......@@ -110,10 +117,8 @@ void AutofillDialogViews::UpdateSection(DialogSection section) {
input->second->SetText(iter->autofilled_value);
}
}
int AutofillDialogViews::GetSuggestionSelection(DialogSection section) {
return GroupForSection(section)->suggested_input->selected_index();
UpdateDetailsGroupState(*group);
}
void AutofillDialogViews::GetUserInput(DialogSection section,
......@@ -123,13 +128,6 @@ void AutofillDialogViews::GetUserInput(DialogSection section,
it != group->textfields.end(); ++it) {
output->insert(std::make_pair(it->first, it->second->text()));
}
for (ComboboxMap::iterator it = group->comboboxes.begin();
it != group->comboboxes.end(); ++it) {
views::Combobox* combobox = it->second;
output->insert(std::make_pair(
it->first,
combobox->model()->GetItemAt(combobox->selected_index())));
}
}
bool AutofillDialogViews::UseBillingForShipping() {
......@@ -189,15 +187,25 @@ void AutofillDialogViews::ButtonPressed(views::Button* sender,
GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
}
void AutofillDialogViews::OnSelectedIndexChanged(views::Combobox* combobox) {
void AutofillDialogViews::OnMenuButtonClicked(views::View* source,
const gfx::Point& point) {
DetailsGroup* group =
combobox == email_.suggested_input ? &email_ :
combobox == cc_.suggested_input ? &cc_ :
combobox == billing_.suggested_input ? &billing_ :
combobox == shipping_.suggested_input ? &shipping_ : NULL;
source == email_.suggested_button ? &email_ :
source == cc_.suggested_button ? &cc_ :
source == billing_.suggested_button ? &billing_ :
source == shipping_.suggested_button ? &shipping_ : NULL;
DCHECK(group);
UpdateDetailsGroupState(*group);
GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
views::MenuModelAdapter adapter(
controller_->MenuModelForSection(group->section));
menu_runner_.reset(new views::MenuRunner(adapter.CreateMenu()));
// Ignore the result since we don't need to handle a deleted menu specially.
ignore_result(
menu_runner_->RunMenuAt(source->GetWidget(),
group->suggested_button,
gfx::Rect(point, gfx::Size()),
views::MenuItemView::TOPRIGHT,
0));
}
void AutofillDialogViews::ContentsChanged(views::Textfield* sender,
......@@ -362,18 +370,46 @@ void AutofillDialogViews::CreateBillingSection() {
views::View* AutofillDialogViews::CreateInputsContainer(DialogSection section) {
views::View* inputs_container = new views::View();
inputs_container->SetLayoutManager(
views::GridLayout* layout = new views::GridLayout(inputs_container);
inputs_container->SetLayoutManager(layout);
int kColumnSetId = 0;
views::ColumnSet* column_set = layout->AddColumnSet(kColumnSetId);
column_set->AddColumn(views::GridLayout::FILL,
views::GridLayout::LEADING,
1,
views::GridLayout::USE_PREF,
0,
0);
column_set->AddColumn(views::GridLayout::CENTER,
views::GridLayout::LEADING,
0,
views::GridLayout::USE_PREF,
0,
0);
layout->StartRow(0, kColumnSetId);
// The |info_view| holds |manual_inputs| and |suggested_info|, allowing the
// dialog toggle which is shown.
views::View* info_view = new views::View();
info_view->SetLayoutManager(
new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
views::View* manual_inputs = InitInputsView(section);
inputs_container->AddChildView(manual_inputs);
views::Combobox* combobox =
new views::Combobox(controller_->ComboboxModelForSection(section));
combobox->set_listener(this);
inputs_container->AddChildView(combobox);
info_view->AddChildView(manual_inputs);
views::Label* suggested_info = new views::Label();
suggested_info->SetHorizontalAlignment(gfx::ALIGN_LEFT);
info_view->AddChildView(suggested_info);
layout->AddView(info_view);
// TODO(estade): Fix the appearance of this button.
views::MenuButton* menu_button =
new views::MenuButton(NULL, string16(), this, true);
layout->AddView(menu_button);
DetailsGroup* group = GroupForSection(section);
group->suggested_input = combobox;
group->suggested_button = menu_button;
group->manual_input = manual_inputs;
group->suggested_info = suggested_info;
UpdateDetailsGroupState(*group);
return inputs_container;
}
......@@ -444,13 +480,13 @@ views::View* AutofillDialogViews::InitInputsView(DialogSection section) {
}
void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
views::Combobox* combobox = group.suggested_input;
int suggestion_count = combobox->model()->GetItemCount();
bool show_combobox = suggestion_count > 1 &&
combobox->selected_index() != suggestion_count - 1;
combobox->SetVisible(show_combobox);
group.manual_input->SetVisible(!show_combobox);
string16 suggestion_text =
controller_->SuggestionTextForSection(group.section);
group.manual_input->SetVisible(suggestion_text.empty());
group.suggested_info->SetVisible(!suggestion_text.empty());
group.suggested_info->SetText(suggestion_text);
if (GetWidget())
GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
}
AutofillDialogViews::DetailsGroup* AutofillDialogViews::
......@@ -470,10 +506,12 @@ AutofillDialogViews::DetailsGroup* AutofillDialogViews::
return NULL;
}
AutofillDialogViews::DetailsGroup::DetailsGroup()
: container(NULL),
suggested_input(NULL),
manual_input(NULL) {}
AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
: section(section),
container(NULL),
manual_input(NULL),
suggested_info(NULL),
suggested_button(NULL) {}
AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
......
......@@ -8,7 +8,7 @@
#include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
#include "chrome/browser/ui/autofill/autofill_dialog_view.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/combobox/combobox_listener.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/window/dialog_delegate.h"
......@@ -17,6 +17,10 @@ class ConstrainedWindowViews;
namespace views {
class Checkbox;
class Combobox;
class Label;
class MenuButton;
class MenuRunner;
class Textfield;
}
......@@ -34,7 +38,7 @@ struct DetailInput;
class AutofillDialogViews : public AutofillDialogView,
public views::DialogDelegate,
public views::ButtonListener,
public views::ComboboxListener,
public views::MenuButtonListener,
public views::TextfieldController,
public views::FocusChangeListener {
public:
......@@ -44,7 +48,6 @@ class AutofillDialogViews : public AutofillDialogView,
// AutofillDialogView implementation:
virtual void Show() OVERRIDE;
virtual void UpdateSection(DialogSection section) OVERRIDE;
virtual int GetSuggestionSelection(DialogSection section) OVERRIDE;
virtual void GetUserInput(DialogSection section,
DetailOutputMap* output) OVERRIDE;
virtual bool UseBillingForShipping() OVERRIDE;
......@@ -65,8 +68,9 @@ class AutofillDialogViews : public AutofillDialogView,
virtual void ButtonPressed(views::Button* sender,
const ui::Event& event) OVERRIDE;
// views::ComboboxListener implementation:
virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE;
// views::MenuButtonListener implementation:
virtual void OnMenuButtonClicked(views::View* source,
const gfx::Point& point) OVERRIDE;
// views::TextfieldController implementation:
virtual void ContentsChanged(views::Textfield* sender,
......@@ -87,19 +91,24 @@ class AutofillDialogViews : public AutofillDialogView,
// A convenience struct for holding pointers to views within each detail
// section. None of the member pointers are owned.
struct DetailsGroup {
DetailsGroup();
explicit DetailsGroup(DialogSection section);
~DetailsGroup();
// The section this group is associated with.
const DialogSection section;
// The view that contains the entire section (label + input).
views::View* container;
// The combobox that holds suggested values.
views::Combobox* suggested_input;
// The view that allows manual input.
views::View* manual_input;
// The textfields in |manual_input|, tracked by their DetailInput.
TextfieldMap textfields;
// The comboboxes in |manual_input|, tracked by their DetailInput.
ComboboxMap comboboxes;
// The label that holds the text of the suggested data. This will be
// visible IFF |manual_input| is not visible.
views::Label* suggested_info;
// The view that allows selecting other data suggestions.
views::MenuButton* suggested_button;
};
void InitChildViews();
......@@ -158,6 +167,9 @@ class AutofillDialogViews : public AutofillDialogView,
// as well.
views::Checkbox* use_billing_for_shipping_;
// Runs the suggestion menu (triggered by each section's |suggested_button|.
scoped_ptr<views::MenuRunner> menu_runner_;
DISALLOW_COPY_AND_ASSIGN(AutofillDialogViews);
};
......
......@@ -195,10 +195,10 @@
'browser/ui/aura/stacking_client_aura.cc',
'browser/ui/aura/stacking_client_aura.h',
'browser/ui/aura/tabs/dock_info_aurax11.cc',
'browser/ui/autofill/autofill_dialog_comboboxes.cc',
'browser/ui/autofill/autofill_dialog_comboboxes.h',
'browser/ui/autofill/autofill_dialog_controller.cc',
'browser/ui/autofill/autofill_dialog_controller.h',
'browser/ui/autofill/autofill_dialog_models.cc',
'browser/ui/autofill/autofill_dialog_models.h',
'browser/ui/autofill/autofill_dialog_view.cc',
'browser/ui/autofill/autofill_dialog_view.h',
'browser/ui/autofill/autofill_popup_controller.h',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment