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

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: Win fixes 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
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 namespace {
31
32 ChromeWebUIDataSource* CreateVersionUIDataSource(Profile* profile) {
33 ChromeWebUIDataSource* html_source =
34 new ChromeWebUIDataSource(chrome::kChromeUIVersionHost);
35
36 // Localized and data strings.
37 html_source->AddLocalizedString("title", IDS_ABOUT_VERSION_TITLE);
38 html_source->AddLocalizedString("name", IDS_PRODUCT_NAME);
39 chrome::VersionInfo version_info;
40 html_source->AddString("version", version_info.Version());
41 // http://crbug.com/79458: Need to evaluate the use of getting the version
42 // string on this thread.
43 base::ThreadRestrictions::ScopedAllowIO allow_io;
44 html_source->AddString("version_modifier",
45 chrome::VersionInfo::GetVersionStringModifier());
46 html_source->AddLocalizedString("os_name", IDS_ABOUT_VERSION_OS);
47 html_source->AddLocalizedString("platform", IDS_PLATFORM_LABEL);
48 html_source->AddString("os_type", version_info.OSType());
49 html_source->AddString("os_version", string16());
50 html_source->AddString("webkit_version", webkit_glue::GetWebKitVersion());
51 html_source->AddString("js_engine", "V8");
52 html_source->AddString("js_version", v8::V8::GetVersion());
53
54 #if !defined(OS_ANDROID)
55 html_source->AddString("flash_plugin", "Flash");
56 // Note that the Flash version is retrieve asynchronously and returned in
57 // VersionHandler::OnGotPlugins. The initial text is a loading message.
58 html_source->AddLocalizedString("flash_version",
59 IDS_ABOUT_VERSION_LOADING_MESSAGE);
60 #endif
61 html_source->AddLocalizedString("company", IDS_ABOUT_VERSION_COMPANY_NAME);
62 html_source->AddLocalizedString("copyright", IDS_ABOUT_VERSION_COPYRIGHT);
63 html_source->AddString("cl", version_info.LastChange());
64 html_source->AddLocalizedString("official",
65 version_info.IsOfficialBuild() ? IDS_ABOUT_VERSION_OFFICIAL :
66 IDS_ABOUT_VERSION_UNOFFICIAL);
67 html_source->AddLocalizedString("user_agent_name",
68 IDS_ABOUT_VERSION_USER_AGENT);
69 html_source->AddString("useragent", content::GetUserAgent(GURL()));
70 html_source->AddLocalizedString("command_line_name",
71 IDS_ABOUT_VERSION_COMMAND_LINE);
72
73 #if defined(OS_WIN)
74 html_source->AddString("command_line",
75 WideToUTF16(CommandLine::ForCurrentProcess()->GetCommandLineString()));
76 #elif defined(OS_POSIX)
77 std::string command_line = "";
78 typedef std::vector<std::string> ArgvList;
79 const ArgvList& argv = CommandLine::ForCurrentProcess()->argv();
80 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
81 command_line += " " + *iter;
82 // TODO(viettrungluu): |command_line| could really have any encoding, whereas
83 // below we assumes it's UTF-8.
84 html_source->AddString("command_line", command_line);
85 #endif
86
87 // Note that the executable path and profile path are retrieved asynchronously
88 // and returned in VersionHandler::OnGotFilePaths. The initial text is a
89 // loading message.
90 html_source->AddLocalizedString("executable_path_name",
91 IDS_ABOUT_VERSION_EXECUTABLE_PATH);
92 html_source->AddLocalizedString("executable_path",
93 IDS_ABOUT_VERSION_LOADING_MESSAGE);
94
95 html_source->AddLocalizedString("profile_path_name",
96 IDS_ABOUT_VERSION_PROFILE_PATH);
97 html_source->AddLocalizedString("profile_path",
98 IDS_ABOUT_VERSION_LOADING_MESSAGE);
Evan Stade 2012/09/14 09:18:02 hmmm... I don't think these loading messages are a
SteveT 2012/09/14 14:48:15 Sure. I've set a reminder to log the bug as soon a
99
100 #if !defined(NDEBUG)
101 html_source->AddLocalizedString("variations_name",
102 IDS_ABOUT_VERSION_VARIATIONS);
103 #endif
104 html_source->set_use_json_js_format_v2();
105 html_source->set_json_path("strings.js");
106 html_source->add_resource_path("version.js", IDR_ABOUT_VERSION_JS);
107 html_source->set_default_resource(IDR_ABOUT_VERSION_HTML);
108 return html_source;
109 }
110
111 } // namespace
112
113 VersionUI::VersionUI(content::WebUI* web_ui)
114 : content::WebUIController(web_ui) {
115 Profile* profile = Profile::FromWebUI(web_ui);
116
117 web_ui->AddMessageHandler(new VersionHandler());
118
119 #if defined(ENABLE_THEMES)
120 // Set up the chrome://theme/ source.
121 ThemeSource* theme = new ThemeSource(profile);
122 ChromeURLDataManager::AddDataSource(profile, theme);
123 #endif
124
125 ChromeURLDataManager::AddDataSource(profile,
126 CreateVersionUIDataSource(profile));
127 }
128
129 VersionUI::~VersionUI() {
130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698