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

Side by Side Diff: chrome/browser/ui/webui/help/help_handler.cc

Issue 10038034: Implemented a "Last Updated" field for the about page of Chrome OS. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated comments, code style, etc. Created 8 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/help/help_handler.h" 5 #include "chrome/browser/ui/webui/help/help_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "grit/chromium_strings.h" 27 #include "grit/chromium_strings.h"
28 #include "grit/generated_resources.h" 28 #include "grit/generated_resources.h"
29 #include "grit/google_chrome_strings.h" 29 #include "grit/google_chrome_strings.h"
30 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
31 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
32 #include "v8/include/v8.h" 32 #include "v8/include/v8.h"
33 #include "webkit/glue/user_agent.h" 33 #include "webkit/glue/user_agent.h"
34 #include "webkit/glue/webkit_glue.h" 34 #include "webkit/glue/webkit_glue.h"
35 35
36 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
37 #include "base/i18n/time_formatting.h"
38 #include "base/sys_info.h"
37 #include "chrome/browser/chromeos/login/user_manager.h" 39 #include "chrome/browser/chromeos/login/user_manager.h"
38 #include "chrome/browser/chromeos/cros_settings.h" 40 #include "chrome/browser/chromeos/cros_settings.h"
39 #include "chrome/browser/profiles/profile.h" 41 #include "chrome/browser/profiles/profile.h"
40 #include "chrome/browser/prefs/pref_service.h" 42 #include "chrome/browser/prefs/pref_service.h"
41 #endif 43 #endif
42 44
43 using base::ListValue; 45 using base::ListValue;
44 46
45 namespace { 47 namespace {
46 48
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); 85 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email();
84 size_t at_pos = user.find('@'); 86 size_t at_pos = user.find('@');
85 if (at_pos != std::string::npos && at_pos + 1 < user.length()) 87 if (at_pos != std::string::npos && at_pos + 1 < user.length())
86 domain = user.substr(user.find('@') + 1); 88 domain = user.substr(user.find('@') + 1);
87 return domain == g_browser_process->browser_policy_connector()-> 89 return domain == g_browser_process->browser_policy_connector()->
88 GetEnterpriseDomain(); 90 GetEnterpriseDomain();
89 } 91 }
90 return false; 92 return false;
91 } 93 }
92 94
95 // Retrieves the time of the last Chrome OS update and converts it to a human-
96 // readable string. Note that this method uses an i18n-friendly library, so
97 // the returned string will already be properly translated.
98 string16 CreateLastUpdatedString() {
99 base::Time time;
100
101 if (!base::SysInfo::GetTimeLastUpdated(&time))
Evan Stade 2012/04/14 00:37:46 curlies
Kyle Horimoto 2012/04/16 18:32:54 Done.
102 // If the time of the last update cannot be retrieved, punt and just set
103 // the last update time to be the current time.
104 time = base::Time::Now();
105
106 return base::TimeFormatFriendlyDate(time);
107 }
108
93 #endif // defined(OS_CHROMEOS) 109 #endif // defined(OS_CHROMEOS)
94 110
95 } // namespace 111 } // namespace
96 112
97 HelpHandler::HelpHandler() 113 HelpHandler::HelpHandler()
98 : version_updater_(VersionUpdater::Create()) { 114 : version_updater_(VersionUpdater::Create()) {
99 } 115 }
100 116
101 HelpHandler::~HelpHandler() { 117 HelpHandler::~HelpHandler() {
102 } 118 }
(...skipping 26 matching lines...) Expand all
129 { "firmware", IDS_ABOUT_PAGE_FIRMWARE }, 145 { "firmware", IDS_ABOUT_PAGE_FIRMWARE },
130 { "showMoreInfo", IDS_SHOW_MORE_INFO }, 146 { "showMoreInfo", IDS_SHOW_MORE_INFO },
131 { "hideMoreInfo", IDS_HIDE_MORE_INFO }, 147 { "hideMoreInfo", IDS_HIDE_MORE_INFO },
132 { "channel", IDS_ABOUT_PAGE_CHANNEL }, 148 { "channel", IDS_ABOUT_PAGE_CHANNEL },
133 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE }, 149 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE },
134 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA }, 150 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA },
135 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT }, 151 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT },
136 { "webkit", IDS_WEBKIT }, 152 { "webkit", IDS_WEBKIT },
137 { "userAgent", IDS_ABOUT_VERSION_USER_AGENT }, 153 { "userAgent", IDS_ABOUT_VERSION_USER_AGENT },
138 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, 154 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE },
155 { "lastUpdated", IDS_ABOUT_VERSION_LAST_UPDATED },
139 #endif 156 #endif
140 #if defined(OS_MACOSX) 157 #if defined(OS_MACOSX)
141 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, 158 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER },
142 #endif 159 #endif
143 }; 160 };
144 161
145 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { 162 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) {
146 localized_strings->SetString(resources[i].name, 163 localized_strings->SetString(resources[i].name,
147 l10n_util::GetStringUTF16(resources[i].ids)); 164 l10n_util::GetStringUTF16(resources[i].ids));
148 } 165 }
149 166
150 localized_strings->SetString( 167 localized_strings->SetString(
151 "browserVersion", 168 "browserVersion",
152 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION, 169 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION,
153 BuildBrowserVersionString())); 170 BuildBrowserVersionString()));
154 171
155 string16 license = l10n_util::GetStringFUTF16( 172 string16 license = l10n_util::GetStringFUTF16(
156 IDS_ABOUT_VERSION_LICENSE, 173 IDS_ABOUT_VERSION_LICENSE,
157 UTF8ToUTF16(google_util::StringAppendGoogleLocaleParam( 174 UTF8ToUTF16(google_util::StringAppendGoogleLocaleParam(
158 chrome::kChromiumProjectURL)), 175 chrome::kChromiumProjectURL)),
159 ASCIIToUTF16(chrome::kChromeUICreditsURL)); 176 ASCIIToUTF16(chrome::kChromeUICreditsURL));
160 localized_strings->SetString("productLicense", license); 177 localized_strings->SetString("productLicense", license);
161 178
162 #if defined(OS_CHROMEOS) 179 #if defined(OS_CHROMEOS)
163 string16 os_license = l10n_util::GetStringFUTF16( 180 string16 os_license = l10n_util::GetStringFUTF16(
164 IDS_ABOUT_CROS_VERSION_LICENSE, 181 IDS_ABOUT_CROS_VERSION_LICENSE,
165 ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); 182 ASCIIToUTF16(chrome::kChromeUIOSCreditsURL));
166 localized_strings->SetString("productOsLicense", os_license); 183 localized_strings->SetString("productOsLicense", os_license);
184
185 localized_strings->SetString("lastUpdatedDate", CreateLastUpdatedString());
Evan Stade 2012/04/14 00:37:46 you can't read a file on the UI thread. You must p
Kyle Horimoto 2012/04/16 18:32:54 Done.
167 #endif 186 #endif
168 187
169 string16 tos = l10n_util::GetStringFUTF16( 188 string16 tos = l10n_util::GetStringFUTF16(
170 IDS_ABOUT_TERMS_OF_SERVICE, UTF8ToUTF16(chrome::kChromeUITermsURL)); 189 IDS_ABOUT_TERMS_OF_SERVICE, UTF8ToUTF16(chrome::kChromeUITermsURL));
171 localized_strings->SetString("productTOS", tos); 190 localized_strings->SetString("productTOS", tos);
172 191
173 localized_strings->SetString("webkitVersion", 192 localized_strings->SetString("webkitVersion",
174 webkit_glue::GetWebKitVersion()); 193 webkit_glue::GetWebKitVersion());
175 194
176 localized_strings->SetString("jsEngine", "V8"); 195 localized_strings->SetString("jsEngine", "V8");
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", 393 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware",
375 *firmware_string); 394 *firmware_string);
376 } 395 }
377 396
378 void HelpHandler::OnReleaseChannel(const std::string& channel) { 397 void HelpHandler::OnReleaseChannel(const std::string& channel) {
379 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); 398 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel));
380 web_ui()->CallJavascriptFunction( 399 web_ui()->CallJavascriptFunction(
381 "help.HelpPage.updateSelectedChannel", *channel_string); 400 "help.HelpPage.updateSelectedChannel", *channel_string);
382 } 401 }
383 #endif // defined(OS_CHROMEOS) 402 #endif // defined(OS_CHROMEOS)
OLDNEW
« base/sys_info_chromeos.cc ('K') | « chrome/browser/resources/help/help.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698