diff options
author | skrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-07 20:17:53 +0000 |
---|---|---|
committer | skrul@chromium.org <skrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-07 20:17:53 +0000 |
commit | ef3c3d3b1818ec9c05ec8de5c448d3936da07987 (patch) | |
tree | c8c37d6f29561413866217a460b07cfd33d90969 /chrome/browser/language_order_table_model.cc | |
parent | 7ae1222a9905534ca2d16f70623f3ebde14df2e8 (diff) | |
download | chromium_src-ef3c3d3b1818ec9c05ec8de5c448d3936da07987.zip chromium_src-ef3c3d3b1818ec9c05ec8de5c448d3936da07987.tar.gz chromium_src-ef3c3d3b1818ec9c05ec8de5c448d3936da07987.tar.bz2 |
Enable live update of language list
The old way this was written was trying to re-use the Add() method to "merge" the new langauge string with the existing list. But in the case when a syncd browser sends a re-ordering or delete change, this would not detect the change and never fire the observer. I changed this to simply make SetAcceptLanguagesString replace the current langages_ list.
BUG=40486
TEST=Language lists should stay in sync between two browsers.
Review URL: http://codereview.chromium.org/1566024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/language_order_table_model.cc')
-rw-r--r-- | chrome/browser/language_order_table_model.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/chrome/browser/language_order_table_model.cc b/chrome/browser/language_order_table_model.cc index e9c5aac..2655378 100644 --- a/chrome/browser/language_order_table_model.cc +++ b/chrome/browser/language_order_table_model.cc @@ -4,6 +4,8 @@ #include "chrome/browser/language_order_table_model.h" +#include <set> + #include "app/l10n_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" @@ -16,9 +18,17 @@ void LanguageOrderTableModel::SetAcceptLanguagesString( const std::string& language_list) { std::vector<std::string> languages_vector; ListToVector(language_list, &languages_vector); + languages_.clear(); + std::set<std::string> added; for (int i = 0; i < static_cast<int>(languages_vector.size()); i++) { - Add(languages_vector.at(i)); + const std::string& language(languages_vector.at(i)); + if (!language.empty() && added.count(language) == 0) { + languages_.push_back(language); + added.insert(language); + } } + if (observer_) + observer_->OnModelChanged(); } void LanguageOrderTableModel::SetObserver(TableModelObserver* observer) { |