Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/ui/webui/version_ui.cc

Issue 1486403002: Mojo-ifying chrome://version. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing DOMContentLoaded TODO. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/version_handler.h" 10 #include "chrome/browser/ui/webui/version_handler.h"
(...skipping 18 matching lines...) Expand all
29 29
30 #if defined(ENABLE_THEMES) 30 #if defined(ENABLE_THEMES)
31 #include "chrome/browser/ui/webui/theme_source.h" 31 #include "chrome/browser/ui/webui/theme_source.h"
32 #endif 32 #endif
33 33
34 #if defined(OS_ANDROID) 34 #if defined(OS_ANDROID)
35 #include "base/android/build_info.h" 35 #include "base/android/build_info.h"
36 #include "chrome/browser/ui/android/android_about_app_info.h" 36 #include "chrome/browser/ui/android/android_about_app_info.h"
37 #endif 37 #endif
38 38
39 #if defined(OS_CHROMEOS)
40 #include "chrome/browser/ui/webui/version_handler_chromeos.h"
41 #endif
42
43 using content::WebUIDataSource; 39 using content::WebUIDataSource;
44 40
45 namespace { 41 namespace {
46 42
47 WebUIDataSource* CreateVersionUIDataSource() { 43 WebUIDataSource* CreateVersionUIDataSource() {
48 WebUIDataSource* html_source = 44 WebUIDataSource* html_source =
49 WebUIDataSource::Create(chrome::kChromeUIVersionHost); 45 WebUIDataSource::Create(chrome::kChromeUIVersionHost);
50 46
51 // Localized and data strings. 47 // Localized and data strings.
52 html_source->AddLocalizedString(version_ui::kTitle, IDS_VERSION_UI_TITLE); 48 html_source->AddLocalizedString(version_ui::kTitle, IDS_VERSION_UI_TITLE);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 #else 137 #else
142 html_source->AddString("compiler", "MSVC"); 138 html_source->AddString("compiler", "MSVC");
143 #endif 139 #endif
144 #endif 140 #endif
145 141
146 html_source->SetJsonPath("strings.js"); 142 html_source->SetJsonPath("strings.js");
147 html_source->AddResourcePath(version_ui::kVersionJS, IDR_VERSION_UI_JS); 143 html_source->AddResourcePath(version_ui::kVersionJS, IDR_VERSION_UI_JS);
148 html_source->AddResourcePath(version_ui::kAboutVersionCSS, 144 html_source->AddResourcePath(version_ui::kAboutVersionCSS,
149 IDR_VERSION_UI_CSS); 145 IDR_VERSION_UI_CSS);
150 html_source->SetDefaultResource(IDR_VERSION_UI_HTML); 146 html_source->SetDefaultResource(IDR_VERSION_UI_HTML);
147
148 html_source->AddResourcePath(
149 "chrome/browser/ui/webui/version.mojom",
150 IDR_VERSION_MOJO_JS);
Dan Beam 2015/12/09 21:45:07 html_source->AddResourcePath("chrome/browser/ui/we
dpapad 2015/12/10 01:08:27 Done.
151 html_source->AddMojoResources();
152
151 return html_source; 153 return html_source;
152 } 154 }
153 155
154 } // namespace 156 } // namespace
155 157
156 VersionUI::VersionUI(content::WebUI* web_ui) 158 VersionUI::VersionUI(content::WebUI* web_ui)
157 : content::WebUIController(web_ui) { 159 : MojoWebUIController(web_ui) {
158 Profile* profile = Profile::FromWebUI(web_ui); 160 Profile* profile = Profile::FromWebUI(web_ui);
159 161
160 #if defined(OS_CHROMEOS)
161 web_ui->AddMessageHandler(new VersionHandlerChromeOS());
162 #else
163 web_ui->AddMessageHandler(new VersionHandler());
164 #endif
165
166 #if defined(ENABLE_THEMES) 162 #if defined(ENABLE_THEMES)
167 // Set up the chrome://theme/ source. 163 // Set up the chrome://theme/ source.
168 ThemeSource* theme = new ThemeSource(profile); 164 ThemeSource* theme = new ThemeSource(profile);
169 content::URLDataSource::Add(profile, theme); 165 content::URLDataSource::Add(profile, theme);
170 #endif 166 #endif
171 167
172 WebUIDataSource::Add(profile, CreateVersionUIDataSource()); 168 WebUIDataSource::Add(profile, CreateVersionUIDataSource());
173 } 169 }
174 170
175 VersionUI::~VersionUI() { 171 VersionUI::~VersionUI() {
176 } 172 }
173
174 void VersionUI::BindUIHandler(
175 mojo::InterfaceRequest<VersionHandlerMojo> request) {
176 // VersionHandler deletes itself when the pipe is closed.
177 new VersionHandler(web_ui(), request.Pass());
178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698