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

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

Issue 63053003: Ask libaddressinput for address components to use in requestAutocomplete(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: base:: 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
17 namespace ui {
18 class ComboboxModelObserver;
19 }
20
15 namespace autofill { 21 namespace autofill {
16 22
17 class AutofillCountry; 23 class AutofillCountry;
18 class PersonalDataManager;
19 24
20 // A model for countries to be used to enter addresses. 25 // A model for countries to be used to enter addresses.
21 class CountryComboboxModel : public ui::ComboboxModel { 26 class CountryComboboxModel : public ui::ComboboxModel {
22 public: 27 public:
23 explicit CountryComboboxModel(const PersonalDataManager& manager); 28 explicit CountryComboboxModel(const std::string& default_country_code);
24 virtual ~CountryComboboxModel(); 29 virtual ~CountryComboboxModel();
25 30
26 // ui::Combobox implementation: 31 // ui::Combobox implementation:
27 virtual int GetItemCount() const OVERRIDE; 32 virtual int GetItemCount() const OVERRIDE;
28 virtual base::string16 GetItemAt(int index) OVERRIDE; 33 virtual base::string16 GetItemAt(int index) OVERRIDE;
29 virtual bool IsItemSeparatorAt(int index) OVERRIDE; 34 virtual bool IsItemSeparatorAt(int index) OVERRIDE;
35 virtual int GetDefaultIndex() const OVERRIDE;
36 virtual void AddObserver(ui::ComboboxModelObserver* observer) OVERRIDE;
37 virtual void RemoveObserver(ui::ComboboxModelObserver* observer) 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 the default index and default country (which is based on this).
44 void SetDefaultIndex(int default_index);
45
46 // Returns which country should be the default when the combobox is shown.
47 std::string GetDefaultCountryCode() const;
48
35 private: 49 private:
36 // The countries to show in the model, including NULL for entries that are 50 // The countries to show in the model, including NULL for entries that are
37 // not countries (the separator entry). 51 // not countries (the separator entry).
38 ScopedVector<AutofillCountry> countries_; 52 ScopedVector<AutofillCountry> countries_;
39 53
54 // The index of the item that should be shown by default.
55 int default_index_;
56
57 ObserverList<ui::ComboboxModelObserver> observers_;
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