OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/autofill/autofill_dialog_comboboxes.h" |
| 6 |
| 7 #include "base/string_number_conversions.h" |
| 8 #include "base/stringprintf.h" |
| 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" |
| 11 |
| 12 namespace autofill { |
| 13 |
| 14 // SuggestionsComboboxModel ---------------------------------------------------- |
| 15 |
| 16 SuggestionsComboboxModel::SuggestionsComboboxModel() {} |
| 17 |
| 18 SuggestionsComboboxModel::~SuggestionsComboboxModel() {} |
| 19 |
| 20 void SuggestionsComboboxModel::AddItem( |
| 21 const std::string& key, const string16& item) { |
| 22 items_.push_back(std::make_pair(key, item)); |
| 23 } |
| 24 |
| 25 std::string SuggestionsComboboxModel::GetItemKeyAt(int index) const { |
| 26 return items_[index].first; |
| 27 } |
| 28 |
| 29 int SuggestionsComboboxModel::GetItemCount() const { |
| 30 return items_.size(); |
| 31 } |
| 32 |
| 33 string16 SuggestionsComboboxModel::GetItemAt(int index) { |
| 34 return items_[index].second; |
| 35 } |
| 36 |
| 37 // MonthComboboxModel ---------------------------------------------------------- |
| 38 |
| 39 MonthComboboxModel::MonthComboboxModel() {} |
| 40 |
| 41 MonthComboboxModel::~MonthComboboxModel() {} |
| 42 |
| 43 int MonthComboboxModel::GetItemCount() const { |
| 44 return 12; |
| 45 } |
| 46 |
| 47 string16 MonthComboboxModel::GetItemAt(int index) { |
| 48 return ASCIIToUTF16(StringPrintf("%2d", index + 1)); |
| 49 } |
| 50 |
| 51 // YearComboboxModel ----------------------------------------------------------- |
| 52 |
| 53 YearComboboxModel::YearComboboxModel() : this_year_(0) { |
| 54 base::Time time = base::Time::Now(); |
| 55 base::Time::Exploded exploded; |
| 56 time.LocalExplode(&exploded); |
| 57 this_year_ = exploded.year; |
| 58 } |
| 59 |
| 60 YearComboboxModel::~YearComboboxModel() {} |
| 61 |
| 62 int YearComboboxModel::GetItemCount() const { |
| 63 return 10; |
| 64 } |
| 65 |
| 66 string16 YearComboboxModel::GetItemAt(int index) { |
| 67 return base::IntToString16(this_year_ + index); |
| 68 } |
| 69 |
| 70 } // autofill |
OLD | NEW |