OLD | NEW |
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); | 94 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); |
95 size_t at_pos = user.find('@'); | 95 size_t at_pos = user.find('@'); |
96 if (at_pos != std::string::npos && at_pos + 1 < user.length()) | 96 if (at_pos != std::string::npos && at_pos + 1 < user.length()) |
97 domain = user.substr(user.find('@') + 1); | 97 domain = user.substr(user.find('@') + 1); |
98 return domain == g_browser_process->browser_policy_connector()-> | 98 return domain == g_browser_process->browser_policy_connector()-> |
99 GetEnterpriseDomain(); | 99 GetEnterpriseDomain(); |
100 } | 100 } |
101 return false; | 101 return false; |
102 } | 102 } |
103 | 103 |
104 // Pointer to a |StringValue| holding the date of the last update to Chromium | 104 // Pointer to a |StringValue| holding the date of the build date to Chromium |
105 // OS. Because this value is obtained by reading a file, it is cached here to | 105 // OS. Because this value is obtained by reading a file, it is cached here to |
106 // prevent the need to read from the file system multiple times unnecessarily. | 106 // prevent the need to read from the file system multiple times unnecessarily. |
107 Value* g_last_updated_string = NULL; | 107 Value* g_build_date_string = NULL; |
108 | 108 |
109 #endif // defined(OS_CHROMEOS) | 109 #endif // defined(OS_CHROMEOS) |
110 | 110 |
111 } // namespace | 111 } // namespace |
112 | 112 |
113 HelpHandler::HelpHandler() | 113 HelpHandler::HelpHandler() |
114 : version_updater_(VersionUpdater::Create()), | 114 : version_updater_(VersionUpdater::Create()), |
115 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 115 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
116 } | 116 } |
117 | 117 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 { "firmware", IDS_ABOUT_PAGE_FIRMWARE }, | 150 { "firmware", IDS_ABOUT_PAGE_FIRMWARE }, |
151 { "showMoreInfo", IDS_SHOW_MORE_INFO }, | 151 { "showMoreInfo", IDS_SHOW_MORE_INFO }, |
152 { "hideMoreInfo", IDS_HIDE_MORE_INFO }, | 152 { "hideMoreInfo", IDS_HIDE_MORE_INFO }, |
153 { "channel", IDS_ABOUT_PAGE_CHANNEL }, | 153 { "channel", IDS_ABOUT_PAGE_CHANNEL }, |
154 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE }, | 154 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE }, |
155 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA }, | 155 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA }, |
156 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT }, | 156 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT }, |
157 { "webkit", IDS_WEBKIT }, | 157 { "webkit", IDS_WEBKIT }, |
158 { "userAgent", IDS_ABOUT_VERSION_USER_AGENT }, | 158 { "userAgent", IDS_ABOUT_VERSION_USER_AGENT }, |
159 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, | 159 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, |
160 { "lastUpdated", IDS_ABOUT_VERSION_LAST_UPDATED }, | 160 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE }, |
161 #endif | 161 #endif |
162 #if defined(OS_MACOSX) | 162 #if defined(OS_MACOSX) |
163 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, | 163 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, |
164 { "learnMore", IDS_LEARN_MORE }, | 164 { "learnMore", IDS_LEARN_MORE }, |
165 #endif | 165 #endif |
166 }; | 166 }; |
167 | 167 |
168 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { | 168 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { |
169 localized_strings->SetString(resources[i].name, | 169 localized_strings->SetString(resources[i].name, |
170 l10n_util::GetStringUTF16(resources[i].ids)); | 170 l10n_util::GetStringUTF16(resources[i].ids)); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 base::Unretained(this)), | 261 base::Unretained(this)), |
262 chromeos::VersionLoader::VERSION_FULL); | 262 chromeos::VersionLoader::VERSION_FULL); |
263 loader_.GetFirmware(&consumer_, base::Bind(&HelpHandler::OnOSFirmware, | 263 loader_.GetFirmware(&consumer_, base::Bind(&HelpHandler::OnOSFirmware, |
264 base::Unretained(this))); | 264 base::Unretained(this))); |
265 | 265 |
266 scoped_ptr<base::Value> can_change_channel_value( | 266 scoped_ptr<base::Value> can_change_channel_value( |
267 base::Value::CreateBooleanValue(CanChangeReleaseChannel())); | 267 base::Value::CreateBooleanValue(CanChangeReleaseChannel())); |
268 web_ui()->CallJavascriptFunction( | 268 web_ui()->CallJavascriptFunction( |
269 "help.HelpPage.updateEnableReleaseChannel", *can_change_channel_value); | 269 "help.HelpPage.updateEnableReleaseChannel", *can_change_channel_value); |
270 | 270 |
271 if (g_last_updated_string == NULL) { | 271 if (g_build_date_string == NULL) { |
272 // If |g_last_updated_string| is |NULL|, the date has not yet been assigned. | 272 // If |g_build_date_string| is |NULL|, the date has not yet been assigned. |
273 // Get the date of the last lsb-release file modification. | 273 // Get the date of the last lsb-release file modification. |
274 base::FileUtilProxy::GetFileInfo( | 274 base::FileUtilProxy::GetFileInfo( |
275 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 275 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
276 base::SysInfo::GetLsbReleaseFilePath(), | 276 base::SysInfo::GetLsbReleaseFilePath(), |
277 base::Bind(&HelpHandler::ProcessLsbFileInfo, | 277 base::Bind(&HelpHandler::ProcessLsbFileInfo, |
278 weak_factory_.GetWeakPtr())); | 278 weak_factory_.GetWeakPtr())); |
279 } else { | 279 } else { |
280 web_ui()->CallJavascriptFunction("help.HelpPage.setLastUpdated", | 280 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", |
281 *g_last_updated_string); | 281 *g_build_date_string); |
282 } | 282 } |
283 #endif // defined(OS_CHROMEOS) | 283 #endif // defined(OS_CHROMEOS) |
284 | 284 |
285 version_updater_->CheckForUpdate( | 285 version_updater_->CheckForUpdate( |
286 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)) | 286 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)) |
287 #if defined(OS_MACOSX) | 287 #if defined(OS_MACOSX) |
288 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) | 288 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) |
289 #endif | 289 #endif |
290 ); | 290 ); |
291 | 291 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 void HelpHandler::OnReleaseChannel(const std::string& channel) { | 427 void HelpHandler::OnReleaseChannel(const std::string& channel) { |
428 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); | 428 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); |
429 web_ui()->CallJavascriptFunction( | 429 web_ui()->CallJavascriptFunction( |
430 "help.HelpPage.updateSelectedChannel", *channel_string); | 430 "help.HelpPage.updateSelectedChannel", *channel_string); |
431 } | 431 } |
432 | 432 |
433 void HelpHandler::ProcessLsbFileInfo( | 433 void HelpHandler::ProcessLsbFileInfo( |
434 base::PlatformFileError error, const base::PlatformFileInfo& file_info) { | 434 base::PlatformFileError error, const base::PlatformFileInfo& file_info) { |
435 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 435 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
436 | 436 |
437 // If |g_last_updated_string| is not |NULL|, then the file's information has | 437 // If |g_build_date_string| is not |NULL|, then the file's information has |
438 // already been retrieved by another tab. | 438 // already been retrieved by another tab. |
439 if (g_last_updated_string == NULL) { | 439 if (g_build_date_string == NULL) { |
440 base::Time time; | 440 base::Time time; |
441 if (error == base::PLATFORM_FILE_OK) { | 441 if (error == base::PLATFORM_FILE_OK) { |
442 // Retrieves the approximate time at which Chrome OS was last updated. | 442 // Retrieves the time at which the Chrome OS build was created. |
443 // Each time a new build is created, /etc/lsb-release is modified with the | 443 // Each time a new build is created, /etc/lsb-release is modified with the |
444 // new version numbers of the release. | 444 // new version numbers of the release. |
445 time = file_info.last_modified; | 445 time = file_info.last_modified; |
446 } else { | 446 } else { |
447 // If the time of the last update cannot be retrieved, return and do not | 447 // If the time of the build cannot be retrieved, return and do not |
448 // display the "Last Updated" section. | 448 // display the "Build Date" section. |
449 return; | 449 return; |
450 } | 450 } |
451 | 451 |
452 // Note that this string will be internationalized. | 452 // Note that this string will be internationalized. |
453 string16 last_updated = base::TimeFormatFriendlyDate(time); | 453 string16 build_date = base::TimeFormatFriendlyDate(time); |
454 g_last_updated_string = Value::CreateStringValue(last_updated); | 454 g_build_date_string = Value::CreateStringValue(build_date); |
455 } | 455 } |
456 | 456 |
457 web_ui()->CallJavascriptFunction("help.HelpPage.setLastUpdated", | 457 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", |
458 *g_last_updated_string); | 458 *g_build_date_string); |
459 } | 459 } |
460 #endif // defined(OS_CHROMEOS) | 460 #endif // defined(OS_CHROMEOS) |
OLD | NEW |