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

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: more estade changes 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 #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 // 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 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", version_info.OSType());
53 html_source->AddString("os_version", string16());
Evan Stade 2012/09/14 15:11:30 for blank strings (where it doesn't matter either
SteveT 2012/09/14 15:28:37 Done.
54 html_source->AddString("webkit_version", webkit_glue::GetWebKitVersion());
55 html_source->AddString("js_engine", "V8");
56 html_source->AddString("js_version", v8::V8::GetVersion());
57
58 #if !defined(OS_ANDROID)
59 html_source->AddString("flash_plugin", "Flash");
60 // Note that the Flash version is retrieve asynchronously and returned in
61 // VersionHandler::OnGotPlugins. The area is initially blank.
62 html_source->AddString("flash_version", string16());
63 #endif
64 html_source->AddLocalizedString("company", IDS_ABOUT_VERSION_COMPANY_NAME);
65 html_source->AddLocalizedString("copyright", IDS_ABOUT_VERSION_COPYRIGHT);
66 html_source->AddString("cl", version_info.LastChange());
67 html_source->AddLocalizedString("official",
68 version_info.IsOfficialBuild() ? IDS_ABOUT_VERSION_OFFICIAL :
69 IDS_ABOUT_VERSION_UNOFFICIAL);
70 html_source->AddLocalizedString("user_agent_name",
71 IDS_ABOUT_VERSION_USER_AGENT);
72 html_source->AddString("useragent", content::GetUserAgent(GURL()));
73 html_source->AddLocalizedString("command_line_name",
74 IDS_ABOUT_VERSION_COMMAND_LINE);
75
76 #if defined(OS_WIN)
77 html_source->AddString("command_line",
78 WideToUTF16(CommandLine::ForCurrentProcess()->GetCommandLineString()));
79 #elif defined(OS_POSIX)
80 std::string command_line = "";
81 typedef std::vector<std::string> ArgvList;
82 const ArgvList& argv = CommandLine::ForCurrentProcess()->argv();
83 for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
84 command_line += " " + *iter;
85 // TODO(viettrungluu): |command_line| could really have any encoding, whereas
86 // below we assumes it's UTF-8.
87 html_source->AddString("command_line", command_line);
88 #endif
89
90 // Note that the executable path and profile path are retrieved asynchronously
91 // and returned in VersionHandler::OnGotFilePaths. The area is initially
92 // blank.
93 html_source->AddLocalizedString("executable_path_name",
94 IDS_ABOUT_VERSION_EXECUTABLE_PATH);
95 html_source->AddString("executable_path", string16());
96
97 html_source->AddLocalizedString("profile_path_name",
98 IDS_ABOUT_VERSION_PROFILE_PATH);
99 html_source->AddString("profile_path", string16());
100
101 #if !defined(NDEBUG)
102 html_source->AddLocalizedString("variations_name",
103 IDS_ABOUT_VERSION_VARIATIONS);
104 #endif
105 html_source->set_use_json_js_format_v2();
106 html_source->set_json_path("strings.js");
107 html_source->add_resource_path("version.js", IDR_ABOUT_VERSION_JS);
108 html_source->set_default_resource(IDR_ABOUT_VERSION_HTML);
109 return html_source;
110 }
111
112 } // namespace
113
114 VersionUI::VersionUI(content::WebUI* web_ui)
115 : content::WebUIController(web_ui) {
116 Profile* profile = Profile::FromWebUI(web_ui);
117
118 #if defined(OS_CHROMEOS)
119 web_ui->AddMessageHandler(new VersionHandlerChromeOS());
120 #else
121 web_ui->AddMessageHandler(new VersionHandler());
122 #endif
123
124 #if defined(ENABLE_THEMES)
125 // Set up the chrome://theme/ source.
126 ThemeSource* theme = new ThemeSource(profile);
127 ChromeURLDataManager::AddDataSource(profile, theme);
128 #endif
129
130 ChromeURLDataManager::AddDataSource(profile,
131 CreateVersionUIDataSource(profile));
132 }
133
134 VersionUI::~VersionUI() {
135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698