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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 content::WebUIDataSource* CreateTranslateInternalsHTMLSource() { | 44 content::WebUIDataSource* CreateTranslateInternalsHTMLSource() { |
45 content::WebUIDataSource* source = | 45 content::WebUIDataSource* source = |
46 content::WebUIDataSource::Create(chrome::kChromeUITranslateInternalsHost); | 46 content::WebUIDataSource::Create(chrome::kChromeUITranslateInternalsHost); |
47 | 47 |
48 source->SetDefaultResource(IDR_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HTML); | 48 source->SetDefaultResource(IDR_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HTML); |
49 source->SetJsonPath("strings.js"); | 49 source->SetJsonPath("strings.js"); |
50 source->AddResourcePath("translate_internals.js", | 50 source->AddResourcePath("translate_internals.js", |
51 IDR_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_JS); | 51 IDR_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_JS); |
| 52 source->UseGzipForAllPaths(); |
52 | 53 |
53 base::DictionaryValue langs; | 54 base::DictionaryValue langs; |
54 GetLanguages(&langs); | 55 GetLanguages(&langs); |
55 for (base::DictionaryValue::Iterator it(langs); !it.IsAtEnd(); it.Advance()) { | 56 for (base::DictionaryValue::Iterator it(langs); !it.IsAtEnd(); it.Advance()) { |
56 std::string key = "language-" + it.key(); | 57 std::string key = "language-" + it.key(); |
57 std::string value; | 58 std::string value; |
58 it.value().GetAsString(&value); | 59 it.value().GetAsString(&value); |
59 source->AddString(key, value); | 60 source->AddString(key, value); |
60 } | 61 } |
61 | 62 |
62 std::string cld_version = ""; | 63 std::string cld_version = ""; |
63 // The version string is hardcoded here to avoid linking with the CLD | 64 // The version string is hardcoded here to avoid linking with the CLD |
64 // library, see http://crbug.com/297777. | 65 // library, see http://crbug.com/297777. |
65 cld_version = "2"; | 66 cld_version = "2"; |
66 source->AddString("cld-version", cld_version); | 67 source->AddString("cld-version", cld_version); |
67 | 68 |
68 return source; | 69 return source; |
69 } | 70 } |
70 | 71 |
71 } // namespace | 72 } // namespace |
72 | 73 |
73 TranslateInternalsUI::TranslateInternalsUI(content::WebUI* web_ui) | 74 TranslateInternalsUI::TranslateInternalsUI(content::WebUI* web_ui) |
74 : WebUIController(web_ui) { | 75 : WebUIController(web_ui) { |
75 web_ui->AddMessageHandler(new TranslateInternalsHandler); | 76 web_ui->AddMessageHandler(new TranslateInternalsHandler); |
76 | 77 |
77 Profile* profile = Profile::FromWebUI(web_ui); | 78 Profile* profile = Profile::FromWebUI(web_ui); |
78 content::WebUIDataSource::Add(profile, CreateTranslateInternalsHTMLSource()); | 79 content::WebUIDataSource::Add(profile, CreateTranslateInternalsHTMLSource()); |
79 } | 80 } |
OLD | NEW |