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

Side by Side Diff: chrome/browser/ui/autofill/country_combobox_model.h

Issue 124533003: Add country combobox to change country and rebuild address inputs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ 6 #define CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
7 7
8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/observer_list.h"
12 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
13 #include "ui/base/models/combobox_model.h" 15 #include "ui/base/models/combobox_model.h"
14 16
15 namespace autofill { 17 namespace autofill {
16 18
17 class AutofillCountry; 19 class AutofillCountry;
20 class CountryComboboxModel;
18 class PersonalDataManager; 21 class PersonalDataManager;
19 22
23 class CountryComboboxModelObserver {
Evan Stade 2014/01/14 17:19:38 why are you inventing another observer instead of
Dan Beam 2014/01/15 03:10:48 Done. (after dropping need for selected stuff)
24 public:
25 virtual void OnCountryComboboxModelChanged(CountryComboboxModel* model) = 0;
26 };
27
20 // A model for countries to be used to enter addresses. 28 // A model for countries to be used to enter addresses.
21 class CountryComboboxModel : public ui::ComboboxModel { 29 class CountryComboboxModel : public ui::ComboboxModel {
22 public: 30 public:
23 explicit CountryComboboxModel(const PersonalDataManager& manager); 31 explicit CountryComboboxModel(const PersonalDataManager& manager);
24 virtual ~CountryComboboxModel(); 32 virtual ~CountryComboboxModel();
25 33
26 // ui::Combobox implementation: 34 // ui::ComboboxModel implementation:
27 virtual int GetItemCount() const OVERRIDE; 35 virtual int GetItemCount() const OVERRIDE;
28 virtual base::string16 GetItemAt(int index) OVERRIDE; 36 virtual base::string16 GetItemAt(int index) OVERRIDE;
29 virtual bool IsItemSeparatorAt(int index) OVERRIDE; 37 virtual bool IsItemSeparatorAt(int index) OVERRIDE;
30 38
31 const std::vector<AutofillCountry*>& countries() const { 39 const std::vector<AutofillCountry*>& countries() const {
32 return countries_.get(); 40 return countries_.get();
33 } 41 }
34 42
43 // Changes |selected_index_| to the default index of this model.
44 void SelectDefaultIndex();
45
46 // Changes |selected_index_| to the index of |country_code|. Returns whether
47 // the selected index changed.
48 void SelectCountry(const std::string& country_code);
49
50 // Returns the currently selected country code for this model.
51 std::string GetSelectedCountryCode() const;
52
53 // Whether the default index is currently selected.
54 bool IsDefaultIndexSelected() const;
55
56 void AddCountryComboboxObserver(CountryComboboxModelObserver* observer);
57 void RemoveCountryComboboxObserver(CountryComboboxModelObserver* observer);
58
35 private: 59 private:
60 // Changes |selected_index_| to index after checking it's sane.
61 void SelectIndex(int index);
62
36 // The countries to show in the model, including NULL for entries that are 63 // The countries to show in the model, including NULL for entries that are
37 // not countries (the separator entry). 64 // not countries (the separator entry).
38 ScopedVector<AutofillCountry> countries_; 65 ScopedVector<AutofillCountry> countries_;
39 66
67 // The index of the currently selected country.
68 int selected_index_;
Evan Stade 2014/01/14 17:19:38 combobox models aren't supposed to know the select
Dan Beam 2014/01/15 03:10:48 Done.
69
70 ObserverList<CountryComboboxModelObserver> observers_;
71
40 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel); 72 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel);
41 }; 73 };
42 74
43 } // namespace autofill 75 } // namespace autofill
44 76
45 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ 77 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698