Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_VIEWS_AUTOFILL_PROFILES_VIEW_WIN_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_AUTOFILL_PROFILES_VIEW_WIN_H_ |
| 6 #define CHROME_BROWSER_VIEWS_AUTOFILL_PROFILES_VIEW_WIN_H_ | 6 #define CHROME_BROWSER_VIEWS_AUTOFILL_PROFILES_VIEW_WIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "views/window/dialog_delegate.h" | 23 #include "views/window/dialog_delegate.h" |
| 24 | 24 |
| 25 namespace views { | 25 namespace views { |
| 26 class Checkbox; | 26 class Checkbox; |
| 27 class GridLayout; | 27 class GridLayout; |
| 28 class ImageButton; | 28 class ImageButton; |
| 29 class Label; | 29 class Label; |
| 30 class RadioButton; | 30 class RadioButton; |
| 31 class TableView; | 31 class TableView; |
| 32 class TextButton; | 32 class TextButton; |
| 33 } | 33 } // namespace views |
| 34 | 34 |
| 35 class PrefService; | 35 class PrefService; |
| 36 class SkBitmap; | 36 class SkBitmap; |
| 37 | 37 |
| 38 /////////////////////////////////////////////////////////////////////////////// | 38 /////////////////////////////////////////////////////////////////////////////// |
| 39 // AutoFillProfilesView | 39 // AutoFillProfilesView |
| 40 // | 40 // |
| 41 // The contents of the "AutoFill profiles" dialog window. | 41 // The contents of the "AutoFill profiles" dialog window. |
| 42 // | 42 // |
| 43 // Overview: has following sub-views: | 43 // Overview: has following sub-views: |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 61 | 61 |
| 62 static int Show(gfx::NativeWindow parent, | 62 static int Show(gfx::NativeWindow parent, |
| 63 AutoFillDialogObserver* observer, | 63 AutoFillDialogObserver* observer, |
| 64 PersonalDataManager* personal_data_manager, | 64 PersonalDataManager* personal_data_manager, |
| 65 Profile* profile, | 65 Profile* profile, |
| 66 PrefService* preferences, | 66 PrefService* preferences, |
| 67 AutoFillProfile* imported_profile, | 67 AutoFillProfile* imported_profile, |
| 68 CreditCard* imported_credit_card); | 68 CreditCard* imported_credit_card); |
| 69 | 69 |
| 70 protected: | 70 protected: |
| 71 // forward declaration. This struct defined further down. | 71 // Forward declaration. This struct defined further down. |
| 72 struct EditableSetInfo; | 72 struct EditableSetInfo; |
| 73 // Called when 'Add Address' (|group_type| is | 73 // Called when 'Add Address' (|group_type| is |
| 74 // ContentListTableModel::kAddressGroup) or 'Add Credit Card' (|group_type| is | 74 // ContentListTableModel::kAddressGroup) or 'Add Credit Card' (|group_type| is |
| 75 // ContentListTableModel::kCreditCardGroup) is clicked. | 75 // ContentListTableModel::kCreditCardGroup) is clicked. |
| 76 void AddClicked(int group_type); | 76 void AddClicked(int group_type); |
| 77 // Called when 'Edit...' is clicked. | 77 // Called when 'Edit...' is clicked. |
| 78 void EditClicked(); | 78 void EditClicked(); |
| 79 // Called when 'Remove' is clicked. | 79 // Called when 'Remove' is clicked. |
| 80 void DeleteClicked(); | 80 void DeleteClicked(); |
| 81 | 81 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 void UpdateButtons(); | 219 void UpdateButtons(); |
| 220 AutoFillProfilesView* autofill_view_; | 220 AutoFillProfilesView* autofill_view_; |
| 221 views::Label* label_; | 221 views::Label* label_; |
| 222 views::Textfield* text_phone_; | 222 views::Textfield* text_phone_; |
| 223 views::ImageButton* phone_warning_button_; | 223 views::ImageButton* phone_warning_button_; |
| 224 bool last_state_; | 224 bool last_state_; |
| 225 | 225 |
| 226 DISALLOW_COPY_AND_ASSIGN(PhoneSubView); | 226 DISALLOW_COPY_AND_ASSIGN(PhoneSubView); |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 // forward declaration | 229 // Forward declaration. |
| 230 class AddressComboBoxModel; | 230 class AddressComboBoxModel; |
| 231 class StringVectorComboboxModel; | 231 class StringVectorComboboxModel; |
| 232 | 232 |
| 233 // Sub-view dealing with addresses. | 233 // Sub-view dealing with addresses. |
| 234 class EditableSetViewContents : public views::View, | 234 class EditableSetViewContents : public views::View, |
| 235 public views::DialogDelegate, | 235 public views::DialogDelegate, |
| 236 public views::ButtonListener, | 236 public views::ButtonListener, |
| 237 public views::Textfield::Controller, | 237 public views::Textfield::Controller, |
| 238 public views::Combobox::Listener { | 238 public views::Combobox::Listener { |
| 239 public: | 239 public: |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 251 views::View* child); | 251 views::View* child); |
| 252 | 252 |
| 253 // views::DialogDelegate methods: | 253 // views::DialogDelegate methods: |
| 254 virtual int GetDialogButtons() const; | 254 virtual int GetDialogButtons() const; |
| 255 virtual std::wstring GetDialogButtonLabel( | 255 virtual std::wstring GetDialogButtonLabel( |
| 256 MessageBoxFlags::DialogButton button) const; | 256 MessageBoxFlags::DialogButton button) const; |
| 257 virtual bool IsDialogButtonEnabled( | 257 virtual bool IsDialogButtonEnabled( |
| 258 MessageBoxFlags::DialogButton button) const; | 258 MessageBoxFlags::DialogButton button) const; |
| 259 virtual bool CanResize() const { return false; } | 259 virtual bool CanResize() const { return false; } |
| 260 virtual bool CanMaximize() const { return false; } | 260 virtual bool CanMaximize() const { return false; } |
| 261 virtual bool IsAlwaysOnTop() const { return false; } | 261 virtual bool IsModal() const { return true; } |
|
James Hawkins
2010/08/09 16:45:49
What is the impetus for this change?
| |
| 262 virtual bool HasAlwaysOnTopMenu() const { return false; } | 262 virtual bool HasAlwaysOnTopMenu() const { return false; } |
| 263 virtual std::wstring GetWindowTitle() const; | 263 virtual std::wstring GetWindowTitle() const; |
| 264 virtual void WindowClosing(); | 264 virtual void WindowClosing(); |
| 265 virtual views::View* GetContentsView(); | 265 virtual views::View* GetContentsView(); |
| 266 virtual bool Cancel(); | 266 virtual bool Cancel(); |
| 267 virtual bool Accept(); | 267 virtual bool Accept(); |
| 268 | 268 |
| 269 // views::ButtonListener methods: | 269 // views::ButtonListener methods: |
| 270 virtual void ButtonPressed(views::Button* sender, | 270 virtual void ButtonPressed(views::Button* sender, |
| 271 const views::Event& event); | 271 const views::Event& event); |
| 272 | 272 |
| 273 // views::Textfield::Controller methods: | 273 // views::Textfield::Controller methods: |
| 274 virtual void ContentsChanged(views::Textfield* sender, | 274 virtual void ContentsChanged(views::Textfield* sender, |
| 275 const string16& new_contents); | 275 const string16& new_contents); |
| 276 virtual bool HandleKeystroke(views::Textfield* sender, | 276 virtual bool HandleKeystroke(views::Textfield* sender, |
| 277 const views::Textfield::Keystroke& keystroke); | 277 const views::Textfield::Keystroke& keystroke); |
| 278 | 278 |
| 279 // views::Combobox::Listener methods: | 279 // views::Combobox::Listener methods: |
| 280 virtual void ItemChanged(views::Combobox* combo_box, | 280 virtual void ItemChanged(views::Combobox* combo_box, |
| 281 int prev_index, | 281 int prev_index, |
| 282 int new_index); | 282 int new_index); |
| 283 private: | 283 private: |
| 284 enum TextFields { | 284 enum TextFields { |
| 285 TEXT_FULL_NAME, | 285 TEXT_FULL_NAME, |
| 286 TEXT_COMPANY, | 286 TEXT_COMPANY, |
| 287 TEXT_EMAIL, | 287 TEXT_EMAIL, |
| 288 TEXT_ADDRESS_LINE_1, | 288 TEXT_ADDRESS_LINE_1, |
| 289 TEXT_ADDRESS_LINE_2, | 289 TEXT_ADDRESS_LINE_2, |
| 290 TEXT_ADDRESS_CITY, | 290 TEXT_ADDRESS_CITY, |
| 291 TEXT_ADDRESS_STATE, | 291 TEXT_ADDRESS_STATE, |
| 292 TEXT_ADDRESS_ZIP, | 292 TEXT_ADDRESS_ZIP, |
| 293 TEXT_ADDRESS_COUNTRY, | 293 TEXT_ADDRESS_COUNTRY, |
| 294 TEXT_PHONE_PHONE, | 294 TEXT_PHONE_PHONE, |
| 295 TEXT_FAX_PHONE, | 295 TEXT_FAX_PHONE, |
| 296 TEXT_CC_NAME, | 296 TEXT_CC_NAME, |
| 297 TEXT_CC_NUMBER, | 297 TEXT_CC_NUMBER, |
| 298 // must be last | 298 // Must be last. |
| 299 MAX_TEXT_FIELD | 299 MAX_TEXT_FIELD |
| 300 }; | 300 }; |
| 301 | 301 |
| 302 void InitAddressFields(views::GridLayout* layout); | 302 void InitAddressFields(views::GridLayout* layout); |
| 303 void InitCreditCardFields(views::GridLayout* layout); | 303 void InitCreditCardFields(views::GridLayout* layout); |
| 304 void InitLayoutGrid(views::GridLayout* layout); | 304 void InitLayoutGrid(views::GridLayout* layout); |
| 305 views::Label* CreateLeftAlignedLabel(int label_id); | 305 views::Label* CreateLeftAlignedLabel(int label_id); |
| 306 | 306 |
| 307 void UpdateButtons(); | 307 void UpdateButtons(); |
| 308 | 308 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 339 static const int triple_column_fill_view_set_id_ = 2; | 339 static const int triple_column_fill_view_set_id_ = 2; |
| 340 static const int triple_column_leading_view_set_id_ = 3; | 340 static const int triple_column_leading_view_set_id_ = 3; |
| 341 static const int four_column_city_state_zip_set_id_ = 4; | 341 static const int four_column_city_state_zip_set_id_ = 4; |
| 342 static const int double_column_ccnumber_cvc_ = 5; | 342 static const int double_column_ccnumber_cvc_ = 5; |
| 343 static const int three_column_header_ = 6; | 343 static const int three_column_header_ = 6; |
| 344 static const int double_column_ccexpiration_ = 7; | 344 static const int double_column_ccexpiration_ = 7; |
| 345 | 345 |
| 346 DISALLOW_COPY_AND_ASSIGN(EditableSetViewContents); | 346 DISALLOW_COPY_AND_ASSIGN(EditableSetViewContents); |
| 347 }; | 347 }; |
| 348 | 348 |
| 349 // Encapsulates ComboboxModel for address | 349 // Encapsulates ComboboxModel for address. |
| 350 class AddressComboBoxModel : public ComboboxModel { | 350 class AddressComboBoxModel : public ComboboxModel { |
| 351 public: | 351 public: |
| 352 explicit AddressComboBoxModel(bool is_billing); | 352 explicit AddressComboBoxModel(bool is_billing); |
| 353 virtual ~AddressComboBoxModel() {} | 353 virtual ~AddressComboBoxModel() {} |
| 354 | 354 |
| 355 // Should be called only once. No other function should be called before it. | 355 // Should be called only once. No other function should be called before it. |
| 356 // Does not own |address_labels|. To update the model text, | 356 // Does not own |address_labels|. To update the model text, |
| 357 // update label in one of the profiles and call LabelChanged() | 357 // update label in one of the profiles and call LabelChanged() |
| 358 void set_address_labels(const std::vector<EditableSetInfo>* address_labels); | 358 void set_address_labels(const std::vector<EditableSetInfo>* address_labels); |
| 359 | 359 |
| 360 // When you add a CB view that relies on this model, call this function | 360 // When you add a CB view that relies on this model, call this function |
| 361 // so the CB can be notified if strings change. Can be called multiple | 361 // so the CB can be notified if strings change. Can be called multiple |
| 362 // times if several combo boxes relying on the model. | 362 // times if several combo boxes relying on the model. |
| 363 // Model does not own |combo_box|. | 363 // Model does not own |combo_box|. |
| 364 void UsedWithComboBox(views::Combobox *combo_box); | 364 void UsedWithComboBox(views::Combobox *combo_box); |
| 365 | 365 |
| 366 // Need to be called when comboboxes are destroyed. | 366 // Need to be called when comboboxes are destroyed. |
| 367 void ClearComboBoxes() { combo_boxes_.clear(); } | 367 void ClearComboBoxes() { combo_boxes_.clear(); } |
| 368 | 368 |
| 369 // Call this function if one of the labels has changed | 369 // Call this function if one of the labels has changed |
| 370 void LabelChanged(); | 370 void LabelChanged(); |
| 371 | 371 |
| 372 // Gets index of the item in the model or -1 if not found. | 372 // Gets index of the item in the model or -1 if not found. |
| 373 int GetIndex(int unique_id); | 373 int GetIndex(int unique_id); |
| 374 | 374 |
| 375 // ComboboxModel methods, public as they used from EditableSetViewContents | 375 // Overridden from ComboboxModel: |
| 376 // Public as they are used from EditableSetViewContents. | |
| 376 virtual int GetItemCount(); | 377 virtual int GetItemCount(); |
| 377 virtual std::wstring GetItemAt(int index); | 378 virtual std::wstring GetItemAt(int index); |
| 378 | 379 |
| 379 private: | 380 private: |
| 380 std::list<views::Combobox *> combo_boxes_; | 381 std::list<views::Combobox *> combo_boxes_; |
| 381 std::vector<EditableSetInfo> address_labels_; | 382 std::vector<EditableSetInfo> address_labels_; |
| 382 bool is_billing_; | 383 bool is_billing_; |
| 383 | 384 |
| 384 DISALLOW_COPY_AND_ASSIGN(AddressComboBoxModel); | 385 DISALLOW_COPY_AND_ASSIGN(AddressComboBoxModel); |
| 385 }; | 386 }; |
| 386 | 387 |
| 387 class StringVectorComboboxModel : public ComboboxModel { | 388 class StringVectorComboboxModel : public ComboboxModel { |
| 388 public: | 389 public: |
| 389 StringVectorComboboxModel() {} | 390 StringVectorComboboxModel() {} |
| 390 virtual ~StringVectorComboboxModel() {} | 391 virtual ~StringVectorComboboxModel() {} |
| 391 | 392 |
| 392 // Sets the vector of the strings for the combobox. Swaps content with | 393 // Sets the vector of the strings for the combobox. Swaps content with |
| 393 // |source|. | 394 // |source|. |
| 394 void set_cb_strings(std::vector<std::wstring> *source); | 395 void set_cb_strings(std::vector<std::wstring> *source); |
| 395 | 396 |
| 396 // Return the number of items in the combo box. | 397 // Overridden from ComboboxModel: |
| 397 virtual int GetItemCount(); | 398 virtual int GetItemCount(); |
| 398 | |
| 399 // Return the string that should be used to represent a given item. | |
| 400 virtual std::wstring GetItemAt(int index); | 399 virtual std::wstring GetItemAt(int index); |
| 401 | 400 |
| 402 // Find an index of the item in the model, -1 if not present. | 401 // Find an index of the item in the model, -1 if not present. |
| 403 int GetIndex(const std::wstring& value); | 402 int GetIndex(const std::wstring& value); |
| 404 | 403 |
| 405 private: | 404 private: |
| 406 std::vector<std::wstring> cb_strings_; | 405 std::vector<std::wstring> cb_strings_; |
| 407 | 406 |
| 408 DISALLOW_COPY_AND_ASSIGN(StringVectorComboboxModel); | 407 DISALLOW_COPY_AND_ASSIGN(StringVectorComboboxModel); |
| 409 }; | 408 }; |
| 410 | 409 |
| 411 | 410 // Model for scrolling credit cards and addresses. |
| 412 // Model for scrolling credit cards and addresses | |
| 413 class ContentListTableModel : public TableModel { | 411 class ContentListTableModel : public TableModel { |
| 414 public: | 412 public: |
| 415 ContentListTableModel(std::vector<EditableSetInfo>* profiles, | 413 ContentListTableModel(std::vector<EditableSetInfo>* profiles, |
| 416 std::vector<EditableSetInfo>* credit_cards); | 414 std::vector<EditableSetInfo>* credit_cards); |
| 417 virtual ~ContentListTableModel() {} | 415 virtual ~ContentListTableModel() {} |
| 418 | 416 |
| 419 // Two constants defined for indexes of groups. The first one is index | 417 // Two constants defined for indexes of groups. The first one is index |
| 420 // of Add Address button, the second one is the index of Add Credit Card | 418 // of Add Address button, the second one is the index of Add Credit Card |
| 421 // button. | 419 // button. |
| 422 static const int kAddressGroup = 1; | 420 static const int kAddressGroup = 1; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 scoped_ptr<ContentListTableModel> table_model_; | 459 scoped_ptr<ContentListTableModel> table_model_; |
| 462 views::FocusManager* focus_manager_; | 460 views::FocusManager* focus_manager_; |
| 463 bool child_dialog_opened_; | 461 bool child_dialog_opened_; |
| 464 | 462 |
| 465 static AutoFillProfilesView* instance_; | 463 static AutoFillProfilesView* instance_; |
| 466 | 464 |
| 467 DISALLOW_COPY_AND_ASSIGN(AutoFillProfilesView); | 465 DISALLOW_COPY_AND_ASSIGN(AutoFillProfilesView); |
| 468 }; | 466 }; |
| 469 | 467 |
| 470 #endif // CHROME_BROWSER_VIEWS_AUTOFILL_PROFILES_VIEW_WIN_H_ | 468 #endif // CHROME_BROWSER_VIEWS_AUTOFILL_PROFILES_VIEW_WIN_H_ |
| 471 | |
| OLD | NEW |