| 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_ui.h" | 5 #include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/webui/translate_internals/translate_internals_handle
r.h" | 15 #include "chrome/browser/ui/webui/translate_internals/translate_internals_handle
r.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "components/translate/content/common/cld_data_source.h" | |
| 19 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_ui.h" | 19 #include "content/public/browser/web_ui.h" |
| 21 #include "content/public/browser/web_ui_data_source.h" | 20 #include "content/public/browser/web_ui_data_source.h" |
| 22 #include "grit/translate_internals_resources.h" | 21 #include "grit/translate_internals_resources.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 24 | 23 |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 27 // Sets the languages to |dict|. Each key is a language code and each value is | 26 // Sets the languages to |dict|. Each key is a language code and each value is |
| 28 // a language name in the locale. | 27 // a language name in the locale. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 54 base::DictionaryValue langs; | 53 base::DictionaryValue langs; |
| 55 GetLanguages(&langs); | 54 GetLanguages(&langs); |
| 56 for (base::DictionaryValue::Iterator it(langs); !it.IsAtEnd(); it.Advance()) { | 55 for (base::DictionaryValue::Iterator it(langs); !it.IsAtEnd(); it.Advance()) { |
| 57 std::string key = "language-" + it.key(); | 56 std::string key = "language-" + it.key(); |
| 58 std::string value; | 57 std::string value; |
| 59 it.value().GetAsString(&value); | 58 it.value().GetAsString(&value); |
| 60 source->AddString(key, value); | 59 source->AddString(key, value); |
| 61 } | 60 } |
| 62 | 61 |
| 63 std::string cld_version = ""; | 62 std::string cld_version = ""; |
| 64 std::string cld_data_source = ""; | |
| 65 // The version string is hardcoded here to avoid linking with the CLD | 63 // The version string is hardcoded here to avoid linking with the CLD |
| 66 // library, see http://crbug.com/297777. | 64 // library, see http://crbug.com/297777. |
| 67 cld_version = "2"; | 65 cld_version = "2"; |
| 68 cld_data_source = translate::CldDataSource::Get()->GetName(); | |
| 69 source->AddString("cld-version", cld_version); | 66 source->AddString("cld-version", cld_version); |
| 70 source->AddString("cld-data-source", cld_data_source); | |
| 71 | 67 |
| 72 return source; | 68 return source; |
| 73 } | 69 } |
| 74 | 70 |
| 75 } // namespace | 71 } // namespace |
| 76 | 72 |
| 77 TranslateInternalsUI::TranslateInternalsUI(content::WebUI* web_ui) | 73 TranslateInternalsUI::TranslateInternalsUI(content::WebUI* web_ui) |
| 78 : WebUIController(web_ui) { | 74 : WebUIController(web_ui) { |
| 79 web_ui->AddMessageHandler(new TranslateInternalsHandler); | 75 web_ui->AddMessageHandler(new TranslateInternalsHandler); |
| 80 | 76 |
| 81 Profile* profile = Profile::FromWebUI(web_ui); | 77 Profile* profile = Profile::FromWebUI(web_ui); |
| 82 content::WebUIDataSource::Add(profile, CreateTranslateInternalsHTMLSource()); | 78 content::WebUIDataSource::Add(profile, CreateTranslateInternalsHTMLSource()); |
| 83 } | 79 } |
| OLD | NEW |