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

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

Issue 10916182: Refactor the about:version code out of about_ui. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressed estade comments Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/version_ui.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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.
4
5 #include "chrome/browser/ui/webui/version_ui.h"
6
7 #include "base/command_line.h"
8 #include "base/file_util.h"
9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
12 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
13 #include "chrome/browser/ui/webui/version_handler.h"
14 #include "chrome/common/chrome_version_info.h"
15 #include "chrome/common/jstemplate_builder.h"
16 #include "chrome/common/url_constants.h"
17 #include "content/public/browser/web_ui.h"
18 #include "content/public/common/content_client.h"
19 #include "grit/browser_resources.h"
20 #include "grit/chromium_strings.h"
21 #include "grit/generated_resources.h"
22 #include "grit/google_chrome_strings.h"
23 #include "v8/include/v8.h"
24 #include "webkit/user_agent/user_agent_util.h"
25
26 #if defined(ENABLE_THEMES)
27 #include "chrome/browser/ui/webui/theme_source.h"
28 #endif
29
30 #if defined(OS_CHROMEOS)
31 #include "chrome/browser/chromeos/version_loader.h"
32 #endif
33
34 namespace {
35
36 ChromeWebUIDataSource* CreateVersionUIDataSource(Profile* profile) {
37 ChromeWebUIDataSource* html_source =
38 new ChromeWebUIDataSource(chrome::kChromeUIVersionHost);
39
40 // Localized and data strings.
41 html_source->AddLocalizedString("title", IDS_ABOUT_VERSION_TITLE);
42 html_source->AddLocalizedString("name", IDS_PRODUCT_NAME);
43 chrome::VersionInfo version_info;
44 html_source->AddString("version", ASCIIToUTF16(version_info.Version()));
45 // http://crbug.com/79458: Need to evaluate the use of getting the version
46 // string on this thread.
47 base::ThreadRestrictions::ScopedAllowIO allow_io;
48 html_source->AddString("version_modifier",
49 ASCIIToUTF16(chrome::VersionInfo::GetVersionStringModifier()));
50 html_source->AddLocalizedString("os_name", IDS_ABOUT_VERSION_OS);
51 html_source->AddLocalizedString("platform", IDS_PLATFORM_LABEL);
52 html_source->AddString("os_type", ASCIIToUTF16(version_info.OSType()));
53 html_source->AddString("os_version", string16());
54 html_source->AddString("webkit_version",
55 ASCIIToUTF16(webkit_glue::GetWebKitVersion()));
56 html_source->AddString("js_engine", ASCIIToUTF16("V8"));
Evan Stade 2012/09/13 15:23:27 please remove all unnecessary string16 conversions
SteveT 2012/09/13 15:41:27 Done.
57 html_source->AddString("js_version", ASCIIToUTF16(v8::V8::GetVersion()));
58
59 #if !defined(OS_ANDROID)
60 html_source->AddString("flash_plugin", ASCIIToUTF16("Flash"));
61 // Note that the Flash version is retrieve asynchronously and returned in
62 // VersionHandler::OnGotPlugins. The initial text is a loading message.
63 html_source->AddLocalizedString("flash_version",
64 IDS_ABOUT_VERSION_LOADING_MESSAGE);
65 #endif
66 html_source->AddLocalizedString("company", IDS_ABOUT_VERSION_COMPANY_NAME);
67 html_source->AddLocalizedString("copyright", IDS_ABOUT_VERSION_COPYRIGHT);
68 html_source->AddString("cl", ASCIIToUTF16(version_info.LastChange()));
69 html_source->AddLocalizedString("official",
70 version_info.IsOfficialBuild() ?
71 IDS_ABOUT_VERSION_OFFICIAL
72 : IDS_ABOUT_VERSION_UNOFFICIAL);
Evan Stade 2012/09/13 15:23:27 operands go at end of line
SteveT 2012/09/13 15:41:27 Not sure what you mean here. Did you mean: versio
Evan Stade 2012/09/13 16:05:47 sorry, meant operators
SteveT 2012/09/13 17:00:26 Done.
73 html_source->AddLocalizedString("user_agent_name",
74 IDS_ABOUT_VERSION_USER_AGENT);
75 html_source->AddString("useragent",
76 ASCIIToUTF16(content::GetUserAgent(GURL())));
77 html_source->AddLocalizedString("command_line_name",
78 IDS_ABOUT_VERSION_COMMAND_LINE);
79
80 #if defined(OS_WIN)
81 html_source->AddString("command_line",
82 WideToUTF16(CommandLine::ForCurrentProcess()->GetCommandLineString()));
83 #elif defined(OS_POSIX)
84 std::string command_line = "";
85 typedef std::vector<std::string> ArgvList;
86 const ArgvList& argv = CommandLine::ForCurrentProcess()->argv();
87 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
88 command_line += " " + *iter;
89 // TODO(viettrungluu): |command_line| could really have any encoding, whereas
90 // below we assumes it's UTF-8.
91 html_source->AddString("command_line", command_line);
92 #endif
93
94 // Note that the executable path is retrieved asynchronously and returned in
95 // VersionHandler::OnGotExecutablePath. The initial text is a loading message.
96 html_source->AddLocalizedString("executable_path_name",
97 IDS_ABOUT_VERSION_EXECUTABLE_PATH);
98 html_source->AddLocalizedString("executable_path",
99 IDS_ABOUT_VERSION_LOADING_MESSAGE);
100
101 html_source->AddLocalizedString("profile_path_name",
102 IDS_ABOUT_VERSION_PROFILE_PATH);
103 if (profile) {
104 FilePath profile_path = profile->GetPath();
105 if (file_util::AbsolutePath(&profile_path))
Evan Stade 2012/09/13 15:23:27 curlies
Evan Stade 2012/09/13 15:23:27 file_util::AbsolutePath does file access, does it
SteveT 2012/09/13 15:41:27 Done.
SteveT 2012/09/13 15:41:27 According to this, no: http://code.google.com/sear
Evan Stade 2012/09/13 16:05:47 yet: http://code.google.com/searchframe#OAMlx_jo-c
SteveT 2012/09/13 17:00:26 D'oh. Fixed by making this bit async as well.
106 html_source->AddString("profile_path",
107 ASCIIToUTF16(profile_path.value()));
108 else
Evan Stade 2012/09/13 15:23:27 curlies
SteveT 2012/09/13 15:41:27 Done.
109 html_source->AddLocalizedString("profile_path",
110 IDS_ABOUT_VERSION_PATH_NOTFOUND);
111 } else {
112 html_source->AddLocalizedString("profile_path",
113 IDS_ABOUT_VERSION_PATH_NOTFOUND);
114 }
115
116 #if !defined(NDEBUG)
117 html_source->AddLocalizedString("variations_name",
118 IDS_ABOUT_VERSION_VARIATIONS);
119 #endif
120 html_source->set_use_json_js_format_v2();
121 html_source->set_json_path("strings.js");
122 html_source->add_resource_path("version.js", IDR_ABOUT_VERSION_JS);
123 html_source->set_default_resource(IDR_ABOUT_VERSION_HTML);
124 return html_source;
125 }
126
127 } // namespace
128
129 VersionUI::VersionUI(content::WebUI* web_ui)
130 : content::WebUIController(web_ui) {
131 Profile* profile = Profile::FromWebUI(web_ui);
132
133 web_ui->AddMessageHandler(new VersionHandler());
134
135 #if defined(ENABLE_THEMES)
136 // Set up the chrome://theme/ source.
137 ThemeSource* theme = new ThemeSource(profile);
138 ChromeURLDataManager::AddDataSource(profile, theme);
139 #endif
140
141 ChromeURLDataManager::AddDataSource(profile,
142 CreateVersionUIDataSource(profile));
143 }
144
145 VersionUI::~VersionUI() {
146 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/version_ui.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698