OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/options/language_dictionary_overlay_handler.h" | 5 #include "chrome/browser/ui/webui/options/language_dictionary_overlay_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 10 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 if (!overlay_initialized_) | 84 if (!overlay_initialized_) |
85 return; | 85 return; |
86 | 86 |
87 if (!dictionary_) { | 87 if (!dictionary_) { |
88 dictionary_ = SpellcheckServiceFactory::GetForProfile( | 88 dictionary_ = SpellcheckServiceFactory::GetForProfile( |
89 Profile::FromWebUI(web_ui()))->GetCustomDictionary(); | 89 Profile::FromWebUI(web_ui()))->GetCustomDictionary(); |
90 dictionary_->AddObserver(this); | 90 dictionary_->AddObserver(this); |
91 } | 91 } |
92 | 92 |
93 ListValue list_value; | 93 ListValue list_value; |
94 list_value.AppendStrings(dictionary_->GetWords()); | 94 const chrome::spellcheck_common::WordSet& words = dictionary_->GetWords(); |
| 95 for (chrome::spellcheck_common::WordSet::const_iterator it = words.begin(); |
| 96 it != words.end(); ++it) { |
| 97 list_value.AppendString(*it); |
| 98 } |
95 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.setWordList", | 99 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.setWordList", |
96 list_value); | 100 list_value); |
97 } | 101 } |
98 | 102 |
99 void LanguageDictionaryOverlayHandler::RefreshWords(const ListValue* args) { | 103 void LanguageDictionaryOverlayHandler::RefreshWords(const ListValue* args) { |
100 overlay_initialized_ = true; | 104 overlay_initialized_ = true; |
101 ResetDictionaryWords(); | 105 ResetDictionaryWords(); |
102 } | 106 } |
103 | 107 |
104 void LanguageDictionaryOverlayHandler::AddWord(const ListValue* args) { | 108 void LanguageDictionaryOverlayHandler::AddWord(const ListValue* args) { |
105 std::string new_word; | 109 std::string new_word; |
106 if (!args->GetString(0, &new_word) || new_word.empty() || !dictionary_) { | 110 if (!args->GetString(0, &new_word) || new_word.empty() || !dictionary_) { |
107 NOTREACHED(); | 111 NOTREACHED(); |
108 return; | 112 return; |
109 } | 113 } |
110 dictionary_->AddWord(new_word); | 114 dictionary_->AddWord(new_word); |
111 } | 115 } |
112 | 116 |
113 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) { | 117 void LanguageDictionaryOverlayHandler::RemoveWord(const ListValue* args) { |
114 std::string old_word; | 118 std::string old_word; |
115 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { | 119 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { |
116 NOTREACHED(); | 120 NOTREACHED(); |
117 return; | 121 return; |
118 } | 122 } |
119 dictionary_->RemoveWord(old_word); | 123 dictionary_->RemoveWord(old_word); |
120 } | 124 } |
121 | 125 |
122 } // namespace options | 126 } // namespace options |
OLD | NEW |