Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/vr_shell/vr_shell_ui_ui.h" | 5 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_ui.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h" | 8 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "content/public/browser/web_ui.h" | 10 #include "content/public/browser/web_ui.h" |
| 11 | 11 |
| 12 #if !defined(ENABLE_VR_SHELL_UI_DEV) | 12 #if !defined(ENABLE_VR_SHELL_UI_DEV) |
| 13 #include "chrome/browser/browser_process.h" | |
| 13 #include "chrome/grit/browser_resources.h" | 14 #include "chrome/grit/browser_resources.h" |
| 15 #include "chrome/grit/generated_resources.h" | |
| 14 #include "content/public/browser/web_ui_data_source.h" | 16 #include "content/public/browser/web_ui_data_source.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | |
| 18 #include "ui/base/webui/web_ui_util.h" | |
| 15 #else | 19 #else |
| 16 #include <map> | 20 #include <map> |
| 17 #include "base/macros.h" | 21 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted_memory.h" | 22 #include "base/memory/ref_counted_memory.h" |
| 19 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 20 #include "content/public/browser/url_data_source.h" | 24 #include "content/public/browser/url_data_source.h" |
| 21 #include "net/url_request/url_fetcher.h" | 25 #include "net/url_request/url_fetcher.h" |
| 22 #include "net/url_request/url_fetcher_delegate.h" | 26 #include "net/url_request/url_fetcher_delegate.h" |
| 23 #include "net/url_request/url_request_context_getter.h" | 27 #include "net/url_request/url_request_context_getter.h" |
| 24 #endif | 28 #endif |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 delete source; | 176 delete source; |
| 173 pending_.erase(it); | 177 pending_.erase(it); |
| 174 } | 178 } |
| 175 #else | 179 #else |
| 176 content::WebUIDataSource* CreateVrShellUIHTMLSource() { | 180 content::WebUIDataSource* CreateVrShellUIHTMLSource() { |
| 177 content::WebUIDataSource* source = | 181 content::WebUIDataSource* source = |
| 178 content::WebUIDataSource::Create(chrome::kChromeUIVrShellUIHost); | 182 content::WebUIDataSource::Create(chrome::kChromeUIVrShellUIHost); |
| 179 source->AddResourcePath("vr_shell_ui.js", IDR_VR_SHELL_UI_JS); | 183 source->AddResourcePath("vr_shell_ui.js", IDR_VR_SHELL_UI_JS); |
| 180 source->AddResourcePath("vr_shell_ui.css", IDR_VR_SHELL_UI_CSS); | 184 source->AddResourcePath("vr_shell_ui.css", IDR_VR_SHELL_UI_CSS); |
| 181 source->SetDefaultResource(IDR_VR_SHELL_UI_HTML); | 185 source->SetDefaultResource(IDR_VR_SHELL_UI_HTML); |
| 182 source->DisableI18nAndUseGzipForAllPaths(); | 186 // We're localizing strings, so we can't currently use gzip since it's |
| 187 // incompatible with i18n. TODO(klausw): re-enable gzip once an i18n | |
| 188 // compatible variant of WebUIDataSource's DisableI18nAndUseGzipForAllPaths | |
| 189 // gets added, and add compress=gzip to browser_resources.grd as appropriate. | |
| 190 | |
| 191 base::DictionaryValue localized_strings; | |
| 192 | |
| 193 localized_strings.SetString( | |
| 194 "insecureWebVrContentPermanent", | |
| 195 l10n_util::GetStringUTF16( | |
| 196 IDS_WEBSITE_SETTINGS_INSECURE_WEBVR_CONTENT_PERMANENT)); | |
| 197 localized_strings.SetString( | |
| 198 "insecureWebVrContentTransient", | |
| 199 l10n_util::GetStringUTF16( | |
| 200 IDS_WEBSITE_SETTINGS_INSECURE_WEBVR_CONTENT_TRANSIENT)); | |
| 201 | |
| 202 const std::string& app_locale = g_browser_process->GetApplicationLocale(); | |
| 203 webui::SetLoadTimeDataDefaults(app_locale, &localized_strings); | |
|
Dan Beam
2016/10/03 20:30:59
why are you adding this? SetLoadTimeDataDefaults(
klausw
2016/10/03 21:28:19
Thank you, it does indeed work without it. FWIW, t
| |
| 204 | |
| 205 source->AddLocalizedStrings(localized_strings); | |
| 183 return source; | 206 return source; |
| 184 } | 207 } |
| 185 #endif | 208 #endif |
| 186 | 209 |
| 187 } // namespace | 210 } // namespace |
| 188 | 211 |
| 189 VrShellUIUI::VrShellUIUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 212 VrShellUIUI::VrShellUIUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 190 Profile* profile = Profile::FromWebUI(web_ui); | 213 Profile* profile = Profile::FromWebUI(web_ui); |
| 191 #if !defined(ENABLE_VR_SHELL_UI_DEV) | 214 #if !defined(ENABLE_VR_SHELL_UI_DEV) |
| 192 content::WebUIDataSource::Add(profile, CreateVrShellUIHTMLSource()); | 215 content::WebUIDataSource::Add(profile, CreateVrShellUIHTMLSource()); |
| 193 #else | 216 #else |
| 194 content::URLDataSource::Add( | 217 content::URLDataSource::Add( |
| 195 profile, new RemoteDataSource(profile->GetRequestContext())); | 218 profile, new RemoteDataSource(profile->GetRequestContext())); |
| 196 #endif | 219 #endif |
| 197 web_ui->AddMessageHandler(new VrShellUIMessageHandler); | 220 web_ui->AddMessageHandler(new VrShellUIMessageHandler); |
| 198 } | 221 } |
| 199 | 222 |
| 200 VrShellUIUI::~VrShellUIUI() {} | 223 VrShellUIUI::~VrShellUIUI() {} |
| OLD | NEW |