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> |
11 | 11 |
12 #include "app/combobox_model.h" | 12 #include "app/combobox_model.h" |
13 #include "app/table_model.h" | 13 #include "app/table_model.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "chrome/browser/autofill/autofill_dialog.h" | 15 #include "chrome/browser/autofill/autofill_dialog.h" |
16 #include "chrome/browser/autofill/autofill_profile.h" | 16 #include "chrome/browser/autofill/autofill_profile.h" |
17 #include "chrome/browser/autofill/personal_data_manager.h" | 17 #include "chrome/browser/autofill/personal_data_manager.h" |
| 18 #include "chrome/browser/pref_member.h" |
| 19 #include "chrome/common/notification_observer.h" |
18 #include "views/controls/combobox/combobox.h" | 20 #include "views/controls/combobox/combobox.h" |
19 #include "views/controls/link.h" | 21 #include "views/controls/link.h" |
20 #include "views/controls/table/table_view_observer.h" | 22 #include "views/controls/table/table_view_observer.h" |
21 #include "views/controls/textfield/textfield.h" | 23 #include "views/controls/textfield/textfield.h" |
22 #include "views/focus/focus_manager.h" | 24 #include "views/focus/focus_manager.h" |
23 #include "views/view.h" | 25 #include "views/view.h" |
24 #include "views/window/dialog_delegate.h" | 26 #include "views/window/dialog_delegate.h" |
25 | 27 |
26 namespace views { | 28 namespace views { |
27 class Checkbox; | 29 class Checkbox; |
(...skipping 21 matching lines...) Expand all Loading... |
49 // ScrollViewContents. | 51 // ScrollViewContents. |
50 // And there is a support data structure EditableSetInfo which encapsulates | 52 // And there is a support data structure EditableSetInfo which encapsulates |
51 // editable set (address or credit card) and allows for quick addition and | 53 // editable set (address or credit card) and allows for quick addition and |
52 // deletion. | 54 // deletion. |
53 class AutoFillProfilesView : public views::View, | 55 class AutoFillProfilesView : public views::View, |
54 public views::DialogDelegate, | 56 public views::DialogDelegate, |
55 public views::ButtonListener, | 57 public views::ButtonListener, |
56 public views::LinkController, | 58 public views::LinkController, |
57 public views::FocusChangeListener, | 59 public views::FocusChangeListener, |
58 public views::TableViewObserver, | 60 public views::TableViewObserver, |
59 public PersonalDataManager::Observer { | 61 public PersonalDataManager::Observer, |
| 62 public NotificationObserver { |
60 public: | 63 public: |
61 virtual ~AutoFillProfilesView(); | 64 virtual ~AutoFillProfilesView(); |
62 | 65 |
63 static int Show(gfx::NativeWindow parent, | 66 static int Show(gfx::NativeWindow parent, |
64 AutoFillDialogObserver* observer, | 67 AutoFillDialogObserver* observer, |
65 PersonalDataManager* personal_data_manager, | 68 PersonalDataManager* personal_data_manager, |
66 Profile* profile, | 69 Profile* profile, |
67 PrefService* preferences, | 70 PrefService* preferences, |
68 AutoFillProfile* imported_profile, | 71 AutoFillProfile* imported_profile, |
69 CreditCard* imported_credit_card); | 72 CreditCard* imported_credit_card); |
70 | 73 |
71 protected: | 74 protected: |
72 // Forward declaration. This struct defined further down. | 75 // Forward declaration. This struct defined further down. |
73 struct EditableSetInfo; | 76 struct EditableSetInfo; |
74 // Called when 'Add Address' (|group_type| is | 77 // Called when 'Add Address' (|group_type| is |
75 // ContentListTableModel::kAddressGroup) or 'Add Credit Card' (|group_type| is | 78 // ContentListTableModel::kAddressGroup) or 'Add Credit Card' (|group_type| is |
76 // ContentListTableModel::kCreditCardGroup) is clicked. | 79 // ContentListTableModel::kCreditCardGroup) is clicked. |
77 void AddClicked(int group_type); | 80 void AddClicked(int group_type); |
78 // Called when 'Edit...' is clicked. | 81 // Called when 'Edit...' is clicked. |
79 void EditClicked(); | 82 void EditClicked(); |
80 // Called when 'Remove' is clicked. | 83 // Called when 'Remove' is clicked. |
81 void DeleteClicked(); | 84 void DeleteClicked(); |
82 | 85 |
83 // Updates state of the buttons. | 86 // Updates state of the buttons. |
84 void UpdateButtonState(); | 87 void UpdateWidgetState(); |
85 | 88 |
86 // Updates inferred labels. | 89 // Updates inferred labels. |
87 void UpdateProfileLabels(); | 90 void UpdateProfileLabels(); |
88 | 91 |
89 // Updates the billing model. This is invoked any time the profile_set_ | 92 // Updates the billing model. This is invoked any time the profile_set_ |
90 // changes. | 93 // changes. |
91 void UpdateBillingModel(); | 94 void UpdateBillingModel(); |
92 | 95 |
93 // Following two functions are called from opened child dialog to | 96 // Following two functions are called from opened child dialog to |
94 // disable/enable buttons. | 97 // disable/enable buttons. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 virtual void FocusWillChange(views::View* focused_before, | 137 virtual void FocusWillChange(views::View* focused_before, |
135 views::View* focused_now); | 138 views::View* focused_now); |
136 | 139 |
137 // views::TableViewObserver methods: | 140 // views::TableViewObserver methods: |
138 virtual void OnSelectionChanged(); | 141 virtual void OnSelectionChanged(); |
139 virtual void OnDoubleClick(); | 142 virtual void OnDoubleClick(); |
140 | 143 |
141 // PersonalDataManager::Observer methods: | 144 // PersonalDataManager::Observer methods: |
142 virtual void OnPersonalDataLoaded(); | 145 virtual void OnPersonalDataLoaded(); |
143 | 146 |
| 147 // NotificationObserver methods: |
| 148 virtual void Observe(NotificationType type, |
| 149 const NotificationSource& source, |
| 150 const NotificationDetails& details); |
| 151 |
144 // Helper structure to keep info on one address or credit card. | 152 // Helper structure to keep info on one address or credit card. |
145 // Keeps info on one item in EditableSetViewContents. | 153 // Keeps info on one item in EditableSetViewContents. |
146 // Also keeps info on opened status. Allows to quickly add and delete items, | 154 // Also keeps info on opened status. Allows to quickly add and delete items, |
147 // and then rebuild EditableSetViewContents. | 155 // and then rebuild EditableSetViewContents. |
148 struct EditableSetInfo { | 156 struct EditableSetInfo { |
149 bool is_address; | 157 bool is_address; |
150 bool has_credit_card_number_been_edited; | 158 bool has_credit_card_number_been_edited; |
151 // If |is_address| is true |address| has some data and |credit_card| | 159 // If |is_address| is true |address| has some data and |credit_card| |
152 // is empty, and vice versa | 160 // is empty, and vice versa |
153 AutoFillProfile address; | 161 AutoFillProfile address; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 454 |
447 AutoFillDialogObserver* observer_; | 455 AutoFillDialogObserver* observer_; |
448 PersonalDataManager* personal_data_manager_; | 456 PersonalDataManager* personal_data_manager_; |
449 Profile* profile_; | 457 Profile* profile_; |
450 PrefService* preferences_; | 458 PrefService* preferences_; |
451 std::vector<EditableSetInfo> profiles_set_; | 459 std::vector<EditableSetInfo> profiles_set_; |
452 std::vector<EditableSetInfo> credit_card_set_; | 460 std::vector<EditableSetInfo> credit_card_set_; |
453 | 461 |
454 AddressComboBoxModel billing_model_; | 462 AddressComboBoxModel billing_model_; |
455 | 463 |
| 464 BooleanPrefMember enable_auto_fill_; |
| 465 |
456 views::Checkbox* enable_auto_fill_button_; | 466 views::Checkbox* enable_auto_fill_button_; |
457 views::Button* add_address_button_; | 467 views::Button* add_address_button_; |
458 views::Button* add_credit_card_button_; | 468 views::Button* add_credit_card_button_; |
459 views::Button* edit_button_; | 469 views::Button* edit_button_; |
460 views::Button* remove_button_; | 470 views::Button* remove_button_; |
461 views::TableView* scroll_view_; | 471 views::TableView* scroll_view_; |
462 scoped_ptr<ContentListTableModel> table_model_; | 472 scoped_ptr<ContentListTableModel> table_model_; |
463 views::FocusManager* focus_manager_; | 473 views::FocusManager* focus_manager_; |
464 bool child_dialog_opened_; | 474 bool child_dialog_opened_; |
465 | 475 |
466 static AutoFillProfilesView* instance_; | 476 static AutoFillProfilesView* instance_; |
467 | 477 |
468 DISALLOW_COPY_AND_ASSIGN(AutoFillProfilesView); | 478 DISALLOW_COPY_AND_ASSIGN(AutoFillProfilesView); |
469 }; | 479 }; |
470 | 480 |
471 #endif // CHROME_BROWSER_VIEWS_AUTOFILL_PROFILES_VIEW_WIN_H_ | 481 #endif // CHROME_BROWSER_VIEWS_AUTOFILL_PROFILES_VIEW_WIN_H_ |
OLD | NEW |