Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: chrome/browser/language_order_table_model.cc

Issue 174043: Gtk languages options page part 1: accept-languages configuration. (Closed)
Patch Set: rebase Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/language_order_table_model.h ('k') | chrome/browser/views/options/languages_page_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698