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

Side by Side Diff: chrome/browser/ui/webui/options/language_dictionary_overlay_handler.cc

Issue 1995113002: Rename WebUI::CallJavascriptFunction to WebUI::CallJavascriptFunctionUnsafe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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) 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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 base::ListValue add_words; 77 base::ListValue add_words;
78 for (const std::string& word : dictionary_change.to_add()) { 78 for (const std::string& word : dictionary_change.to_add()) {
79 add_words.AppendString(word); 79 add_words.AppendString(word);
80 } 80 }
81 81
82 base::ListValue remove_words; 82 base::ListValue remove_words;
83 for (const std::string& word : dictionary_change.to_remove()) { 83 for (const std::string& word : dictionary_change.to_remove()) {
84 remove_words.AppendString(word); 84 remove_words.AppendString(word);
85 } 85 }
86 86
87 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.updateWords", 87 web_ui()->CallJavascriptFunctionUnsafe("EditDictionaryOverlay.updateWords",
88 add_words, remove_words); 88 add_words, remove_words);
89 } 89 }
90 90
91 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() { 91 void LanguageDictionaryOverlayHandler::ResetDictionaryWords() {
92 if (!overlay_initialized_) 92 if (!overlay_initialized_)
93 return; 93 return;
94 94
95 if (!dictionary_) { 95 if (!dictionary_) {
96 SpellcheckService* service = SpellcheckServiceFactory::GetForContext( 96 SpellcheckService* service = SpellcheckServiceFactory::GetForContext(
97 Profile::FromWebUI(web_ui())); 97 Profile::FromWebUI(web_ui()));
98 dictionary_ = service->GetCustomDictionary(); 98 dictionary_ = service->GetCustomDictionary();
99 dictionary_->AddObserver(this); 99 dictionary_->AddObserver(this);
100 } 100 }
101 101
102 base::ListValue list_value; 102 base::ListValue list_value;
103 for (const std::string& word : dictionary_->GetWords()) { 103 for (const std::string& word : dictionary_->GetWords()) {
104 list_value.AppendString(word); 104 list_value.AppendString(word);
105 } 105 }
106 web_ui()->CallJavascriptFunction("EditDictionaryOverlay.setWordList", 106 web_ui()->CallJavascriptFunctionUnsafe("EditDictionaryOverlay.setWordList",
107 list_value); 107 list_value);
108 } 108 }
109 109
110 void LanguageDictionaryOverlayHandler::RefreshWords( 110 void LanguageDictionaryOverlayHandler::RefreshWords(
111 const base::ListValue* args) { 111 const base::ListValue* args) {
112 overlay_initialized_ = true; 112 overlay_initialized_ = true;
113 ResetDictionaryWords(); 113 ResetDictionaryWords();
114 } 114 }
115 115
116 void LanguageDictionaryOverlayHandler::AddWord(const base::ListValue* args) { 116 void LanguageDictionaryOverlayHandler::AddWord(const base::ListValue* args) {
117 std::string new_word; 117 std::string new_word;
118 if (!args->GetString(0, &new_word) || new_word.empty() || !dictionary_) { 118 if (!args->GetString(0, &new_word) || new_word.empty() || !dictionary_) {
119 NOTREACHED(); 119 NOTREACHED();
120 return; 120 return;
121 } 121 }
122 dictionary_->AddWord(new_word); 122 dictionary_->AddWord(new_word);
123 } 123 }
124 124
125 void LanguageDictionaryOverlayHandler::RemoveWord(const base::ListValue* args) { 125 void LanguageDictionaryOverlayHandler::RemoveWord(const base::ListValue* args) {
126 std::string old_word; 126 std::string old_word;
127 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) { 127 if (!args->GetString(0, &old_word) || old_word.empty() || !dictionary_) {
128 NOTREACHED(); 128 NOTREACHED();
129 return; 129 return;
130 } 130 }
131 dictionary_->RemoveWord(old_word); 131 dictionary_->RemoveWord(old_word);
132 } 132 }
133 133
134 } // namespace options 134 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698