| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/version_ui.h" | 5 #include "chrome/browser/ui/webui/version_ui.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/message_formatter.h" | 8 #include "base/i18n/message_formatter.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #if defined(ENABLE_THEMES) | 32 #if defined(ENABLE_THEMES) |
| 33 #include "chrome/browser/ui/webui/theme_source.h" | 33 #include "chrome/browser/ui/webui/theme_source.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
| 37 #include "base/android/build_info.h" | 37 #include "base/android/build_info.h" |
| 38 #include "chrome/browser/ui/android/android_about_app_info.h" | 38 #include "chrome/browser/ui/android/android_about_app_info.h" |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 #if defined(OS_CHROMEOS) | |
| 42 #include "chrome/browser/ui/webui/version_handler_chromeos.h" | |
| 43 #endif | |
| 44 | |
| 45 using content::WebUIDataSource; | 41 using content::WebUIDataSource; |
| 46 | 42 |
| 47 namespace { | 43 namespace { |
| 48 | 44 |
| 49 WebUIDataSource* CreateVersionUIDataSource() { | 45 WebUIDataSource* CreateVersionUIDataSource() { |
| 50 WebUIDataSource* html_source = | 46 WebUIDataSource* html_source = |
| 51 WebUIDataSource::Create(chrome::kChromeUIVersionHost); | 47 WebUIDataSource::Create(chrome::kChromeUIVersionHost); |
| 52 | 48 |
| 53 // Localized and data strings. | 49 // Localized and data strings. |
| 54 html_source->AddLocalizedString(version_ui::kTitle, IDS_VERSION_UI_TITLE); | 50 html_source->AddLocalizedString(version_ui::kTitle, IDS_VERSION_UI_TITLE); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 #else | 140 #else |
| 145 html_source->AddString("compiler", "Unknown"); | 141 html_source->AddString("compiler", "Unknown"); |
| 146 #endif | 142 #endif |
| 147 #endif // defined(OS_WIN) | 143 #endif // defined(OS_WIN) |
| 148 | 144 |
| 149 html_source->SetJsonPath("strings.js"); | 145 html_source->SetJsonPath("strings.js"); |
| 150 html_source->AddResourcePath(version_ui::kVersionJS, IDR_VERSION_UI_JS); | 146 html_source->AddResourcePath(version_ui::kVersionJS, IDR_VERSION_UI_JS); |
| 151 html_source->AddResourcePath(version_ui::kAboutVersionCSS, | 147 html_source->AddResourcePath(version_ui::kAboutVersionCSS, |
| 152 IDR_VERSION_UI_CSS); | 148 IDR_VERSION_UI_CSS); |
| 153 html_source->SetDefaultResource(IDR_VERSION_UI_HTML); | 149 html_source->SetDefaultResource(IDR_VERSION_UI_HTML); |
| 150 |
| 151 html_source->AddResourcePath("components/version_ui/version.mojom", |
| 152 IDR_VERSION_MOJO_JS); |
| 153 |
| 154 return html_source; | 154 return html_source; |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace | 157 } // namespace |
| 158 | 158 |
| 159 VersionUI::VersionUI(content::WebUI* web_ui) | 159 VersionUI::VersionUI(content::WebUI* web_ui) : MojoWebUIController(web_ui) { |
| 160 : content::WebUIController(web_ui) { | |
| 161 Profile* profile = Profile::FromWebUI(web_ui); | 160 Profile* profile = Profile::FromWebUI(web_ui); |
| 162 | 161 |
| 163 #if defined(OS_CHROMEOS) | |
| 164 web_ui->AddMessageHandler(new VersionHandlerChromeOS()); | |
| 165 #else | |
| 166 web_ui->AddMessageHandler(new VersionHandler()); | |
| 167 #endif | |
| 168 | |
| 169 #if defined(ENABLE_THEMES) | 162 #if defined(ENABLE_THEMES) |
| 170 // Set up the chrome://theme/ source. | 163 // Set up the chrome://theme/ source. |
| 171 ThemeSource* theme = new ThemeSource(profile); | 164 ThemeSource* theme = new ThemeSource(profile); |
| 172 content::URLDataSource::Add(profile, theme); | 165 content::URLDataSource::Add(profile, theme); |
| 173 #endif | 166 #endif |
| 174 | 167 |
| 175 WebUIDataSource::Add(profile, CreateVersionUIDataSource()); | 168 WebUIDataSource::Add(profile, CreateVersionUIDataSource()); |
| 176 } | 169 } |
| 177 | 170 |
| 178 VersionUI::~VersionUI() { | 171 VersionUI::~VersionUI() {} |
| 172 |
| 173 void VersionUI::BindUIHandler( |
| 174 mojo::InterfaceRequest<mojom::VersionPageHandler> request) { |
| 175 version_handler_.reset(new VersionHandler(web_ui(), std::move(request))); |
| 179 } | 176 } |
| OLD | NEW |