summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/autofill/autofill_dialog.cc4
-rw-r--r--chrome/browser/autofill/autofill_dialog_win.cc13
-rw-r--r--chrome/browser/autofill/autofill_profiles_view_win.cc805
-rw-r--r--chrome/browser/autofill/autofill_profiles_view_win.h284
-rw-r--r--chrome/browser/autofill/credit_card.cc7
-rw-r--r--chrome/browser/autofill/credit_card.h1
-rwxr-xr-xchrome/chrome_browser.gypi3
8 files changed, 1121 insertions, 2 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 7b114de..3dfe9f1 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4794,6 +4794,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_OPTIONS_AUTOFILL_NEVERSAVE" desc="The label of the 'Never save autofill' radio button">
Never save text from forms
</message>
+ <message name="IDS_OPTIONS_AUTOFILL_SETTINGS" desc="The label of the 'Change autofill settings' button">
+ Change autofill settings
+ </message>
<message name="IDS_AUTOFILL_INFOBAR_ACCEPT" desc="Text to show for the autofill request infobar accept button.">
Set up AutoFill...
</message>
@@ -4893,6 +4896,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_AUTOFILL_DIALOG_MAKE_DEFAULT" desc="The label of the Make this my default profile entry.">
Make this my default profile
</message>
+ <message name="IDS_AUTOFILL_DIALOG_SAVE" desc="The label of the Save button on the autofill dialog.">
+ Save
+ </message>
<message name="IDS_THEMES_GROUP_NAME" desc="The title of the themes group">
Themes:
diff --git a/chrome/browser/autofill/autofill_dialog.cc b/chrome/browser/autofill/autofill_dialog.cc
index f574987..44df062 100644
--- a/chrome/browser/autofill/autofill_dialog.cc
+++ b/chrome/browser/autofill/autofill_dialog.cc
@@ -4,9 +4,9 @@
#include "chrome/browser/autofill/autofill_dialog.h"
-// TODO(georgey, dhollowa): Remove these as each platform implements this
+// TODO(dhollowa): Remove these as each platform implements this
// function. The last one to implement the function should remove this file.
-#if defined(OS_WIN) || defined(OS_MACOSX)
+#if defined(OS_MACOSX)
void ShowAutoFillDialog(AutoFillDialogObserver* observer,
const std::vector<AutoFillProfile*>& profiles,
const std::vector<CreditCard*>& credit_cards) {
diff --git a/chrome/browser/autofill/autofill_dialog_win.cc b/chrome/browser/autofill/autofill_dialog_win.cc
new file mode 100644
index 0000000..4ea73abd3
--- /dev/null
+++ b/chrome/browser/autofill/autofill_dialog_win.cc
@@ -0,0 +1,13 @@
+// Copyright (c) 2010 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/autofill/autofill_dialog.h"
+#include "chrome/browser/autofill/autofill_profiles_view_win.h"
+
+void ShowAutoFillDialog(AutoFillDialogObserver* observer,
+ const std::vector<AutoFillProfile*>& profiles,
+ const std::vector<CreditCard*>& credit_cards) {
+ AutoFillProfilesView::Show(observer, profiles, credit_cards);
+}
+
diff --git a/chrome/browser/autofill/autofill_profiles_view_win.cc b/chrome/browser/autofill/autofill_profiles_view_win.cc
new file mode 100644
index 0000000..238368b
--- /dev/null
+++ b/chrome/browser/autofill/autofill_profiles_view_win.cc
@@ -0,0 +1,805 @@
+// Copyright (c) 2010 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/autofill/autofill_profiles_view_win.h"
+
+#include <vsstyle.h>
+#include <vssym32.h>
+
+#include "app/gfx/canvas.h"
+#include "app/gfx/native_theme_win.h"
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "base/gfx/size.h"
+#include "base/message_loop.h"
+#include "grit/generated_resources.h"
+#include "grit/locale_settings.h"
+#include "views/controls/button/native_button.h"
+#include "views/controls/label.h"
+#include "views/controls/scroll_view.h"
+#include "views/grid_layout.h"
+#include "views/standard_layout.h"
+#include "views/window/window.h"
+
+namespace {
+
+// padding on the sides of AutoFill settings dialog.
+const int kDialogPadding = 7;
+
+// Insets for subview controls.
+const int kSubViewInsets = 5;
+
+// TODO(georgey) remove this code into a separate file as it is already the same
+// elsewhere.
+// A background object that paints the scrollable list background,
+// which may be rendered by the system visual styles system.
+class ListBackground : public views::Background {
+ public:
+ explicit ListBackground() {
+ SkColor list_color =
+ gfx::NativeTheme::instance()->GetThemeColorWithDefault(
+ gfx::NativeTheme::LIST, 1, TS_NORMAL, TMT_FILLCOLOR, COLOR_WINDOW);
+ SetNativeControlColor(list_color);
+ }
+ virtual ~ListBackground() {}
+
+ virtual void Paint(gfx::Canvas* canvas, views::View* view) const {
+ HDC dc = canvas->beginPlatformPaint();
+ RECT native_lb = view->GetLocalBounds(true).ToRECT();
+ gfx::NativeTheme::instance()->PaintListBackground(dc, true, &native_lb);
+ canvas->endPlatformPaint();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ListBackground);
+};
+
+}; // namespace
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView, static data:
+AutoFillProfilesView *AutoFillProfilesView::instance_ = NULL;
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::ScrollViewContents, static data:
+int AutoFillProfilesView::ScrollViewContents::line_height_ = 0;
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView, public:
+AutoFillProfilesView::AutoFillProfilesView(
+ AutoFillDialogObserver* observer,
+ const std::vector<AutoFillProfile*>& profiles,
+ const std::vector<CreditCard*>& credit_cards)
+ : observer_(observer),
+ scroll_view_(NULL),
+ save_changes_(NULL) {
+ profiles_set_.reserve(profiles.size());
+ for (std::vector<AutoFillProfile*>::const_iterator address_it =
+ profiles.begin();
+ address_it != profiles.end();
+ ++address_it) {
+ profiles_set_.push_back(EditableSetInfo(*address_it, true));
+ }
+ credit_card_set_.reserve(credit_cards.size());
+ for (std::vector<CreditCard*>::const_iterator cc_it = credit_cards.begin();
+ cc_it != credit_cards.end();
+ ++cc_it) {
+ credit_card_set_.push_back(EditableSetInfo(*cc_it, true));
+ }
+}
+
+AutoFillProfilesView::~AutoFillProfilesView() {
+}
+
+int AutoFillProfilesView::Show(AutoFillDialogObserver* observer,
+ const std::vector<AutoFillProfile*>& profiles,
+ const std::vector<CreditCard*>& credit_cards) {
+ if (!instance_) {
+ instance_ = new AutoFillProfilesView(observer, profiles, credit_cards);
+
+ // |instance_| will get deleted once Close() is called.
+ views::Window::CreateChromeWindow(NULL, gfx::Rect(), instance_);
+ }
+ if (!instance_->window()->IsVisible())
+ instance_->window()->Show();
+ else
+ instance_->window()->Activate();
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView, protected:
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView, views::View implementations
+void AutoFillProfilesView::Layout() {
+ scroll_view_->SetBounds(kDialogPadding, kDialogPadding,
+ width() - (2 * kDialogPadding),
+ height() - (2 * kDialogPadding));
+}
+
+gfx::Size AutoFillProfilesView::GetPreferredSize() {
+ return views::Window::GetLocalizedContentsSize(
+ IDS_AUTOFILL_DIALOG_WIDTH_CHARS,
+ IDS_AUTOFILL_DIALOG_HEIGHT_LINES);
+}
+
+void AutoFillProfilesView::ViewHierarchyChanged(bool is_add,
+ views::View* parent,
+ views::View* child) {
+ if (is_add && child == this)
+ Init();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView, views::DialogDelegate implementations:
+int AutoFillProfilesView::GetDialogButtons() const {
+ return MessageBoxFlags::DIALOGBUTTON_CANCEL |
+ MessageBoxFlags::DIALOGBUTTON_OK;
+}
+
+std::wstring AutoFillProfilesView::GetDialogButtonLabel(
+ MessageBoxFlags::DialogButton button) const {
+ switch (button) {
+ case MessageBoxFlags::DIALOGBUTTON_OK:
+ return l10n_util::GetString(IDS_AUTOFILL_DIALOG_SAVE);
+ case MessageBoxFlags::DIALOGBUTTON_CANCEL:
+ return std::wstring();
+ default:
+ break;
+ }
+ NOTREACHED();
+ return std::wstring();
+}
+
+std::wstring AutoFillProfilesView::GetWindowTitle() const {
+ return l10n_util::GetString(IDS_AUTOFILL_DIALOG_TITLE);
+}
+
+void AutoFillProfilesView::WindowClosing() {
+ instance_ = NULL;
+}
+
+views::View* AutoFillProfilesView::GetContentsView() {
+ return this;
+}
+
+bool AutoFillProfilesView::Accept() {
+ DCHECK(observer_);
+ std::vector<AutoFillProfile> profiles;
+ profiles.reserve(profiles_set_.size());
+ std::vector<EditableSetInfo>::iterator it;
+ for (it = profiles_set_.begin(); it != profiles_set_.end(); ++it) {
+ profiles.push_back(it->address);
+ }
+ std::vector<CreditCard> credit_cards;
+ credit_cards.reserve(credit_card_set_.size());
+ for (it = credit_card_set_.begin(); it != credit_card_set_.end(); ++it) {
+ credit_cards.push_back(it->credit_card);
+ }
+ observer_->OnAutoFillDialogApply(&profiles, &credit_cards);
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView, views::ButtonListener implementations:
+void AutoFillProfilesView::ButtonPressed(views::Button* sender,
+ const views::Event& event) {
+ NOTIMPLEMENTED();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView, private:
+void AutoFillProfilesView::Init() {
+ scroll_view_ = new AutoFillScrollView(&profiles_set_, &credit_card_set_);
+
+ views::GridLayout* layout = CreatePanelGridLayout(this);
+ SetLayoutManager(layout);
+
+ const int single_column_view_set_id = 0;
+ views::ColumnSet* column_set =
+ layout->AddColumnSet(single_column_view_set_id);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ layout->StartRow(1, single_column_view_set_id);
+ layout->AddView(scroll_view_);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::PhoneSubView, public:
+AutoFillProfilesView::PhoneSubView::PhoneSubView(
+ views::Label* label,
+ views::Textfield* text_country,
+ views::Textfield* text_area,
+ views::Textfield* text_phone)
+ : label_(label),
+ text_country_(text_country),
+ text_area_(text_area),
+ text_phone_(text_phone) {
+ DCHECK(label_);
+ DCHECK(text_country_);
+ DCHECK(text_area_);
+ DCHECK(text_phone_);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::PhoneSubView, protected:
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::PhoneSubView, views::View implementations
+void AutoFillProfilesView::PhoneSubView::ViewHierarchyChanged(
+ bool is_add, views::View* parent, views::View* child) {
+ if (is_add && this == child) {
+ views::GridLayout* layout = new views::GridLayout(this);
+ SetLayoutManager(layout);
+ const int triple_column_fill_view_set_id = 0;
+ views::ColumnSet* column_set =
+ layout->AddColumnSet(triple_column_fill_view_set_id);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ layout->StartRow(0, triple_column_fill_view_set_id);
+ layout->AddView(label_, 5, 1);
+ layout->StartRow(0, triple_column_fill_view_set_id);
+ text_country_->set_default_width_in_chars(3);
+ text_area_->set_default_width_in_chars(3);
+ text_phone_->set_default_width_in_chars(7);
+ layout->AddView(text_country_);
+ layout->AddView(text_area_);
+ layout->AddView(text_phone_);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::EditableSetViewContents, static data:
+AutoFillProfilesView::EditableSetViewContents::TextFieldToAutoFill
+ AutoFillProfilesView::EditableSetViewContents::address_fields_[] = {
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_LABEL, NO_SERVER_DATA },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_FIRST_NAME,
+ NAME_FIRST },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_MIDDLE_NAME,
+ NAME_MIDDLE },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_LAST_NAME,
+ NAME_LAST },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_EMAIL, EMAIL_ADDRESS },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_COMPANY_NAME,
+ COMPANY_NAME },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_ADDRESS_LINE_1,
+ ADDRESS_HOME_LINE1 },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_ADDRESS_LINE_2,
+ ADDRESS_HOME_LINE2 },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_ADDRESS_CITY,
+ ADDRESS_HOME_CITY },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_ADDRESS_STATE,
+ ADDRESS_HOME_STATE },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_ADDRESS_ZIP,
+ ADDRESS_HOME_ZIP },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_ADDRESS_COUNTRY,
+ ADDRESS_HOME_COUNTRY },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_PHONE_COUNTRY,
+ PHONE_HOME_COUNTRY_CODE },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_PHONE_AREA,
+ PHONE_HOME_CITY_CODE },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_PHONE_PHONE,
+ PHONE_HOME_NUMBER },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_FAX_COUNTRY,
+ PHONE_FAX_COUNTRY_CODE },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_FAX_AREA,
+ PHONE_FAX_CITY_CODE },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_FAX_PHONE,
+ PHONE_FAX_NUMBER },
+};
+
+AutoFillProfilesView::EditableSetViewContents::TextFieldToAutoFill
+ AutoFillProfilesView::EditableSetViewContents::credit_card_fields_[] = {
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_LABEL, NO_SERVER_DATA },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_CC_NAME,
+ CREDIT_CARD_NAME },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_CC_NUMBER,
+ CREDIT_CARD_NUMBER },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_CC_EXPIRATION_MONTH,
+ CREDIT_CARD_EXP_MONTH },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_CC_EXPIRATION_YEAR,
+ CREDIT_CARD_EXP_2_DIGIT_YEAR },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_CC_EXPIRATION_CVC,
+ CREDIT_CARD_VERIFICATION_CODE },
+ /* phone is disabled for now
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_PHONE_COUNTRY,
+ PHONE_HOME_COUNTRY_CODE },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_PHONE_AREA,
+ PHONE_HOME_CITY_CODE },
+ { AutoFillProfilesView::EditableSetViewContents::TEXT_PHONE_PHONE,
+ PHONE_HOME_NUMBER },
+ */
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::EditableSetViewContents, public:
+AutoFillProfilesView::EditableSetViewContents::EditableSetViewContents(
+ std::vector<EditableSetInfo>::iterator field_set)
+ : editable_fields_set_(field_set),
+ delete_button_(NULL),
+ title_label_(NULL) {
+ ZeroMemory(text_fields_, sizeof(text_fields_));
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::EditableSetViewContents, protected:
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::EditableSetViewContents, views::View implementations
+void AutoFillProfilesView::EditableSetViewContents::Layout() {
+ View::Layout();
+}
+
+gfx::Size AutoFillProfilesView::EditableSetViewContents::GetPreferredSize() {
+ gfx::Size prefsize;
+ views::View* parent = GetParent();
+ if (parent && parent->width()) {
+ const int width = parent->width();
+ prefsize = gfx::Size(width, GetHeightForWidth(width));
+ }
+ return prefsize;
+}
+
+void AutoFillProfilesView::EditableSetViewContents::ViewHierarchyChanged(
+ bool is_add, views::View* parent, views::View* child) {
+ if (is_add && this == child) {
+ views::GridLayout* layout = new views::GridLayout(this);
+ layout->SetInsets(kSubViewInsets, kSubViewInsets,
+ kSubViewInsets, kSubViewInsets);
+ SetLayoutManager(layout);
+ InitLayoutGrid(layout);
+ delete_button_ = new views::NativeButton(this,
+ l10n_util::GetString(IDS_AUTOFILL_DELETE_BUTTON));
+ if (editable_fields_set_->is_address)
+ InitAddressFields(layout);
+ else
+ InitCreditCardFields(layout);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::EditableSetViewContents,
+// views::Textfield::Controller implementations
+void AutoFillProfilesView::EditableSetViewContents::ContentsChanged(
+ views::Textfield* sender, const string16& new_contents) {
+ if (editable_fields_set_->is_address) {
+ for (int field = 0; field < arraysize(address_fields_); ++field) {
+ DCHECK(text_fields_[address_fields_[field].text_field]);
+ if (text_fields_[address_fields_[field].text_field] == sender) {
+ if (address_fields_[field].text_field == TEXT_LABEL)
+ editable_fields_set_->address.set_label(new_contents);
+ else
+ editable_fields_set_->address.SetInfo(
+ AutoFillType(address_fields_[field].type), new_contents);
+ return;
+ }
+ }
+ } else {
+ for (int field = 0; field < arraysize(credit_card_fields_); ++field) {
+ DCHECK(text_fields_[credit_card_fields_[field].text_field]);
+ if (text_fields_[credit_card_fields_[field].text_field] == sender) {
+ if (credit_card_fields_[field].text_field == TEXT_LABEL)
+ editable_fields_set_->credit_card.set_label(new_contents);
+ else
+ editable_fields_set_->credit_card.SetInfo(
+ AutoFillType(credit_card_fields_[field].type), new_contents);
+ return;
+ }
+ }
+ }
+}
+
+bool AutoFillProfilesView::EditableSetViewContents::HandleKeystroke(
+ views::Textfield* sender, const views::Textfield::Keystroke& keystroke) {
+ return false;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::EditableSetViewContents,
+// views::ButtonListener implementations
+void AutoFillProfilesView::EditableSetViewContents::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::EditableSetViewContents, private:
+void AutoFillProfilesView::EditableSetViewContents::InitAddressFields(
+ views::GridLayout* layout) {
+ DCHECK(editable_fields_set_->is_address);
+ std::wstring title = editable_fields_set_->address.Label();
+ if (title.empty())
+ title = l10n_util::GetString(IDS_AUTOFILL_NEW_ADDRESS);
+ title_label_ = new views::Label(title);
+
+ for (int field = 0; field < arraysize(address_fields_); ++field) {
+ DCHECK(!text_fields_[address_fields_[field].text_field]);
+ text_fields_[address_fields_[field].text_field] =
+ new views::Textfield(views::Textfield::STYLE_DEFAULT);
+ text_fields_[address_fields_[field].text_field]->SetController(this);
+ if (address_fields_[field].text_field == TEXT_LABEL) {
+ text_fields_[TEXT_LABEL]->SetText(
+ editable_fields_set_->address.Label());
+ } else {
+ text_fields_[address_fields_[field].text_field]->SetText(
+ editable_fields_set_->address.GetFieldText(
+ AutoFillType(address_fields_[field].type)));
+ }
+ }
+
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ gfx::Font title_font =
+ rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
+ title_label_->SetFont(title_font);
+
+ SkColor title_color =
+ gfx::NativeTheme::instance()->GetThemeColorWithDefault(
+ gfx::NativeTheme::BUTTON, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR,
+ COLOR_WINDOWTEXT);
+ title_label_->SetColor(title_color);
+ SkColor bk_color =
+ gfx::NativeTheme::instance()->GetThemeColorWithDefault(
+ gfx::NativeTheme::BUTTON, BP_PUSHBUTTON, PBS_NORMAL, TMT_BTNFACE,
+ COLOR_BTNFACE);
+ title_label_->set_background(
+ views::Background::CreateSolidBackground(bk_color));
+ title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+
+ layout->StartRow(0, triple_column_fill_view_set_id_);
+ layout->AddView(title_label_, 5, 1);
+ layout->StartRow(0, triple_column_leading_view_set_id_);
+ layout->AddView(new views::Label(
+ l10n_util::GetString(IDS_AUTOFILL_DIALOG_LABEL)));
+ layout->StartRow(0, triple_column_fill_view_set_id_);
+ layout->AddView(text_fields_[TEXT_LABEL]);
+ layout->StartRow(0, triple_column_fill_view_set_id_);
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_FIRST_NAME));
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_MIDDLE_NAME));
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_LAST_NAME));
+ layout->StartRow(0, triple_column_fill_view_set_id_);
+ layout->AddView(text_fields_[TEXT_FIRST_NAME]);
+ layout->AddView(text_fields_[TEXT_MIDDLE_NAME]);
+ layout->AddView(text_fields_[TEXT_LAST_NAME]);
+
+ layout->StartRow(0, triple_column_leading_view_set_id_);
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_EMAIL));
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_COMPANY_NAME));
+
+ layout->StartRow(0, triple_column_fill_view_set_id_);
+ layout->AddView(text_fields_[TEXT_EMAIL]);
+ layout->AddView(text_fields_[TEXT_COMPANY_NAME]);
+
+ layout->StartRow(0, triple_column_leading_view_set_id_);
+ layout->AddView(new views::Label(l10n_util::GetString(
+ IDS_AUTOFILL_DIALOG_ADDRESS_LINE_1)), 3, 1);
+
+ layout->StartRow(0, triple_column_fill_view_set_id_);
+ layout->AddView(text_fields_[TEXT_ADDRESS_LINE_1], 3, 1);
+
+ layout->StartRow(0, triple_column_leading_view_set_id_);
+ layout->AddView(new views::Label(l10n_util::GetString(
+ IDS_AUTOFILL_DIALOG_ADDRESS_LINE_2)), 3, 1);
+
+ layout->StartRow(0, triple_column_fill_view_set_id_);
+ layout->AddView(text_fields_[TEXT_ADDRESS_LINE_2], 3, 1);
+
+ layout->StartRow(0, four_column_city_state_zip_set_id_);
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_CITY));
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_STATE));
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_ZIP_CODE));
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_COUNTRY));
+ // City (33% - 16/48), state(33%), zip (12.7% - 5/42), country (21% - 11/48)
+ text_fields_[TEXT_ADDRESS_CITY]->set_default_width_in_chars(16);
+ text_fields_[TEXT_ADDRESS_STATE]->set_default_width_in_chars(16);
+ text_fields_[TEXT_ADDRESS_ZIP]->set_default_width_in_chars(5);
+ text_fields_[TEXT_ADDRESS_COUNTRY]->set_default_width_in_chars(11);
+
+ layout->StartRow(0, four_column_city_state_zip_set_id_);
+ layout->AddView(text_fields_[TEXT_ADDRESS_CITY]);
+ layout->AddView(text_fields_[TEXT_ADDRESS_STATE]);
+ layout->AddView(text_fields_[TEXT_ADDRESS_ZIP]);
+ layout->AddView(text_fields_[TEXT_ADDRESS_COUNTRY]);
+
+ PhoneSubView *phone = new PhoneSubView(
+ CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_PHONE),
+ text_fields_[TEXT_PHONE_COUNTRY],
+ text_fields_[TEXT_PHONE_AREA],
+ text_fields_[TEXT_PHONE_PHONE]);
+
+ PhoneSubView *fax = new PhoneSubView(
+ CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_FAX),
+ text_fields_[TEXT_FAX_COUNTRY],
+ text_fields_[TEXT_FAX_AREA],
+ text_fields_[TEXT_FAX_PHONE]);
+
+ layout->StartRow(0, double_column_fill_view_set_id_);
+ layout->AddView(phone);
+ layout->AddView(fax);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ layout->StartRow(0, triple_column_leading_view_set_id_);
+ layout->AddView(delete_button_);
+}
+
+void AutoFillProfilesView::EditableSetViewContents::InitCreditCardFields(
+ views::GridLayout* layout) {
+ DCHECK(!editable_fields_set_->is_address);
+ std::wstring title = editable_fields_set_->credit_card.Label();
+ if (title.empty())
+ title = l10n_util::GetString(IDS_AUTOFILL_NEW_CREDITCARD);
+ title_label_ = new views::Label(title);
+
+ for (int field = 0; field < arraysize(credit_card_fields_); ++field) {
+ DCHECK(!text_fields_[credit_card_fields_[field].text_field]);
+ text_fields_[credit_card_fields_[field].text_field] =
+ new views::Textfield(views::Textfield::STYLE_DEFAULT);
+ text_fields_[credit_card_fields_[field].text_field]->SetController(this);
+ if (credit_card_fields_[field].text_field == TEXT_LABEL) {
+ text_fields_[TEXT_LABEL]->SetText(
+ editable_fields_set_->credit_card.Label());
+ } else {
+ text_fields_[credit_card_fields_[field].text_field]->SetText(
+ editable_fields_set_->credit_card.GetFieldText(
+ AutoFillType(credit_card_fields_[field].type)));
+ }
+ }
+
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ gfx::Font title_font =
+ rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
+ title_label_->SetFont(title_font);
+
+ SkColor title_color =
+ gfx::NativeTheme::instance()->GetThemeColorWithDefault(
+ gfx::NativeTheme::BUTTON, BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR,
+ COLOR_WINDOWTEXT);
+ title_label_->SetColor(title_color);
+ SkColor bk_color =
+ gfx::NativeTheme::instance()->GetThemeColorWithDefault(
+ gfx::NativeTheme::BUTTON, BP_PUSHBUTTON, PBS_NORMAL, TMT_BTNFACE,
+ COLOR_BTNFACE);
+ title_label_->set_background(
+ views::Background::CreateSolidBackground(bk_color));
+ title_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+
+ layout->StartRow(0, triple_column_fill_view_set_id_);
+ layout->AddView(title_label_, 5, 1);
+
+ layout->StartRow(0, triple_column_leading_view_set_id_);
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_LABEL));
+ layout->StartRow(0, triple_column_fill_view_set_id_);
+ layout->AddView(text_fields_[TEXT_LABEL]);
+ layout->StartRow(0, double_column_fill_view_set_id_);
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_NAME_ON_CARD));
+ layout->StartRow(0, double_column_fill_view_set_id_);
+ layout->AddView(text_fields_[TEXT_CC_NAME]);
+ layout->StartRow(0, four_column_ccnumber_expiration_cvc_);
+ layout->AddView(
+ CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_CREDIT_CARD_NUMBER));
+ layout->AddView(
+ CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_EXPIRATION_DATE), 2, 1);
+ layout->AddView(CreateLeftAlignedLabel(IDS_AUTOFILL_DIALOG_CVC));
+ layout->StartRow(0, four_column_ccnumber_expiration_cvc_);
+ // Number (20 chars), month(2 chars), year (4 chars), cvc (4 chars)
+ text_fields_[TEXT_CC_NUMBER]->set_default_width_in_chars(20);
+ text_fields_[TEXT_CC_EXPIRATION_MONTH]->set_default_width_in_chars(2);
+ text_fields_[TEXT_CC_EXPIRATION_YEAR]->set_default_width_in_chars(4);
+ text_fields_[TEXT_CC_EXPIRATION_CVC]->set_default_width_in_chars(4);
+ layout->AddView(text_fields_[TEXT_CC_NUMBER]);
+ layout->AddView(text_fields_[TEXT_CC_EXPIRATION_MONTH]);
+ layout->AddView(text_fields_[TEXT_CC_EXPIRATION_YEAR]);
+ layout->AddView(text_fields_[TEXT_CC_EXPIRATION_CVC]);
+}
+
+void AutoFillProfilesView::EditableSetViewContents::InitLayoutGrid(
+ views::GridLayout* layout) {
+ views::ColumnSet* column_set =
+ layout->AddColumnSet(double_column_fill_view_set_id_);
+ int i;
+ for (i = 0; i < 2; ++i) {
+ if (i)
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ }
+ column_set = layout->AddColumnSet(double_column_leading_view_set_id_);
+ for (i = 0; i < 2; ++i) {
+ if (i)
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ }
+ column_set = layout->AddColumnSet(triple_column_fill_view_set_id_);
+ for (i = 0; i < 3; ++i) {
+ if (i)
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ }
+ column_set = layout->AddColumnSet(triple_column_leading_view_set_id_);
+ for (i = 0; i < 3; ++i) {
+ if (i)
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ }
+ column_set = layout->AddColumnSet(four_column_city_state_zip_set_id_);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+
+ column_set = layout->AddColumnSet(four_column_ccnumber_expiration_cvc_);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+}
+
+views::Label*
+AutoFillProfilesView::EditableSetViewContents::CreateLeftAlignedLabel(
+ int label_id) {
+ views::Label* label = new views::Label(l10n_util::GetString(label_id));
+ label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ return label;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::ScrollViewContents, public:
+AutoFillProfilesView::ScrollViewContents::ScrollViewContents(
+ std::vector<EditableSetInfo>* profiles,
+ std::vector<EditableSetInfo>* credit_cards)
+ : profiles_(profiles),
+ credit_cards_(credit_cards),
+ add_address_(NULL),
+ add_credit_card_(NULL) {
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::ScrollViewContents, protected:
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::ScrollViewContents, views::View implementations
+int AutoFillProfilesView::ScrollViewContents::GetLineScrollIncrement(
+ views::ScrollView* scroll_view, bool is_horizontal, bool is_positive) {
+ if (!is_horizontal)
+ return line_height_;
+ return View::GetPageScrollIncrement(scroll_view, is_horizontal, is_positive);
+}
+
+void AutoFillProfilesView::ScrollViewContents::Layout() {
+ views::View* parent = GetParent();
+ if (parent && parent->width()) {
+ const int width = parent->width();
+ const int height = GetHeightForWidth(width);
+ SetBounds(0, 0, width, height);
+ } else {
+ gfx::Size prefsize = GetPreferredSize();
+ SetBounds(0, 0, prefsize.width(), prefsize.height());
+ }
+ View::Layout();
+}
+
+gfx::Size AutoFillProfilesView::ScrollViewContents::GetPreferredSize() {
+ return gfx::Size();
+}
+
+void AutoFillProfilesView::ScrollViewContents::ViewHierarchyChanged(
+ bool is_add, views::View* parent, views::View* child) {
+ if (is_add && this == child) {
+ if (!line_height_) {
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ line_height_ = rb.GetFont(ResourceBundle::BaseFont).height();
+ }
+
+ gfx::Rect lb = GetLocalBounds(false);
+ SetBounds(lb);
+
+ views::GridLayout* layout = new views::GridLayout(this);
+ SetLayoutManager(layout);
+
+ const int single_column_filled_view_set_id = 0;
+ views::ColumnSet* column_set =
+ layout->AddColumnSet(single_column_filled_view_set_id);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ const int single_column_left_view_set_id = 1;
+ column_set = layout->AddColumnSet(single_column_left_view_set_id);
+ column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ views::Label *title_label = new views::Label(
+ l10n_util::GetString(IDS_AUTOFILL_ADDRESSES_GROUP_NAME));
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ gfx::Font title_font =
+ rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD);
+ title_label->SetFont(title_font);
+ layout->StartRow(0, single_column_left_view_set_id);
+ layout->AddView(title_label);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ std::vector<EditableSetInfo>::iterator it;
+ for (it = profiles_->begin(); it != profiles_->end(); ++it) {
+ EditableSetViewContents *address_view =
+ new EditableSetViewContents(it);
+ layout->StartRow(0, single_column_filled_view_set_id);
+ layout->AddView(address_view);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ }
+
+ add_address_ = new views::NativeButton(this,
+ l10n_util::GetString(IDS_AUTOFILL_ADD_ADDRESS_BUTTON));
+ layout->StartRow(0, single_column_left_view_set_id);
+ layout->AddView(add_address_);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ title_label = new views::Label(
+ l10n_util::GetString(IDS_AUTOFILL_CREDITCARDS_GROUP_NAME));
+ title_label->SetFont(title_font);
+ layout->StartRow(0, single_column_left_view_set_id);
+ layout->AddView(title_label);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ for (it = credit_cards_->begin(); it != credit_cards_->end(); ++it) {
+ EditableSetViewContents *address_view =
+ new EditableSetViewContents(it);
+ layout->StartRow(0, single_column_filled_view_set_id);
+ layout->AddView(address_view);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ }
+
+ add_credit_card_ = new views::NativeButton(this,
+ l10n_util::GetString(IDS_AUTOFILL_ADD_CREDITCARD_BUTTON));
+
+ layout->StartRow(0, single_column_left_view_set_id);
+ layout->AddView(add_credit_card_);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::ScrollViewContents,
+// views::ButtonListener implementations
+void AutoFillProfilesView::ScrollViewContents::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
+ NOTIMPLEMENTED();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::AutoFillScrollView, public:
+AutoFillProfilesView::AutoFillScrollView::AutoFillScrollView(
+ std::vector<EditableSetInfo>* profiles,
+ std::vector<EditableSetInfo>* credit_cards)
+ : scroll_view_(new views::ScrollView),
+ scroll_contents_view_(new ScrollViewContents(profiles, credit_cards)) {
+ AddChildView(scroll_view_);
+ scroll_view_->SetContents(scroll_contents_view_);
+ set_background(new ListBackground());
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView::AutoFillScrollView, views::View implementations
+void AutoFillProfilesView::AutoFillScrollView::Layout() {
+ gfx::Rect lb = GetLocalBounds(false);
+
+ gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize(
+ gfx::NativeTheme::LIST);
+ lb.Inset(border.width(), border.height());
+ scroll_view_->SetBounds(lb);
+ scroll_view_->Layout();
+}
+
diff --git a/chrome/browser/autofill/autofill_profiles_view_win.h b/chrome/browser/autofill/autofill_profiles_view_win.h
new file mode 100644
index 0000000..d4afa25
--- /dev/null
+++ b/chrome/browser/autofill/autofill_profiles_view_win.h
@@ -0,0 +1,284 @@
+// Copyright (c) 2010 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.
+
+#ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILES_VIEW_WIN_H_
+#define CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILES_VIEW_WIN_H_
+
+#include <vector>
+
+#include "chrome/browser/autofill/autofill_dialog.h"
+#include "chrome/browser/autofill/autofill_profile.h"
+#include "views/controls/textfield/textfield.h"
+#include "views/view.h"
+#include "views/window/dialog_delegate.h"
+
+namespace views {
+class ScrollView;
+class Label;
+class GridLayout;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// AutoFillProfilesView
+//
+// The contents of the "Autofill profiles" dialog window.
+//
+// Overview: has following sub-views:
+// AutoFillScrollView - scroll view that has all of the addresses and credit
+// cards. Implemented by connecting views::ScrollView to ScrollViewContents.
+// ScrollViewContents - contents of the scroll view. Has multiple
+// EditableSetViewContents views for credit cards and addresses and
+// 'Add address' and 'Add Credit Card' buttons.
+// EditableSetViewContents - set of displayed fields for address or credit card,
+// has iterator to std::vector<EditableSetInfo> vector so data could be
+// updated or notifications passes to the dialog view.
+// PhoneSubView - support view for the phone fields sets. used in
+// ScrollViewContents.
+// And there is a support data structure EditableSetInfo which encapsulates
+// editable set (address or credit card) and allows for quick addition and
+// deletion.
+class AutoFillProfilesView : public views::View,
+ public views::DialogDelegate,
+ public views::ButtonListener {
+ public:
+ virtual ~AutoFillProfilesView();
+
+ static int Show(AutoFillDialogObserver* observer,
+ const std::vector<AutoFillProfile*>& profiles,
+ const std::vector<CreditCard*>& credit_cards);
+
+ protected:
+ // views::View methods:
+ virtual void Layout();
+ virtual gfx::Size GetPreferredSize();
+ virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
+ views::View* child);
+
+ // views::DialogDelegate methods:
+ virtual int GetDialogButtons() const;
+ virtual std::wstring GetDialogButtonLabel(
+ MessageBoxFlags::DialogButton button) const;
+ virtual bool CanResize() const { return true; }
+ virtual bool CanMaximize() const { return true; }
+ virtual bool IsAlwaysOnTop() const { return false; }
+ virtual bool HasAlwaysOnTopMenu() const { return false; }
+ virtual std::wstring GetWindowTitle() const;
+ virtual void WindowClosing();
+ virtual views::View* GetContentsView();
+ virtual bool Accept();
+
+ // views::ButtonListener methods:
+ virtual void ButtonPressed(views::Button* sender,
+ const views::Event& event);
+
+ // Helper structure to keep info on one address or credit card.
+ // Keeps info on one item in EditableSetViewContents.
+ // Also keeps info on opened status. Allows to quickly add and delete items,
+ // and then rebuild EditableSetViewContents.
+ struct EditableSetInfo {
+ bool is_address;
+ bool is_opened;
+ // If |is_address| is true |address| has some data and |credit_card|
+ // is empty, and vice versa
+ AutoFillProfile address;
+ CreditCard credit_card;
+
+ EditableSetInfo(const AutoFillProfile* input_address, bool opened)
+ : address(*input_address),
+ is_address(true),
+ is_opened(opened) {
+ }
+ EditableSetInfo(const CreditCard* input_credit_card, bool opened)
+ : credit_card(*input_credit_card),
+ is_address(false),
+ is_opened(opened) {
+ }
+ };
+
+ // Callbacks, called from EditableSetViewContents and ScrollViewContents.
+ // Called from ScrollViewContents when 'Add Address' (|address| is true) or
+ // 'Add Credit Card' (|address| is false) is clicked.
+ void AddClicked(bool address);
+ // Called from EditableSetViewContents when 'Delete' is clicked.
+ // |field_set_iterator| is iterator to item being deleted
+ void DeleteEditableSet(std::vector<EditableSetInfo>::iterator
+ field_set_iterator);
+ // Called from EditableSetViewContents when header of the item is clicked
+ // either to collapse or expand. |field_set_iterator| is iterator to item
+ // being changed.
+ void CollapseStateChanged(std::vector<EditableSetInfo>::iterator
+ field_set_iterator);
+
+ private:
+ AutoFillProfilesView(AutoFillDialogObserver* observer,
+ const std::vector<AutoFillProfile*>& profiles,
+ const std::vector<CreditCard*>& credit_cards);
+ void Init();
+
+ // PhoneSubView encapsulates three phone fields (country, area, and phone)
+ // and label above them, so they could be used together in one grid cell.
+ class PhoneSubView : public views::View {
+ public:
+ PhoneSubView(views::Label* label,
+ views::Textfield* text_country,
+ views::Textfield* text_area,
+ views::Textfield* text_phone);
+ virtual ~PhoneSubView() {}
+
+ protected:
+ // views::View methods:
+ virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
+ views::View* child);
+ private:
+ views::Label* label_;
+ views::Textfield* text_country_;
+ views::Textfield* text_area_;
+ views::Textfield* text_phone_;
+
+ DISALLOW_COPY_AND_ASSIGN(PhoneSubView);
+ };
+
+ // Sub-view dealing with addresses.
+ class EditableSetViewContents : public views::View,
+ public views::Textfield::Controller,
+ public views::ButtonListener {
+ public:
+ explicit EditableSetViewContents(
+ std::vector<EditableSetInfo>::iterator field_set);
+ virtual ~EditableSetViewContents() {}
+
+ protected:
+ // views::View methods:
+ virtual void Layout();
+ virtual gfx::Size GetPreferredSize();
+ virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
+ views::View* child);
+
+ // views::Textfield::Controller methods:
+ virtual void ContentsChanged(views::Textfield* sender,
+ const string16& new_contents);
+ virtual bool HandleKeystroke(views::Textfield* sender,
+ const views::Textfield::Keystroke& keystroke);
+
+ // views::ButtonListener methods:
+ virtual void ButtonPressed(views::Button* sender,
+ const views::Event& event);
+ private:
+ void InitAddressFields(views::GridLayout* layout);
+ void InitCreditCardFields(views::GridLayout* layout);
+ void InitLayoutGrid(views::GridLayout* layout);
+ views::Label* CreateLeftAlignedLabel(int label_id);
+
+ enum TextFields {
+ TEXT_LABEL,
+ TEXT_FIRST_NAME,
+ TEXT_MIDDLE_NAME,
+ TEXT_LAST_NAME,
+ TEXT_EMAIL,
+ TEXT_COMPANY_NAME,
+ TEXT_ADDRESS_LINE_1,
+ TEXT_ADDRESS_LINE_2,
+ TEXT_ADDRESS_CITY,
+ TEXT_ADDRESS_STATE,
+ TEXT_ADDRESS_ZIP,
+ TEXT_ADDRESS_COUNTRY,
+ TEXT_PHONE_COUNTRY,
+ TEXT_PHONE_AREA,
+ TEXT_PHONE_PHONE,
+ TEXT_FAX_COUNTRY,
+ TEXT_FAX_AREA,
+ TEXT_FAX_PHONE,
+ TEXT_CC_NAME,
+ TEXT_CC_NUMBER,
+ TEXT_CC_EXPIRATION_MONTH,
+ TEXT_CC_EXPIRATION_YEAR,
+ TEXT_CC_EXPIRATION_CVC,
+ // must be last
+ MAX_TEXT_FIELD
+ };
+ views::Textfield* text_fields_[MAX_TEXT_FIELD];
+ std::vector<EditableSetInfo>::iterator editable_fields_set_;
+ views::Label* title_label_;
+ views::Button* delete_button_;
+
+ struct TextFieldToAutoFill {
+ TextFields text_field;
+ AutoFillFieldType type;
+ };
+
+ static TextFieldToAutoFill address_fields_[];
+ static TextFieldToAutoFill credit_card_fields_[];
+
+ static const int double_column_fill_view_set_id_ = 0;
+ static const int double_column_leading_view_set_id_ = 1;
+ static const int triple_column_fill_view_set_id_ = 2;
+ static const int triple_column_leading_view_set_id_ = 3;
+ static const int four_column_city_state_zip_set_id_ = 4;
+ static const int four_column_ccnumber_expiration_cvc_ = 5;
+
+ DISALLOW_COPY_AND_ASSIGN(EditableSetViewContents);
+ };
+
+ // Sub-view for scrolling credit cards and addresses
+ class ScrollViewContents : public views::View,
+ public views::ButtonListener {
+ public:
+ ScrollViewContents(std::vector<EditableSetInfo>* profiles,
+ std::vector<EditableSetInfo>* credit_cards);
+ virtual ~ScrollViewContents() {}
+
+ protected:
+ // views::View methods:
+ virtual int GetLineScrollIncrement(views::ScrollView* scroll_view,
+ bool is_horizontal, bool is_positive);
+ virtual void Layout();
+ virtual gfx::Size GetPreferredSize();
+ virtual void ViewHierarchyChanged(bool is_add, views::View* parent,
+ views::View* child);
+ // views::ButtonListener methods:
+ virtual void ButtonPressed(views::Button* sender,
+ const views::Event& event);
+ private:
+ std::vector<EditableSetInfo>* profiles_;
+ std::vector<EditableSetInfo>* credit_cards_;
+ views::Button* add_address_;
+ views::Button* add_credit_card_;
+
+ static int line_height_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScrollViewContents);
+ };
+
+ class AutoFillScrollView : public views::View {
+ public:
+ AutoFillScrollView(std::vector<EditableSetInfo>* profiles,
+ std::vector<EditableSetInfo>* credit_cards);
+ virtual ~AutoFillScrollView() {}
+
+ protected:
+ // views::View overrides:
+ virtual void Layout();
+
+ private:
+ // The scroll view that contains list of the profiles.
+ views::ScrollView* scroll_view_;
+ ScrollViewContents* scroll_contents_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutoFillScrollView);
+ };
+
+ AutoFillDialogObserver* observer_;
+ std::vector<EditableSetInfo> profiles_set_;
+ std::vector<EditableSetInfo> credit_card_set_;
+
+ views::Button* save_changes_;
+ AutoFillScrollView* scroll_view_;
+
+ static AutoFillProfilesView* instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutoFillProfilesView);
+};
+
+#endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILES_VIEW_WIN_H_
+
diff --git a/chrome/browser/autofill/credit_card.cc b/chrome/browser/autofill/credit_card.cc
index 882a062..7c33206 100644
--- a/chrome/browser/autofill/credit_card.cc
+++ b/chrome/browser/autofill/credit_card.cc
@@ -34,6 +34,13 @@ CreditCard::CreditCard(const string16& label, int unique_id)
CreditCard::CreditCard(const CreditCard& card) {
operator=(card);
}
+
+CreditCard::CreditCard()
+ : expiration_month_(0),
+ expiration_year_(0) {
+}
+
+
FormGroup* CreditCard::Clone() const {
return new CreditCard(*this);
}
diff --git a/chrome/browser/autofill/credit_card.h b/chrome/browser/autofill/credit_card.h
index 3962c40..7c9716e 100644
--- a/chrome/browser/autofill/credit_card.h
+++ b/chrome/browser/autofill/credit_card.h
@@ -16,6 +16,7 @@ class CreditCard : public FormGroup {
CreditCard(const string16& label, int unique_id);
// For use in STL containers.
CreditCard(const CreditCard& card);
+ CreditCard();
// FormGroup implementation:
FormGroup* Clone() const;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 1bc51be..520d02a 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -87,6 +87,7 @@
'browser/autofill/address.h',
'browser/autofill/autofill_dialog_gtk.cc',
'browser/autofill/autofill_dialog.cc',
+ 'browser/autofill/autofill_dialog_win.cc',
'browser/autofill/autofill_dialog.h',
'browser/autofill/autofill_field.cc',
'browser/autofill/autofill_field.h',
@@ -96,6 +97,8 @@
'browser/autofill/autofill_manager.h',
'browser/autofill/autofill_profile.cc',
'browser/autofill/autofill_profile.h',
+ 'browser/autofill/autofill_profiles_view_win.cc',
+ 'browser/autofill/autofill_profiles_view_win.h',
'browser/autofill/autofill_type.cc',
'browser/autofill/autofill_type.h',
'browser/autofill/billing_address.h',