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