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

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: . 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"
12 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
13 #include "ui/base/models/combobox_model.h" 14 #include "ui/base/models/combobox_model.h"
14 15
15 namespace autofill { 16 namespace autofill {
16 17
17 class AutofillCountry; 18 class AutofillCountry;
18 class PersonalDataManager; 19 class PersonalDataManager;
19 20
20 // A model for countries to be used to enter addresses. 21 // A model for countries to be used to enter addresses.
21 class CountryComboboxModel : public ui::ComboboxModel { 22 class CountryComboboxModel : public ui::ComboboxModel {
22 public: 23 public:
23 explicit CountryComboboxModel(const PersonalDataManager& manager); 24 explicit CountryComboboxModel(const PersonalDataManager& manager);
24 virtual ~CountryComboboxModel(); 25 virtual ~CountryComboboxModel();
25 26
26 // ui::Combobox implementation: 27 // ui::Combobox implementation:
27 virtual int GetItemCount() const OVERRIDE; 28 virtual int GetItemCount() const OVERRIDE;
28 virtual base::string16 GetItemAt(int index) OVERRIDE; 29 virtual base::string16 GetItemAt(int index) OVERRIDE;
29 virtual bool IsItemSeparatorAt(int index) OVERRIDE; 30 virtual bool IsItemSeparatorAt(int index) OVERRIDE;
30 31
31 const std::vector<AutofillCountry*>& countries() const { 32 const std::vector<AutofillCountry*>& countries() const {
32 return countries_.get(); 33 return countries_.get();
33 } 34 }
34 35
36 // Changes |selected_index_| to |index| after checking that it's sane.
37 void SelectIndex(int index);
38
39 // Changes |selected_index_| to the default index of this model.
40 void SelectDefaultIndex();
41
42 // Changes |selected_index_| to the index of |country_code|.
43 void SelectCountry(const std::string& country_code);
44
45 // Returns the currently selected country code for this model.
46 std::string GetSelectedCountryCode() const;
47
48 // Whether the default index is currently selected.
49 bool IsDefaultIndexSelected() const;
50
35 private: 51 private:
36 // The countries to show in the model, including NULL for entries that are 52 // The countries to show in the model, including NULL for entries that are
37 // not countries (the separator entry). 53 // not countries (the separator entry).
38 ScopedVector<AutofillCountry> countries_; 54 ScopedVector<AutofillCountry> countries_;
39 55
56 // The index of the currently selected country.
57 int selected_index_;
58
40 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel); 59 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel);
41 }; 60 };
42 61
43 } // namespace autofill 62 } // namespace autofill
44 63
45 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ 64 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698