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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/version_ui.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/version_ui.cc
===================================================================
--- chrome/browser/ui/webui/version_ui.cc (revision 0)
+++ chrome/browser/ui/webui/version_ui.cc (revision 0)
@@ -0,0 +1,146 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/version_ui.h"
+
+#include "base/command_line.h"
+#include "base/file_util.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
+#include "chrome/browser/ui/webui/version_handler.h"
+#include "chrome/common/chrome_version_info.h"
+#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/common/content_client.h"
+#include "grit/browser_resources.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "grit/google_chrome_strings.h"
+#include "v8/include/v8.h"
+#include "webkit/user_agent/user_agent_util.h"
+
+#if defined(ENABLE_THEMES)
+#include "chrome/browser/ui/webui/theme_source.h"
+#endif
+
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/version_loader.h"
+#endif
+
+namespace {
+
+ChromeWebUIDataSource* CreateVersionUIDataSource(Profile* profile) {
+ ChromeWebUIDataSource* html_source =
+ new ChromeWebUIDataSource(chrome::kChromeUIVersionHost);
+
+ // Localized and data strings.
+ html_source->AddLocalizedString("title", IDS_ABOUT_VERSION_TITLE);
+ html_source->AddLocalizedString("name", IDS_PRODUCT_NAME);
+ chrome::VersionInfo version_info;
+ html_source->AddString("version", ASCIIToUTF16(version_info.Version()));
+ // http://crbug.com/79458: Need to evaluate the use of getting the version
+ // string on this thread.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ html_source->AddString("version_modifier",
+ ASCIIToUTF16(chrome::VersionInfo::GetVersionStringModifier()));
+ html_source->AddLocalizedString("os_name", IDS_ABOUT_VERSION_OS);
+ html_source->AddLocalizedString("platform", IDS_PLATFORM_LABEL);
+ html_source->AddString("os_type", ASCIIToUTF16(version_info.OSType()));
+ html_source->AddString("os_version", string16());
+ html_source->AddString("webkit_version",
+ ASCIIToUTF16(webkit_glue::GetWebKitVersion()));
+ 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.
+ html_source->AddString("js_version", ASCIIToUTF16(v8::V8::GetVersion()));
+
+#if !defined(OS_ANDROID)
+ html_source->AddString("flash_plugin", ASCIIToUTF16("Flash"));
+ // Note that the Flash version is retrieve asynchronously and returned in
+ // VersionHandler::OnGotPlugins. The initial text is a loading message.
+ html_source->AddLocalizedString("flash_version",
+ IDS_ABOUT_VERSION_LOADING_MESSAGE);
+#endif
+ html_source->AddLocalizedString("company", IDS_ABOUT_VERSION_COMPANY_NAME);
+ html_source->AddLocalizedString("copyright", IDS_ABOUT_VERSION_COPYRIGHT);
+ html_source->AddString("cl", ASCIIToUTF16(version_info.LastChange()));
+ html_source->AddLocalizedString("official",
+ version_info.IsOfficialBuild() ?
+ IDS_ABOUT_VERSION_OFFICIAL
+ : 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.
+ html_source->AddLocalizedString("user_agent_name",
+ IDS_ABOUT_VERSION_USER_AGENT);
+ html_source->AddString("useragent",
+ ASCIIToUTF16(content::GetUserAgent(GURL())));
+ html_source->AddLocalizedString("command_line_name",
+ IDS_ABOUT_VERSION_COMMAND_LINE);
+
+#if defined(OS_WIN)
+ html_source->AddString("command_line",
+ WideToUTF16(CommandLine::ForCurrentProcess()->GetCommandLineString()));
+#elif defined(OS_POSIX)
+ std::string command_line = "";
+ typedef std::vector<std::string> ArgvList;
+ const ArgvList& argv = CommandLine::ForCurrentProcess()->argv();
+ for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
+ command_line += " " + *iter;
+ // TODO(viettrungluu): |command_line| could really have any encoding, whereas
+ // below we assumes it's UTF-8.
+ html_source->AddString("command_line", command_line);
+#endif
+
+ // Note that the executable path is retrieved asynchronously and returned in
+ // VersionHandler::OnGotExecutablePath. The initial text is a loading message.
+ html_source->AddLocalizedString("executable_path_name",
+ IDS_ABOUT_VERSION_EXECUTABLE_PATH);
+ html_source->AddLocalizedString("executable_path",
+ IDS_ABOUT_VERSION_LOADING_MESSAGE);
+
+ html_source->AddLocalizedString("profile_path_name",
+ IDS_ABOUT_VERSION_PROFILE_PATH);
+ if (profile) {
+ FilePath profile_path = profile->GetPath();
+ 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.
+ html_source->AddString("profile_path",
+ ASCIIToUTF16(profile_path.value()));
+ else
Evan Stade 2012/09/13 15:23:27 curlies
SteveT 2012/09/13 15:41:27 Done.
+ html_source->AddLocalizedString("profile_path",
+ IDS_ABOUT_VERSION_PATH_NOTFOUND);
+ } else {
+ html_source->AddLocalizedString("profile_path",
+ IDS_ABOUT_VERSION_PATH_NOTFOUND);
+ }
+
+#if !defined(NDEBUG)
+ html_source->AddLocalizedString("variations_name",
+ IDS_ABOUT_VERSION_VARIATIONS);
+#endif
+ html_source->set_use_json_js_format_v2();
+ html_source->set_json_path("strings.js");
+ html_source->add_resource_path("version.js", IDR_ABOUT_VERSION_JS);
+ html_source->set_default_resource(IDR_ABOUT_VERSION_HTML);
+ return html_source;
+}
+
+} // namespace
+
+VersionUI::VersionUI(content::WebUI* web_ui)
+ : content::WebUIController(web_ui) {
+ Profile* profile = Profile::FromWebUI(web_ui);
+
+ web_ui->AddMessageHandler(new VersionHandler());
+
+#if defined(ENABLE_THEMES)
+ // Set up the chrome://theme/ source.
+ ThemeSource* theme = new ThemeSource(profile);
+ ChromeURLDataManager::AddDataSource(profile, theme);
+#endif
+
+ ChromeURLDataManager::AddDataSource(profile,
+ CreateVersionUIDataSource(profile));
+}
+
+VersionUI::~VersionUI() {
+}
Property changes on: chrome/browser/ui/webui/version_ui.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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