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( |
| 34 int index) { |
| 35 return items_[index].second; |
| 36 } |
| 37 |
| 38 // MonthComboboxModel ---------------------------------------------------------- |
| 39 |
| 40 MonthComboboxModel::MonthComboboxModel() {} |
| 41 |
| 42 MonthComboboxModel::~MonthComboboxModel() {} |
| 43 |
| 44 int MonthComboboxModel::GetItemCount() const OVERRIDE { |
| 45 return 12; |
| 46 } |
| 47 |
| 48 string16 MonthComboboxModel::GetItemAt(int index) OVERRIDE { |
| 49 return ASCIIToUTF16(StringPrintf("%2d", index + 1)); |
| 50 } |
| 51 |
| 52 // YearComboboxModel ----------------------------------------------------------- |
| 53 |
| 54 YearComboboxModel::YearComboboxModel() : this_year_(0) { |
| 55 base::Time time = base::Time::Now(); |
| 56 base::Time::Exploded exploded; |
| 57 time.LocalExplode(&exploded); |
| 58 this_year_ = exploded.year; |
| 59 } |
| 60 |
| 61 YearComboboxModel::~YearComboboxModel() {} |
| 62 |
| 63 int YearComboboxModel::GetItemCount() const { |
| 64 return 10; |
| 65 } |
| 66 |
| 67 string16 YearComboboxModel::GetItemAt(int index) OVERRIDE { |
| 68 return base::IntToString16(this_year_ + index); |
| 69 } |
| 70 |
| 71 } // autofill |
OLD | NEW |