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