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

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

Issue 2626043007: Clean up chrome://version page. (Closed)
Patch Set: fix rebase Created 3 years, 10 months 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
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | components/version_ui/resources/about_version.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/i18n/message_formatter.h" 8 #include "base/i18n/message_formatter.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 12 matching lines...) Expand all
23 #include "components/version_info/version_info.h" 23 #include "components/version_info/version_info.h"
24 #include "components/version_ui/version_ui_constants.h" 24 #include "components/version_ui/version_ui_constants.h"
25 #include "content/public/browser/url_data_source.h" 25 #include "content/public/browser/url_data_source.h"
26 #include "content/public/browser/web_ui.h" 26 #include "content/public/browser/web_ui.h"
27 #include "content/public/browser/web_ui_data_source.h" 27 #include "content/public/browser/web_ui_data_source.h"
28 #include "content/public/common/user_agent.h" 28 #include "content/public/common/user_agent.h"
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 #include "v8/include/v8-version-string.h" 30 #include "v8/include/v8-version-string.h"
31 31
32 #if defined(OS_ANDROID) 32 #if defined(OS_ANDROID)
33 #include "base/android/build_info.h"
34 #include "chrome/browser/ui/android/android_about_app_info.h" 33 #include "chrome/browser/ui/android/android_about_app_info.h"
35 #else // !defined(OS_ANDROID) 34 #else // !defined(OS_ANDROID)
36 #include "chrome/browser/ui/webui/theme_source.h" 35 #include "chrome/browser/ui/webui/theme_source.h"
37 #endif 36 #endif
38 37
39 #if defined(OS_CHROMEOS) 38 #if defined(OS_CHROMEOS)
40 #include "chrome/browser/ui/webui/version_handler_chromeos.h" 39 #include "chrome/browser/ui/webui/version_handler_chromeos.h"
41 #endif 40 #endif
42 41
43 using content::WebUIDataSource; 42 using content::WebUIDataSource;
44 43
45 namespace { 44 namespace {
46 45
47 WebUIDataSource* CreateVersionUIDataSource() { 46 WebUIDataSource* CreateVersionUIDataSource() {
48 WebUIDataSource* html_source = 47 WebUIDataSource* html_source =
49 WebUIDataSource::Create(chrome::kChromeUIVersionHost); 48 WebUIDataSource::Create(chrome::kChromeUIVersionHost);
50 49
51 // Localized and data strings. 50 // Localized and data strings.
52 html_source->AddLocalizedString(version_ui::kTitle, IDS_VERSION_UI_TITLE); 51 html_source->AddLocalizedString(version_ui::kTitle, IDS_VERSION_UI_TITLE);
53 html_source->AddLocalizedString(version_ui::kApplicationLabel, 52 html_source->AddLocalizedString(version_ui::kApplicationLabel,
54 IDS_PRODUCT_NAME); 53 IDS_PRODUCT_NAME);
55 html_source->AddString(version_ui::kVersion, 54 html_source->AddString(version_ui::kVersion,
56 version_info::GetVersionNumber()); 55 version_info::GetVersionNumber());
57 html_source->AddString(version_ui::kVersionModifier, 56 html_source->AddString(version_ui::kVersionModifier,
58 chrome::GetChannelString()); 57 chrome::GetChannelString());
59 html_source->AddLocalizedString(version_ui::kOSName, IDS_VERSION_UI_OS);
60 html_source->AddLocalizedString(version_ui::kARC, IDS_ARC_LABEL);
61 html_source->AddLocalizedString(version_ui::kPlatform, IDS_PLATFORM_LABEL);
62 html_source->AddString(version_ui::kOSType, version_info::GetOSType());
63 html_source->AddString(version_ui::kJSEngine, "V8"); 58 html_source->AddString(version_ui::kJSEngine, "V8");
64 html_source->AddString(version_ui::kJSVersion, V8_VERSION_STRING); 59 html_source->AddString(version_ui::kJSVersion, V8_VERSION_STRING);
65
66 #if defined(OS_ANDROID)
67 html_source->AddString(version_ui::kOSVersion,
68 AndroidAboutAppInfo::GetOsInfo());
69 #else
70 html_source->AddString(version_ui::kOSVersion, std::string());
71 html_source->AddString(version_ui::kFlashPlugin, "Flash");
72 // Note that the Flash version is retrieve asynchronously and returned in
73 // VersionHandler::OnGotPlugins. The area is initially blank.
74 html_source->AddString(version_ui::kFlashVersion, std::string());
75 #endif // defined(OS_ANDROID)
76
77 html_source->AddLocalizedString(version_ui::kCompany, 60 html_source->AddLocalizedString(version_ui::kCompany,
78 IDS_ABOUT_VERSION_COMPANY_NAME); 61 IDS_ABOUT_VERSION_COMPANY_NAME);
79 html_source->AddString( 62 html_source->AddString(
80 version_ui::kCopyright, 63 version_ui::kCopyright,
81 base::i18n::MessageFormatter::FormatWithNumberedArgs( 64 base::i18n::MessageFormatter::FormatWithNumberedArgs(
82 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT), 65 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_COPYRIGHT),
83 base::Time::Now())); 66 base::Time::Now()));
84 html_source->AddLocalizedString(version_ui::kRevision, 67 html_source->AddLocalizedString(version_ui::kRevision,
85 IDS_VERSION_UI_REVISION); 68 IDS_VERSION_UI_REVISION);
86 html_source->AddString(version_ui::kCL, version_info::GetLastChange()); 69 html_source->AddString(version_ui::kCL, version_info::GetLastChange());
87 html_source->AddLocalizedString(version_ui::kOfficial, 70 html_source->AddLocalizedString(version_ui::kOfficial,
88 version_info::IsOfficialBuild() 71 version_info::IsOfficialBuild()
89 ? IDS_VERSION_UI_OFFICIAL 72 ? IDS_VERSION_UI_OFFICIAL
90 : IDS_VERSION_UI_UNOFFICIAL); 73 : IDS_VERSION_UI_UNOFFICIAL);
74 html_source->AddLocalizedString(version_ui::kUserAgentName,
75 IDS_VERSION_UI_USER_AGENT);
76 html_source->AddString(version_ui::kUserAgent, GetUserAgent());
77 html_source->AddLocalizedString(version_ui::kCommandLineName,
78 IDS_VERSION_UI_COMMAND_LINE);
79 // Note that the executable path and profile path are retrieved asynchronously
80 // and returned in VersionHandler::OnGotFilePaths. The area is initially
81 // blank.
82 html_source->AddLocalizedString(version_ui::kExecutablePathName,
83 IDS_VERSION_UI_EXECUTABLE_PATH);
84 html_source->AddString(version_ui::kExecutablePath, std::string());
85 html_source->AddLocalizedString(version_ui::kProfilePathName,
86 IDS_VERSION_UI_PROFILE_PATH);
87 html_source->AddString(version_ui::kProfilePath, std::string());
88 html_source->AddLocalizedString(version_ui::kVariationsName,
89 IDS_VERSION_UI_VARIATIONS);
91 90
92 #if defined(OS_CHROMEOS) 91 #if defined(OS_CHROMEOS)
92 html_source->AddLocalizedString(version_ui::kARC, IDS_ARC_LABEL);
93 html_source->AddLocalizedString(version_ui::kPlatform, IDS_PLATFORM_LABEL);
93 html_source->AddLocalizedString(version_ui::kCustomizationId, 94 html_source->AddLocalizedString(version_ui::kCustomizationId,
94 IDS_VERSION_UI_CUSTOMIZATION_ID); 95 IDS_VERSION_UI_CUSTOMIZATION_ID);
96 #else
97 html_source->AddLocalizedString(version_ui::kOSName, IDS_VERSION_UI_OS);
98 html_source->AddString(version_ui::kOSType, version_info::GetOSType());
95 #endif // OS_CHROMEOS 99 #endif // OS_CHROMEOS
96 100
101 #if defined(OS_ANDROID)
102 html_source->AddString(version_ui::kOSVersion,
103 AndroidAboutAppInfo::GetOsInfo());
104 #else
105 html_source->AddString(version_ui::kFlashPlugin, "Flash");
106 // Note that the Flash version is retrieve asynchronously and returned in
107 // VersionHandler::OnGotPlugins. The area is initially blank.
108 html_source->AddString(version_ui::kFlashVersion, std::string());
109 #endif // OS_ANDROID
110
97 #if defined(ARCH_CPU_64_BITS) 111 #if defined(ARCH_CPU_64_BITS)
98 html_source->AddLocalizedString(version_ui::kVersionBitSize, 112 html_source->AddLocalizedString(version_ui::kVersionBitSize,
99 IDS_VERSION_UI_64BIT); 113 IDS_VERSION_UI_64BIT);
100 #else 114 #else
101 html_source->AddLocalizedString(version_ui::kVersionBitSize, 115 html_source->AddLocalizedString(version_ui::kVersionBitSize,
102 IDS_VERSION_UI_32BIT); 116 IDS_VERSION_UI_32BIT);
103 #endif 117 #endif
104 html_source->AddLocalizedString(version_ui::kUserAgentName,
105 IDS_VERSION_UI_USER_AGENT);
106 html_source->AddString(version_ui::kUserAgent, GetUserAgent());
107 html_source->AddLocalizedString(version_ui::kCommandLineName,
108 IDS_VERSION_UI_COMMAND_LINE);
109 118
110 #if defined(OS_WIN) 119 #if defined(OS_WIN)
111 html_source->AddString( 120 html_source->AddString(
112 version_ui::kCommandLine, 121 version_ui::kCommandLine,
113 base::CommandLine::ForCurrentProcess()->GetCommandLineString()); 122 base::CommandLine::ForCurrentProcess()->GetCommandLineString());
114 #elif defined(OS_POSIX) 123 #elif defined(OS_POSIX)
115 std::string command_line; 124 std::string command_line;
116 typedef std::vector<std::string> ArgvList; 125 typedef std::vector<std::string> ArgvList;
117 const ArgvList& argv = base::CommandLine::ForCurrentProcess()->argv(); 126 const ArgvList& argv = base::CommandLine::ForCurrentProcess()->argv();
118 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++) 127 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
119 command_line += " " + *iter; 128 command_line += " " + *iter;
120 // TODO(viettrungluu): |command_line| could really have any encoding, whereas 129 // TODO(viettrungluu): |command_line| could really have any encoding, whereas
121 // below we assumes it's UTF-8. 130 // below we assumes it's UTF-8.
122 html_source->AddString(version_ui::kCommandLine, command_line); 131 html_source->AddString(version_ui::kCommandLine, command_line);
123 #endif 132 #endif
124 133
125 // Note that the executable path and profile path are retrieved asynchronously
126 // and returned in VersionHandler::OnGotFilePaths. The area is initially
127 // blank.
128 html_source->AddLocalizedString(version_ui::kExecutablePathName,
129 IDS_VERSION_UI_EXECUTABLE_PATH);
130 html_source->AddString(version_ui::kExecutablePath, std::string());
131
132 html_source->AddLocalizedString(version_ui::kProfilePathName,
133 IDS_VERSION_UI_PROFILE_PATH);
134 html_source->AddString(version_ui::kProfilePath, std::string());
135
136 html_source->AddLocalizedString(version_ui::kVariationsName,
137 IDS_VERSION_UI_VARIATIONS);
138
139 #if defined(OS_WIN) 134 #if defined(OS_WIN)
140 #if defined(__clang__) 135 #if defined(__clang__)
141 html_source->AddString("compiler", "clang"); 136 html_source->AddString(version_ui::kCompiler, "clang");
142 #elif defined(_MSC_VER) && _MSC_VER == 1900 137 #elif defined(_MSC_VER) && _MSC_VER == 1900
143 #if BUILDFLAG(PGO_BUILD) 138 #if BUILDFLAG(PGO_BUILD)
144 html_source->AddString("compiler", "MSVC 2015 (PGO)"); 139 html_source->AddString(version_ui::kCompiler, "MSVC 2015 (PGO)");
145 #else 140 #else
146 html_source->AddString("compiler", "MSVC 2015"); 141 html_source->AddString(version_ui::kCompiler, "MSVC 2015");
147 #endif 142 #endif
148 #elif defined(_MSC_VER) && _MSC_VER == 1910 143 #elif defined(_MSC_VER) && _MSC_VER == 1910
149 #if BUILDFLAG(PGO_BUILD) 144 #if BUILDFLAG(PGO_BUILD)
150 html_source->AddString("compiler", "MSVC 2017 (PGO)"); 145 html_source->AddString(version_ui::kCompiler, "MSVC 2017 (PGO)");
151 #else 146 #else
152 html_source->AddString("compiler", "MSVC 2017"); 147 html_source->AddString(version_ui::kCompiler, "MSVC 2017");
153 #endif 148 #endif
154 #elif defined(_MSC_VER) 149 #elif defined(_MSC_VER)
155 #error "Unsupported version of MSVC." 150 #error "Unsupported version of MSVC."
156 #else 151 #else
157 html_source->AddString("compiler", "Unknown"); 152 html_source->AddString(version_ui::kCompiler, "Unknown");
158 #endif 153 #endif
159 #endif // defined(OS_WIN) 154 #endif // defined(OS_WIN)
160 155
161 html_source->SetJsonPath("strings.js"); 156 html_source->SetJsonPath("strings.js");
162 html_source->AddResourcePath(version_ui::kVersionJS, IDR_VERSION_UI_JS); 157 html_source->AddResourcePath(version_ui::kVersionJS, IDR_VERSION_UI_JS);
163 html_source->AddResourcePath(version_ui::kAboutVersionCSS, 158 html_source->AddResourcePath(version_ui::kAboutVersionCSS,
164 IDR_VERSION_UI_CSS); 159 IDR_VERSION_UI_CSS);
165 html_source->SetDefaultResource(IDR_VERSION_UI_HTML); 160 html_source->SetDefaultResource(IDR_VERSION_UI_HTML);
166 return html_source; 161 return html_source;
167 } 162 }
(...skipping 14 matching lines...) Expand all
182 // Set up the chrome://theme/ source. 177 // Set up the chrome://theme/ source.
183 ThemeSource* theme = new ThemeSource(profile); 178 ThemeSource* theme = new ThemeSource(profile);
184 content::URLDataSource::Add(profile, theme); 179 content::URLDataSource::Add(profile, theme);
185 #endif 180 #endif
186 181
187 WebUIDataSource::Add(profile, CreateVersionUIDataSource()); 182 WebUIDataSource::Add(profile, CreateVersionUIDataSource());
188 } 183 }
189 184
190 VersionUI::~VersionUI() { 185 VersionUI::~VersionUI() {
191 } 186 }
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | components/version_ui/resources/about_version.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698