1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/version_ui.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/version_handler.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/user_agent.h"
#include "grit/browser_resources.h"
#include "grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "v8/include/v8.h"
#if defined(ENABLE_THEMES)
#include "chrome/browser/ui/webui/theme_source.h"
#endif
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
#include "chrome/browser/ui/android/android_about_app_info.h"
#endif
#if defined(OS_CHROMEOS)
#include "chrome/browser/ui/webui/version_handler_chromeos.h"
#endif
using content::WebUIDataSource;
namespace {
WebUIDataSource* CreateVersionUIDataSource() {
WebUIDataSource* html_source =
WebUIDataSource::Create(chrome::kChromeUIVersionHost);
// Localized and data strings.
html_source->AddLocalizedString("title", IDS_ABOUT_VERSION_TITLE);
html_source->AddLocalizedString("application_label", IDS_PRODUCT_NAME);
html_source->AddString("version", version_info::GetVersionNumber());
html_source->AddString("version_modifier", chrome::GetChannelString());
html_source->AddLocalizedString("os_name", IDS_ABOUT_VERSION_OS);
html_source->AddLocalizedString("platform", IDS_PLATFORM_LABEL);
html_source->AddString("os_type", version_info::GetOSType());
html_source->AddString("blink_version", content::GetWebKitVersion());
html_source->AddString("js_engine", "V8");
html_source->AddString("js_version", v8::V8::GetVersion());
#if defined(OS_ANDROID)
html_source->AddString("os_version", AndroidAboutAppInfo::GetOsInfo());
html_source->AddLocalizedString("build_id_name",
IDS_ABOUT_VERSION_BUILD_ID);
html_source->AddString("build_id", CHROME_BUILD_ID);
#else
html_source->AddString("os_version", std::string());
html_source->AddString("flash_plugin", "Flash");
// Note that the Flash version is retrieve asynchronously and returned in
// VersionHandler::OnGotPlugins. The area is initially blank.
html_source->AddString("flash_version", std::string());
#endif // defined(OS_ANDROID)
html_source->AddLocalizedString("company", IDS_ABOUT_VERSION_COMPANY_NAME);
base::Time::Exploded exploded_time;
base::Time::Now().LocalExplode(&exploded_time);
html_source->AddString(
"copyright",
l10n_util::GetStringFUTF16(IDS_ABOUT_VERSION_COPYRIGHT,
base::IntToString16(exploded_time.year)));
html_source->AddLocalizedString("revision", IDS_ABOUT_VERSION_REVISION);
html_source->AddString("cl", version_info::GetLastChange());
html_source->AddLocalizedString("official",
version_info::IsOfficialBuild()
? IDS_ABOUT_VERSION_OFFICIAL
: IDS_ABOUT_VERSION_UNOFFICIAL);
#if defined(ARCH_CPU_64_BITS)
html_source->AddLocalizedString("version_bitsize", IDS_ABOUT_VERSION_64BIT);
#else
html_source->AddLocalizedString("version_bitsize", IDS_ABOUT_VERSION_32BIT);
#endif
html_source->AddLocalizedString("user_agent_name",
IDS_ABOUT_VERSION_USER_AGENT);
html_source->AddString("useragent", GetUserAgent());
html_source->AddLocalizedString("command_line_name",
IDS_ABOUT_VERSION_COMMAND_LINE);
#if defined(OS_WIN)
html_source->AddString(
"command_line",
base::CommandLine::ForCurrentProcess()->GetCommandLineString());
#elif defined(OS_POSIX)
std::string command_line;
typedef std::vector<std::string> ArgvList;
const ArgvList& argv = base::CommandLine::ForCurrentProcess()->argv();
for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
command_line += " " + *iter;
// TODO(viettrungluu): |command_line| could really have any encoding, whereas
// below we assumes it's UTF-8.
html_source->AddString("command_line", command_line);
#endif
// Note that the executable path and profile path are retrieved asynchronously
// and returned in VersionHandler::OnGotFilePaths. The area is initially
// blank.
html_source->AddLocalizedString("executable_path_name",
IDS_ABOUT_VERSION_EXECUTABLE_PATH);
html_source->AddString("executable_path", std::string());
html_source->AddLocalizedString("profile_path_name",
IDS_ABOUT_VERSION_PROFILE_PATH);
html_source->AddString("profile_path", std::string());
html_source->AddLocalizedString("variations_name",
IDS_ABOUT_VERSION_VARIATIONS);
html_source->SetJsonPath("strings.js");
html_source->AddResourcePath("version.js", IDR_ABOUT_VERSION_JS);
html_source->AddResourcePath("about_version.css", IDR_ABOUT_VERSION_CSS);
html_source->SetDefaultResource(IDR_ABOUT_VERSION_HTML);
return html_source;
}
} // namespace
VersionUI::VersionUI(content::WebUI* web_ui)
: content::WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
#if defined(OS_CHROMEOS)
web_ui->AddMessageHandler(new VersionHandlerChromeOS());
#else
web_ui->AddMessageHandler(new VersionHandler());
#endif
#if defined(ENABLE_THEMES)
// Set up the chrome://theme/ source.
ThemeSource* theme = new ThemeSource(profile);
content::URLDataSource::Add(profile, theme);
#endif
WebUIDataSource::Add(profile, CreateVersionUIDataSource());
}
VersionUI::~VersionUI() {
}
|