summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 02:29:59 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 02:29:59 +0000
commit12a94ea157a6326c835f6dc9bca3a2332b911606 (patch)
treea45ae2fdda79653d06efed6bcc18cfe784611f05
parentba683f9e34fbe517955f88ed12fd632d2c270704 (diff)
downloadchromium_src-12a94ea157a6326c835f6dc9bca3a2332b911606.zip
chromium_src-12a94ea157a6326c835f6dc9bca3a2332b911606.tar.gz
chromium_src-12a94ea157a6326c835f6dc9bca3a2332b911606.tar.bz2
Use JoinString from string_util.h instead of a custom function.
BUG=None TEST=build and ran it. Review URL: http://codereview.chromium.org/3845004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63008 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/language_order_table_model.cc22
-rw-r--r--chrome/browser/language_order_table_model.h9
2 files changed, 6 insertions, 25 deletions
diff --git a/chrome/browser/language_order_table_model.cc b/chrome/browser/language_order_table_model.cc
index a57a1d7..0f3680b 100644
--- a/chrome/browser/language_order_table_model.cc
+++ b/chrome/browser/language_order_table_model.cc
@@ -19,7 +19,7 @@ LanguageOrderTableModel::LanguageOrderTableModel()
void LanguageOrderTableModel::SetAcceptLanguagesString(
const std::string& language_list) {
std::vector<std::string> languages_vector;
- ListToVector(language_list, &languages_vector);
+ base::SplitString(language_list, ',', &languages_vector);
languages_.clear();
std::set<std::string> added;
for (int i = 0; i < static_cast<int>(languages_vector.size()); i++) {
@@ -105,22 +105,10 @@ void LanguageOrderTableModel::MoveUp(int index) {
observer_->OnItemsChanged(0, RowCount());
}
-int LanguageOrderTableModel::RowCount() {
- return static_cast<int>(languages_.size());
-}
-
-void LanguageOrderTableModel::ListToVector(const std::string& list,
- std::vector<std::string>* vector) {
- base::SplitString(list, ',', vector);
+std::string LanguageOrderTableModel::GetLanguageList() {
+ return JoinString(languages_, ',');
}
-std::string LanguageOrderTableModel::VectorToList(
- const std::vector<std::string>& vector) {
- std::string list;
- for (int i = 0 ; i < static_cast<int>(vector.size()) ; i++) {
- list += vector.at(i);
- if (i != static_cast<int>(vector.size()) - 1)
- list += ',';
- }
- return list;
+int LanguageOrderTableModel::RowCount() {
+ return static_cast<int>(languages_.size());
}
diff --git a/chrome/browser/language_order_table_model.h b/chrome/browser/language_order_table_model.h
index 1f27781..4b11748 100644
--- a/chrome/browser/language_order_table_model.h
+++ b/chrome/browser/language_order_table_model.h
@@ -38,7 +38,7 @@ class LanguageOrderTableModel : public TableModel {
void MoveUp(int index);
// Returns the set of languagess this model contains.
- std::string GetLanguageList() { return VectorToList(languages_); }
+ std::string GetLanguageList();
// TableModel overrides:
virtual int RowCount();
@@ -46,13 +46,6 @@ class LanguageOrderTableModel : public TableModel {
virtual void SetObserver(TableModelObserver* observer);
private:
- // This method converts a comma separated list to a vector of strings.
- void ListToVector(const std::string& list,
- std::vector<std::string>* vector);
-
- // This method returns a comma separated string given a string vector.
- std::string VectorToList(const std::vector<std::string>& vector);
-
// Set of entries we're showing.
std::vector<std::string> languages_;
std::string comma_separated_language_list_;