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

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: comment 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;
18 class PersonalDataManager; 20 class PersonalDataManager;
19 21
20 // A model for countries to be used to enter addresses. 22 // A model for countries to be used to enter addresses.
21 class CountryComboboxModel : public ui::ComboboxModel { 23 class CountryComboboxModel : public ui::ComboboxModel {
22 public: 24 public:
23 explicit CountryComboboxModel(const PersonalDataManager& manager); 25 explicit CountryComboboxModel(const PersonalDataManager& manager);
24 virtual ~CountryComboboxModel(); 26 virtual ~CountryComboboxModel();
25 27
26 // ui::Combobox implementation: 28 // ui::ComboboxModel implementation:
27 virtual int GetItemCount() const OVERRIDE; 29 virtual int GetItemCount() const OVERRIDE;
28 virtual base::string16 GetItemAt(int index) OVERRIDE; 30 virtual base::string16 GetItemAt(int index) OVERRIDE;
29 virtual bool IsItemSeparatorAt(int index) OVERRIDE; 31 virtual bool IsItemSeparatorAt(int index) OVERRIDE;
32 virtual int GetDefaultIndex() const OVERRIDE;
33 virtual void AddObserver(ui::ComboboxModelObserver* observer) OVERRIDE;
34 virtual void RemoveObserver(ui::ComboboxModelObserver* observer) OVERRIDE;
30 35
31 const std::vector<AutofillCountry*>& countries() const { 36 const std::vector<AutofillCountry*>& countries() const {
32 return countries_.get(); 37 return countries_.get();
33 } 38 }
34 39
40 // Clears the default country.
41 void ResetDefault();
42
43 // Changes |country_code| to the default country.
44 void SetDefaultCountry(const std::string& country_code);
45
46 // Returns the default country code for this model.
47 std::string GetDefaultCountryCode() const;
48
35 private: 49 private:
50 // Changes |default_index_| to |index| after checking it's sane. Notifies
51 // observers if |default_index_| changed.
52 void SetDefaultIndex(int index);
53
36 // The countries to show in the model, including NULL for entries that are 54 // The countries to show in the model, including NULL for entries that are
37 // not countries (the separator entry). 55 // not countries (the separator entry).
38 ScopedVector<AutofillCountry> countries_; 56 ScopedVector<AutofillCountry> countries_;
39 57
58 // The index of the default country.
59 int default_index_;
60
61 ObserverList<ui::ComboboxModelObserver> observers_;
62
40 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel); 63 DISALLOW_COPY_AND_ASSIGN(CountryComboboxModel);
41 }; 64 };
42 65
43 } // namespace autofill 66 } // namespace autofill
44 67
45 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_ 68 #endif // CHROME_BROWSER_UI_AUTOFILL_COUNTRY_COMBOBOX_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_view_delegate.h ('k') | chrome/browser/ui/autofill/country_combobox_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698