| 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/grit/browser_resources.h" | 13 #include "chrome/grit/browser_resources.h" |
| 14 #include "chrome/grit/generated_resources.h" |
| 14 #include "content/public/browser/web_ui_data_source.h" | 15 #include "content/public/browser/web_ui_data_source.h" |
| 15 #else | 16 #else |
| 16 #include <map> | 17 #include <map> |
| 17 #include "base/macros.h" | 18 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted_memory.h" | 19 #include "base/memory/ref_counted_memory.h" |
| 19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 20 #include "content/public/browser/url_data_source.h" | 21 #include "content/public/browser/url_data_source.h" |
| 21 #include "net/url_request/url_fetcher.h" | 22 #include "net/url_request/url_fetcher.h" |
| 22 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
| 23 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 delete source; | 173 delete source; |
| 173 pending_.erase(it); | 174 pending_.erase(it); |
| 174 } | 175 } |
| 175 #else | 176 #else |
| 176 content::WebUIDataSource* CreateVrShellUIHTMLSource() { | 177 content::WebUIDataSource* CreateVrShellUIHTMLSource() { |
| 177 content::WebUIDataSource* source = | 178 content::WebUIDataSource* source = |
| 178 content::WebUIDataSource::Create(chrome::kChromeUIVrShellUIHost); | 179 content::WebUIDataSource::Create(chrome::kChromeUIVrShellUIHost); |
| 179 source->AddResourcePath("vr_shell_ui.js", IDR_VR_SHELL_UI_JS); | 180 source->AddResourcePath("vr_shell_ui.js", IDR_VR_SHELL_UI_JS); |
| 180 source->AddResourcePath("vr_shell_ui.css", IDR_VR_SHELL_UI_CSS); | 181 source->AddResourcePath("vr_shell_ui.css", IDR_VR_SHELL_UI_CSS); |
| 181 source->SetDefaultResource(IDR_VR_SHELL_UI_HTML); | 182 source->SetDefaultResource(IDR_VR_SHELL_UI_HTML); |
| 182 source->DisableI18nAndUseGzipForAllPaths(); | 183 // We're localizing strings, so we can't currently use gzip since it's |
| 184 // incompatible with i18n. TODO(klausw): re-enable gzip once an i18n |
| 185 // compatible variant of WebUIDataSource's DisableI18nAndUseGzipForAllPaths |
| 186 // gets added, and add compress=gzip to browser_resources.grd as appropriate. |
| 187 source->AddLocalizedString( |
| 188 "insecureWebVrContentPermanent", |
| 189 IDS_WEBSITE_SETTINGS_INSECURE_WEBVR_CONTENT_PERMANENT); |
| 190 source->AddLocalizedString( |
| 191 "insecureWebVrContentTransient", |
| 192 IDS_WEBSITE_SETTINGS_INSECURE_WEBVR_CONTENT_TRANSIENT); |
| 183 return source; | 193 return source; |
| 184 } | 194 } |
| 185 #endif | 195 #endif |
| 186 | 196 |
| 187 } // namespace | 197 } // namespace |
| 188 | 198 |
| 189 VrShellUIUI::VrShellUIUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 199 VrShellUIUI::VrShellUIUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 190 Profile* profile = Profile::FromWebUI(web_ui); | 200 Profile* profile = Profile::FromWebUI(web_ui); |
| 191 #if !defined(ENABLE_VR_SHELL_UI_DEV) | 201 #if !defined(ENABLE_VR_SHELL_UI_DEV) |
| 192 content::WebUIDataSource::Add(profile, CreateVrShellUIHTMLSource()); | 202 content::WebUIDataSource::Add(profile, CreateVrShellUIHTMLSource()); |
| 193 #else | 203 #else |
| 194 content::URLDataSource::Add( | 204 content::URLDataSource::Add( |
| 195 profile, new RemoteDataSource(profile->GetRequestContext())); | 205 profile, new RemoteDataSource(profile->GetRequestContext())); |
| 196 #endif | 206 #endif |
| 197 web_ui->AddMessageHandler(new VrShellUIMessageHandler); | 207 web_ui->AddMessageHandler(new VrShellUIMessageHandler); |
| 198 } | 208 } |
| 199 | 209 |
| 200 VrShellUIUI::~VrShellUIUI() {} | 210 VrShellUIUI::~VrShellUIUI() {} |
| OLD | NEW |