| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/language_order_table_model.h" | 5 #include "chrome/browser/language_order_table_model.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 | 9 |
| 10 LanguageOrderTableModel::LanguageOrderTableModel() | 10 LanguageOrderTableModel::LanguageOrderTableModel() |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 std::wstring LanguageOrderTableModel::GetText(int row, int column_id) { | 27 std::wstring LanguageOrderTableModel::GetText(int row, int column_id) { |
| 28 DCHECK(row >= 0 && row < RowCount()); | 28 DCHECK(row >= 0 && row < RowCount()); |
| 29 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 29 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
| 30 return UTF16ToWide(l10n_util::GetDisplayNameForLocale(languages_.at(row), | 30 return UTF16ToWide(l10n_util::GetDisplayNameForLocale(languages_.at(row), |
| 31 app_locale, | 31 app_locale, |
| 32 true)); | 32 true)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void LanguageOrderTableModel::Add(const std::string& language) { | 35 bool LanguageOrderTableModel::Add(const std::string& language) { |
| 36 if (language.empty()) | 36 if (language.empty()) |
| 37 return; | 37 return false; |
| 38 // Check for selecting duplicated language. | 38 // Check for selecting duplicated language. |
| 39 for (std::vector<std::string>::const_iterator cit = languages_.begin(); | 39 for (std::vector<std::string>::const_iterator cit = languages_.begin(); |
| 40 cit != languages_.end(); ++cit) | 40 cit != languages_.end(); ++cit) |
| 41 if (*cit == language) | 41 if (*cit == language) |
| 42 return; | 42 return false; |
| 43 languages_.push_back(language); | 43 languages_.push_back(language); |
| 44 if (observer_) | 44 if (observer_) |
| 45 observer_->OnItemsAdded(RowCount() - 1, 1); | 45 observer_->OnItemsAdded(RowCount() - 1, 1); |
| 46 return true; |
| 46 } | 47 } |
| 47 | 48 |
| 48 void LanguageOrderTableModel::Remove(int index) { | 49 void LanguageOrderTableModel::Remove(int index) { |
| 49 DCHECK(index >= 0 && index < RowCount()); | 50 DCHECK(index >= 0 && index < RowCount()); |
| 50 languages_.erase(languages_.begin() + index); | 51 languages_.erase(languages_.begin() + index); |
| 51 if (observer_) | 52 if (observer_) |
| 52 observer_->OnItemsRemoved(index, 1); | 53 observer_->OnItemsRemoved(index, 1); |
| 53 } | 54 } |
| 54 | 55 |
| 55 int LanguageOrderTableModel::GetIndex(const std::string& language) { | 56 int LanguageOrderTableModel::GetIndex(const std::string& language) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 std::string LanguageOrderTableModel::VectorToList( | 104 std::string LanguageOrderTableModel::VectorToList( |
| 104 const std::vector<std::string>& vector) { | 105 const std::vector<std::string>& vector) { |
| 105 std::string list; | 106 std::string list; |
| 106 for (int i = 0 ; i < static_cast<int>(vector.size()) ; i++) { | 107 for (int i = 0 ; i < static_cast<int>(vector.size()) ; i++) { |
| 107 list += vector.at(i); | 108 list += vector.at(i); |
| 108 if (i != static_cast<int>(vector.size()) - 1) | 109 if (i != static_cast<int>(vector.size()) - 1) |
| 109 list += ','; | 110 list += ','; |
| 110 } | 111 } |
| 111 return list; | 112 return list; |
| 112 } | 113 } |
| OLD | NEW |