| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/translate_internals/translate_internals_handle
r.h" | 5 #include "chrome/browser/ui/webui/translate_internals/translate_internals_handle
r.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 void TranslateInternalsHandler::OnRequestInfo(const base::ListValue* /*args*/) { | 181 void TranslateInternalsHandler::OnRequestInfo(const base::ListValue* /*args*/) { |
| 182 SendPrefsToJs(); | 182 SendPrefsToJs(); |
| 183 SendSupportedLanguagesToJs(); | 183 SendSupportedLanguagesToJs(); |
| 184 SendCountryToJs(false); | 184 SendCountryToJs(false); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void TranslateInternalsHandler::SendMessageToJs(const std::string& message, | 187 void TranslateInternalsHandler::SendMessageToJs(const std::string& message, |
| 188 const base::Value& value) { | 188 const base::Value& value) { |
| 189 const char func[] = "cr.translateInternals.messageHandler"; | 189 const char func[] = "cr.translateInternals.messageHandler"; |
| 190 base::StringValue message_data(message); | 190 base::StringValue message_data(message); |
| 191 web_ui()->CallJavascriptFunction(func, message_data, value); | 191 web_ui()->CallJavascriptFunctionUnsafe(func, message_data, value); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void TranslateInternalsHandler::SendPrefsToJs() { | 194 void TranslateInternalsHandler::SendPrefsToJs() { |
| 195 content::WebContents* web_contents = web_ui()->GetWebContents(); | 195 content::WebContents* web_contents = web_ui()->GetWebContents(); |
| 196 Profile* profile = | 196 Profile* profile = |
| 197 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 197 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 198 PrefService* prefs = profile->GetOriginalProfile()->GetPrefs(); | 198 PrefService* prefs = profile->GetOriginalProfile()->GetPrefs(); |
| 199 | 199 |
| 200 base::DictionaryValue dict; | 200 base::DictionaryValue dict; |
| 201 | 201 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 if (variations_service) | 250 if (variations_service) |
| 251 country = variations_service->GetStoredPermanentCountry(); | 251 country = variations_service->GetStoredPermanentCountry(); |
| 252 | 252 |
| 253 base::DictionaryValue dict; | 253 base::DictionaryValue dict; |
| 254 if (!country.empty()) { | 254 if (!country.empty()) { |
| 255 dict.Set("country", new base::StringValue(country)); | 255 dict.Set("country", new base::StringValue(country)); |
| 256 dict.Set("update", new base::FundamentalValue(was_updated)); | 256 dict.Set("update", new base::FundamentalValue(was_updated)); |
| 257 } | 257 } |
| 258 SendMessageToJs("countryUpdated", dict); | 258 SendMessageToJs("countryUpdated", dict); |
| 259 } | 259 } |
| OLD | NEW |