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

Unified Diff: chrome/browser/views/options/languages_page_view.cc

Issue 40145: [chromium-reviews] Fix the bug: Scrolling the Spell-checker drop-down box adds add the languages... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/options/languages_page_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/options/languages_page_view.cc
===================================================================
--- chrome/browser/views/options/languages_page_view.cc (revision 10810)
+++ chrome/browser/views/options/languages_page_view.cc (working copy)
@@ -323,6 +323,10 @@
// Removes the entry at the specified index.
void Remove(int index);
+ // Returns index corresponding to a given language. Returns -1 if the
+ // language is not found.
+ int GetIndex(const std::wstring& language);
+
// Move down the entry at the specified index.
void MoveDown(int index);
@@ -398,6 +402,22 @@
observer_->OnItemsRemoved(index, 1);
}
+int LanguageOrderTableModel::GetIndex(const std::wstring& language) {
+ if (language.empty())
+ return -1;
+
+ int index = 0;
+ for (std::vector<std::wstring>::const_iterator cit = languages_.begin();
+ cit != languages_.end(); ++cit) {
+ if (*cit == language)
+ return index;
+
+ index++;
+ }
+
+ return -1;
+}
+
void LanguageOrderTableModel::MoveDown(int index) {
if (index < 0 || index >= RowCount() - 1)
return;
@@ -730,9 +750,30 @@
language_warning_shown_ = true;
}
} else if (sender == change_dictionary_language_combobox_) {
+ // Set the spellcheck language selected.
spellcheck_language_index_selected_ = new_index;
- OnAddLanguage(dictionary_language_model_->GetLocaleFromIndex(new_index));
- language_table_edited_ = true;
+
+ // Remove the previously added spell check language to the accept list.
+ if (!spellcheck_language_added_.empty()) {
+ int old_index = language_order_table_model_->GetIndex(
+ spellcheck_language_added_);
+ if (old_index > -1)
+ language_order_table_model_->Remove(old_index);
+ }
+
+ // Add this new spell check language only if it is not already in the
+ // accept language list.
+ std::wstring language =
+ dictionary_language_model_->GetLocaleFromIndex(new_index);
+ int index = language_order_table_model_->GetIndex(language);
+ if (index == -1) {
+ // Add the new language.
+ OnAddLanguage(language);
+ language_table_edited_ = true;
+ spellcheck_language_added_ = language;
+ } else {
+ spellcheck_language_added_ = L"";
+ }
}
}
« no previous file with comments | « chrome/browser/views/options/languages_page_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698