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

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

Issue 1332353003: Move resources for version_ui to //components/version_ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 5 years, 2 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/browser/ui/webui/version_handler.cc ('k') | chrome/browser/ui/webui/voice_search_ui.cc » ('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/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"
11 #include "chrome/common/channel_info.h" 11 #include "chrome/common/channel_info.h"
12 #include "chrome/common/chrome_content_client.h" 12 #include "chrome/common/chrome_content_client.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "chrome/grit/chromium_strings.h" 14 #include "chrome/grit/chromium_strings.h"
15 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "components/version_info/version_info.h" 16 #include "components/version_info/version_info.h"
17 #include "components/version_ui/version_ui_constants.h"
17 #include "content/public/browser/url_data_source.h" 18 #include "content/public/browser/url_data_source.h"
18 #include "content/public/browser/web_ui.h" 19 #include "content/public/browser/web_ui.h"
19 #include "content/public/browser/web_ui_data_source.h" 20 #include "content/public/browser/web_ui_data_source.h"
20 #include "content/public/common/user_agent.h" 21 #include "content/public/common/user_agent.h"
21 #include "grit/browser_resources.h" 22 #include "grit/browser_resources.h"
23 #include "grit/components_chromium_strings.h"
24 #include "grit/components_google_chrome_strings.h"
25 #include "grit/components_resources.h"
22 #include "grit/components_strings.h" 26 #include "grit/components_strings.h"
23 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
24 #include "v8/include/v8.h" 28 #include "v8/include/v8.h"
25 29
26 #if defined(ENABLE_THEMES) 30 #if defined(ENABLE_THEMES)
27 #include "chrome/browser/ui/webui/theme_source.h" 31 #include "chrome/browser/ui/webui/theme_source.h"
28 #endif 32 #endif
29 33
30 #if defined(OS_ANDROID) 34 #if defined(OS_ANDROID)
31 #include "base/android/build_info.h" 35 #include "base/android/build_info.h"
32 #include "chrome/browser/ui/android/android_about_app_info.h" 36 #include "chrome/browser/ui/android/android_about_app_info.h"
33 #endif 37 #endif
34 38
35 #if defined(OS_CHROMEOS) 39 #if defined(OS_CHROMEOS)
36 #include "chrome/browser/ui/webui/version_handler_chromeos.h" 40 #include "chrome/browser/ui/webui/version_handler_chromeos.h"
37 #endif 41 #endif
38 42
39 using content::WebUIDataSource; 43 using content::WebUIDataSource;
40 44
41 namespace { 45 namespace {
42 46
43 WebUIDataSource* CreateVersionUIDataSource() { 47 WebUIDataSource* CreateVersionUIDataSource() {
44 WebUIDataSource* html_source = 48 WebUIDataSource* html_source =
45 WebUIDataSource::Create(chrome::kChromeUIVersionHost); 49 WebUIDataSource::Create(chrome::kChromeUIVersionHost);
46 50
47 // Localized and data strings. 51 // Localized and data strings.
48 html_source->AddLocalizedString("title", IDS_ABOUT_VERSION_TITLE); 52 html_source->AddLocalizedString(version_ui::kTitle, IDS_VERSION_UI_TITLE);
49 html_source->AddLocalizedString("application_label", IDS_PRODUCT_NAME); 53 html_source->AddLocalizedString(version_ui::kApplicationLabel,
50 html_source->AddString("version", version_info::GetVersionNumber()); 54 IDS_PRODUCT_NAME);
51 html_source->AddString("version_modifier", chrome::GetChannelString()); 55 html_source->AddString(version_ui::kVersion,
52 html_source->AddLocalizedString("os_name", IDS_ABOUT_VERSION_OS); 56 version_info::GetVersionNumber());
53 html_source->AddLocalizedString("platform", IDS_PLATFORM_LABEL); 57 html_source->AddString(version_ui::kVersionModifier,
54 html_source->AddString("os_type", version_info::GetOSType()); 58 chrome::GetChannelString());
55 html_source->AddString("blink_version", content::GetWebKitVersion()); 59 html_source->AddLocalizedString(version_ui::kOSName, IDS_VERSION_UI_OS);
56 html_source->AddString("js_engine", "V8"); 60 html_source->AddLocalizedString(version_ui::kPlatform, IDS_PLATFORM_LABEL);
57 html_source->AddString("js_version", v8::V8::GetVersion()); 61 html_source->AddString(version_ui::kOSType, version_info::GetOSType());
62 html_source->AddString(version_ui::kBlinkVersion,
63 content::GetWebKitVersion());
64 html_source->AddString(version_ui::kJSEngine, "V8");
65 html_source->AddString(version_ui::kJSVersion, v8::V8::GetVersion());
58 66
59 #if defined(OS_ANDROID) 67 #if defined(OS_ANDROID)
60 html_source->AddString("os_version", AndroidAboutAppInfo::GetOsInfo()); 68 html_source->AddString(version_ui::kOSVersion,
61 html_source->AddLocalizedString("build_id_name", 69 AndroidAboutAppInfo::GetOsInfo());
62 IDS_ABOUT_VERSION_BUILD_ID); 70 html_source->AddLocalizedString(version_ui::kBuildIDName,
63 html_source->AddString("build_id", CHROME_BUILD_ID); 71 IDS_VERSION_UI_BUILD_ID);
72 html_source->AddString(version_ui::kBuildID, CHROME_BUILD_ID);
64 #else 73 #else
65 html_source->AddString("os_version", std::string()); 74 html_source->AddString(version_ui::kOSVersion, std::string());
66 html_source->AddString("flash_plugin", "Flash"); 75 html_source->AddString(version_ui::kFlashPlugin, "Flash");
67 // Note that the Flash version is retrieve asynchronously and returned in 76 // Note that the Flash version is retrieve asynchronously and returned in
68 // VersionHandler::OnGotPlugins. The area is initially blank. 77 // VersionHandler::OnGotPlugins. The area is initially blank.
69 html_source->AddString("flash_version", std::string()); 78 html_source->AddString(version_ui::kFlashVersion, std::string());
70 #endif // defined(OS_ANDROID) 79 #endif // defined(OS_ANDROID)
71 80
72 html_source->AddLocalizedString("company", IDS_ABOUT_VERSION_COMPANY_NAME); 81 html_source->AddLocalizedString(version_ui::kCompany,
82 IDS_ABOUT_VERSION_COMPANY_NAME);
73 base::Time::Exploded exploded_time; 83 base::Time::Exploded exploded_time;
74 base::Time::Now().LocalExplode(&exploded_time); 84 base::Time::Now().LocalExplode(&exploded_time);
75 html_source->AddString( 85 html_source->AddString(
76 "copyright", 86 version_ui::kCopyright,
77 l10n_util::GetStringFUTF16(IDS_ABOUT_VERSION_COPYRIGHT, 87 l10n_util::GetStringFUTF16(IDS_ABOUT_VERSION_COPYRIGHT,
78 base::IntToString16(exploded_time.year))); 88 base::IntToString16(exploded_time.year)));
79 html_source->AddLocalizedString("revision", IDS_ABOUT_VERSION_REVISION); 89 html_source->AddLocalizedString(version_ui::kRevision,
80 html_source->AddString("cl", version_info::GetLastChange()); 90 IDS_VERSION_UI_REVISION);
81 html_source->AddLocalizedString("official", 91 html_source->AddString(version_ui::kCL, version_info::GetLastChange());
92 html_source->AddLocalizedString(version_ui::kOfficial,
82 version_info::IsOfficialBuild() 93 version_info::IsOfficialBuild()
83 ? IDS_ABOUT_VERSION_OFFICIAL 94 ? IDS_VERSION_UI_OFFICIAL
84 : IDS_ABOUT_VERSION_UNOFFICIAL); 95 : IDS_VERSION_UI_UNOFFICIAL);
85 #if defined(ARCH_CPU_64_BITS) 96 #if defined(ARCH_CPU_64_BITS)
86 html_source->AddLocalizedString("version_bitsize", IDS_ABOUT_VERSION_64BIT); 97 html_source->AddLocalizedString(version_ui::kVersionBitSize,
98 IDS_VERSION_UI_64BIT);
87 #else 99 #else
88 html_source->AddLocalizedString("version_bitsize", IDS_ABOUT_VERSION_32BIT); 100 html_source->AddLocalizedString(version_ui::kVersionBitSize,
101 IDS_VERSION_UI_32BIT);
89 #endif 102 #endif
90 html_source->AddLocalizedString("user_agent_name", 103 html_source->AddLocalizedString(version_ui::kUserAgentName,
91 IDS_ABOUT_VERSION_USER_AGENT); 104 IDS_VERSION_UI_USER_AGENT);
92 html_source->AddString("useragent", GetUserAgent()); 105 html_source->AddString(version_ui::kUserAgent, GetUserAgent());
93 html_source->AddLocalizedString("command_line_name", 106 html_source->AddLocalizedString(version_ui::kCommandLineName,
94 IDS_ABOUT_VERSION_COMMAND_LINE); 107 IDS_VERSION_UI_COMMAND_LINE);
95 108
96 #if defined(OS_WIN) 109 #if defined(OS_WIN)
97 html_source->AddString( 110 html_source->AddString(
98 "command_line", 111 version_ui::kCommandLine,
99 base::CommandLine::ForCurrentProcess()->GetCommandLineString()); 112 base::CommandLine::ForCurrentProcess()->GetCommandLineString());
100 #elif defined(OS_POSIX) 113 #elif defined(OS_POSIX)
101 std::string command_line; 114 std::string command_line;
102 typedef std::vector<std::string> ArgvList; 115 typedef std::vector<std::string> ArgvList;
103 const ArgvList& argv = base::CommandLine::ForCurrentProcess()->argv(); 116 const ArgvList& argv = base::CommandLine::ForCurrentProcess()->argv();
104 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++) 117 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
105 command_line += " " + *iter; 118 command_line += " " + *iter;
106 // TODO(viettrungluu): |command_line| could really have any encoding, whereas 119 // TODO(viettrungluu): |command_line| could really have any encoding, whereas
107 // below we assumes it's UTF-8. 120 // below we assumes it's UTF-8.
108 html_source->AddString("command_line", command_line); 121 html_source->AddString(version_ui::kCommandLine, command_line);
109 #endif 122 #endif
110 123
111 // Note that the executable path and profile path are retrieved asynchronously 124 // Note that the executable path and profile path are retrieved asynchronously
112 // and returned in VersionHandler::OnGotFilePaths. The area is initially 125 // and returned in VersionHandler::OnGotFilePaths. The area is initially
113 // blank. 126 // blank.
114 html_source->AddLocalizedString("executable_path_name", 127 html_source->AddLocalizedString(version_ui::kExecutablePathName,
115 IDS_ABOUT_VERSION_EXECUTABLE_PATH); 128 IDS_VERSION_UI_EXECUTABLE_PATH);
116 html_source->AddString("executable_path", std::string()); 129 html_source->AddString(version_ui::kExecutablePath, std::string());
117 130
118 html_source->AddLocalizedString("profile_path_name", 131 html_source->AddLocalizedString(version_ui::kProfilePathName,
119 IDS_ABOUT_VERSION_PROFILE_PATH); 132 IDS_VERSION_UI_PROFILE_PATH);
120 html_source->AddString("profile_path", std::string()); 133 html_source->AddString(version_ui::kProfilePath, std::string());
121 134
122 html_source->AddLocalizedString("variations_name", 135 html_source->AddLocalizedString(version_ui::kVariationsName,
123 IDS_ABOUT_VERSION_VARIATIONS); 136 IDS_VERSION_UI_VARIATIONS);
124 137
125 #if defined(OS_WIN) 138 #if defined(OS_WIN)
126 #if defined(__clang__) 139 #if defined(__clang__)
127 html_source->AddString("compiler", "clang"); 140 html_source->AddString("compiler", "clang");
128 #else 141 #else
129 html_source->AddString("compiler", "MSVC"); 142 html_source->AddString("compiler", "MSVC");
130 #endif 143 #endif
131 #endif 144 #endif
132 145
133 html_source->SetJsonPath("strings.js"); 146 html_source->SetJsonPath("strings.js");
134 html_source->AddResourcePath("version.js", IDR_ABOUT_VERSION_JS); 147 html_source->AddResourcePath(version_ui::kVersionJS, IDR_VERSION_UI_JS);
135 html_source->AddResourcePath("about_version.css", IDR_ABOUT_VERSION_CSS); 148 html_source->AddResourcePath(version_ui::kAboutVersionCSS,
136 html_source->SetDefaultResource(IDR_ABOUT_VERSION_HTML); 149 IDR_VERSION_UI_CSS);
150 html_source->SetDefaultResource(IDR_VERSION_UI_HTML);
137 return html_source; 151 return html_source;
138 } 152 }
139 153
140 } // namespace 154 } // namespace
141 155
142 VersionUI::VersionUI(content::WebUI* web_ui) 156 VersionUI::VersionUI(content::WebUI* web_ui)
143 : content::WebUIController(web_ui) { 157 : content::WebUIController(web_ui) {
144 Profile* profile = Profile::FromWebUI(web_ui); 158 Profile* profile = Profile::FromWebUI(web_ui);
145 159
146 #if defined(OS_CHROMEOS) 160 #if defined(OS_CHROMEOS)
147 web_ui->AddMessageHandler(new VersionHandlerChromeOS()); 161 web_ui->AddMessageHandler(new VersionHandlerChromeOS());
148 #else 162 #else
149 web_ui->AddMessageHandler(new VersionHandler()); 163 web_ui->AddMessageHandler(new VersionHandler());
150 #endif 164 #endif
151 165
152 #if defined(ENABLE_THEMES) 166 #if defined(ENABLE_THEMES)
153 // Set up the chrome://theme/ source. 167 // Set up the chrome://theme/ source.
154 ThemeSource* theme = new ThemeSource(profile); 168 ThemeSource* theme = new ThemeSource(profile);
155 content::URLDataSource::Add(profile, theme); 169 content::URLDataSource::Add(profile, theme);
156 #endif 170 #endif
157 171
158 WebUIDataSource::Add(profile, CreateVersionUIDataSource()); 172 WebUIDataSource::Add(profile, CreateVersionUIDataSource());
159 } 173 }
160 174
161 VersionUI::~VersionUI() { 175 VersionUI::~VersionUI() {
162 } 176 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/version_handler.cc ('k') | chrome/browser/ui/webui/voice_search_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698