Index: chrome/browser/ui/autofill/autofill_dialog_comboboxes.cc |
diff --git a/chrome/browser/ui/autofill/autofill_dialog_comboboxes.cc b/chrome/browser/ui/autofill/autofill_dialog_comboboxes.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3d7b73a046e87f1d91dbec47a20e87e835203db6 |
--- /dev/null |
+++ b/chrome/browser/ui/autofill/autofill_dialog_comboboxes.cc |
@@ -0,0 +1,71 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/autofill/autofill_dialog_comboboxes.h" |
+ |
+#include "base/string_number_conversions.h" |
+#include "base/stringprintf.h" |
+#include "base/time.h" |
+#include "base/utf_string_conversions.h" |
+ |
+namespace autofill { |
+ |
+// SuggestionsComboboxModel ---------------------------------------------------- |
+ |
+SuggestionsComboboxModel::SuggestionsComboboxModel() {} |
+ |
+SuggestionsComboboxModel::~SuggestionsComboboxModel() {} |
+ |
+void SuggestionsComboboxModel::AddItem( |
+ const std::string& key, const string16& item) { |
+ items_.push_back(std::make_pair(key, item)); |
+} |
+ |
+std::string SuggestionsComboboxModel::GetItemKeyAt(int index) const { |
+ return items_[index].first; |
+} |
+ |
+int SuggestionsComboboxModel::GetItemCount() const { |
+ return items_.size(); |
+} |
+ |
+string16 SuggestionsComboboxModel::GetItemAt( |
+ int index) { |
Ilya Sherman
2012/11/30 01:01:32
nit: Looks like this will fit on the previous line
Evan Stade
2012/11/30 22:55:25
Done.
|
+ return items_[index].second; |
+} |
+ |
+// MonthComboboxModel ---------------------------------------------------------- |
+ |
+MonthComboboxModel::MonthComboboxModel() {} |
+ |
+MonthComboboxModel::~MonthComboboxModel() {} |
+ |
+int MonthComboboxModel::GetItemCount() const { |
+ return 12; |
+} |
+ |
+string16 MonthComboboxModel::GetItemAt(int index) { |
+ return ASCIIToUTF16(StringPrintf("%2d", index + 1)); |
+} |
+ |
+// YearComboboxModel ----------------------------------------------------------- |
+ |
+YearComboboxModel::YearComboboxModel() : this_year_(0) { |
Ilya Sherman
2012/11/30 01:01:32
nit: No need to init this_year_ here since you ini
Evan Stade
2012/11/30 22:55:25
I think coverity still complains if you don't init
|
+ base::Time time = base::Time::Now(); |
+ base::Time::Exploded exploded; |
+ time.LocalExplode(&exploded); |
+ this_year_ = exploded.year; |
+} |
+ |
+YearComboboxModel::~YearComboboxModel() {} |
+ |
+int YearComboboxModel::GetItemCount() const { |
+ return 10; |
+} |
+ |
+string16 YearComboboxModel::GetItemAt(int index) { |
+ return base::IntToString16(this_year_ + index); |
+} |
+ |
+} // autofill |