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

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: rebase + lei nit Created 8 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 | 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/ui/webui/version_handler_chromeos.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", version_info.Version());
45 {
46 // http://crbug.com/79458: Need to evaluate the use of getting the version
47 // string on this thread.
48 base::ThreadRestrictions::ScopedAllowIO allow_io;
49 html_source->AddString("version_modifier",
50 chrome::VersionInfo::GetVersionStringModifier());
51 }
52 html_source->AddLocalizedString("os_name", IDS_ABOUT_VERSION_OS);
53 html_source->AddLocalizedString("platform", IDS_PLATFORM_LABEL);
54 html_source->AddString("os_type", version_info.OSType());
55 html_source->AddString("os_version", std::string());
56 html_source->AddString("webkit_version", webkit_glue::GetWebKitVersion());
57 html_source->AddString("js_engine", "V8");
58 html_source->AddString("js_version", v8::V8::GetVersion());
59
60 #if !defined(OS_ANDROID)
61 html_source->AddString("flash_plugin", "Flash");
62 // Note that the Flash version is retrieve asynchronously and returned in
63 // VersionHandler::OnGotPlugins. The area is initially blank.
64 html_source->AddString("flash_version", std::string());
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", version_info.LastChange());
69 html_source->AddLocalizedString("official",
70 version_info.IsOfficialBuild() ? IDS_ABOUT_VERSION_OFFICIAL :
71 IDS_ABOUT_VERSION_UNOFFICIAL);
72 html_source->AddLocalizedString("user_agent_name",
73 IDS_ABOUT_VERSION_USER_AGENT);
74 html_source->AddString("useragent", content::GetUserAgent(GURL()));
75 html_source->AddLocalizedString("command_line_name",
76 IDS_ABOUT_VERSION_COMMAND_LINE);
77
78 #if defined(OS_WIN)
79 html_source->AddString("command_line",
80 WideToUTF16(CommandLine::ForCurrentProcess()->GetCommandLineString()));
81 #elif defined(OS_POSIX)
82 std::string command_line = "";
83 typedef std::vector<std::string> ArgvList;
84 const ArgvList& argv = CommandLine::ForCurrentProcess()->argv();
85 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
86 command_line += " " + *iter;
87 // TODO(viettrungluu): |command_line| could really have any encoding, whereas
88 // below we assumes it's UTF-8.
89 html_source->AddString("command_line", command_line);
90 #endif
91
92 // Note that the executable path and profile path are retrieved asynchronously
93 // and returned in VersionHandler::OnGotFilePaths. The area is initially
94 // blank.
95 html_source->AddLocalizedString("executable_path_name",
96 IDS_ABOUT_VERSION_EXECUTABLE_PATH);
97 html_source->AddString("executable_path", std::string());
98
99 html_source->AddLocalizedString("profile_path_name",
100 IDS_ABOUT_VERSION_PROFILE_PATH);
101 html_source->AddString("profile_path", std::string());
102
103 html_source->AddLocalizedString("variations_name",
104 IDS_ABOUT_VERSION_VARIATIONS);
105
106 html_source->set_use_json_js_format_v2();
107 html_source->set_json_path("strings.js");
108 html_source->add_resource_path("version.js", IDR_ABOUT_VERSION_JS);
109 html_source->set_default_resource(IDR_ABOUT_VERSION_HTML);
110 return html_source;
111 }
112
113 } // namespace
114
115 VersionUI::VersionUI(content::WebUI* web_ui)
116 : content::WebUIController(web_ui) {
117 Profile* profile = Profile::FromWebUI(web_ui);
118
119 #if defined(OS_CHROMEOS)
120 web_ui->AddMessageHandler(new VersionHandlerChromeOS());
121 #else
122 web_ui->AddMessageHandler(new VersionHandler());
123 #endif
124
125 #if defined(ENABLE_THEMES)
126 // Set up the chrome://theme/ source.
127 ThemeSource* theme = new ThemeSource(profile);
128 ChromeURLDataManager::AddDataSource(profile, theme);
129 #endif
130
131 ChromeURLDataManager::AddDataSource(profile,
132 CreateVersionUIDataSource(profile));
133 }
134
135 VersionUI::~VersionUI() {
136 }
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