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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return domain == g_browser_process->browser_policy_connector()-> | 118 return domain == g_browser_process->browser_policy_connector()-> |
119 GetEnterpriseDomain(); | 119 GetEnterpriseDomain(); |
120 } else if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { | 120 } else if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { |
121 // On non managed machines we have local owner who is the only one to change | 121 // On non managed machines we have local owner who is the only one to change |
122 // anything. Ensure that ReleaseChannelDelegated is false. | 122 // anything. Ensure that ReleaseChannelDelegated is false. |
123 return !value; | 123 return !value; |
124 } | 124 } |
125 return false; | 125 return false; |
126 } | 126 } |
127 | 127 |
128 // Pointer to a |StringValue| holding the date of the build date to Chromium | |
129 // OS. Because this value is obtained by reading a file, it is cached here to | |
130 // prevent the need to read from the file system multiple times unnecessarily. | |
131 Value* g_build_date_string = NULL; | |
132 | |
133 #endif // defined(OS_CHROMEOS) | 128 #endif // defined(OS_CHROMEOS) |
134 | 129 |
135 } // namespace | 130 } // namespace |
136 | 131 |
137 HelpHandler::HelpHandler() | 132 HelpHandler::HelpHandler() |
138 : version_updater_(VersionUpdater::Create()), | 133 : version_updater_(VersionUpdater::Create()), |
139 weak_factory_(this) { | 134 weak_factory_(this) { |
140 } | 135 } |
141 | 136 |
142 HelpHandler::~HelpHandler() { | 137 HelpHandler::~HelpHandler() { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 base::Bind(&HelpHandler::OnOSVersion, base::Unretained(this)), | 331 base::Bind(&HelpHandler::OnOSVersion, base::Unretained(this)), |
337 &tracker_); | 332 &tracker_); |
338 loader_.GetFirmware( | 333 loader_.GetFirmware( |
339 base::Bind(&HelpHandler::OnOSFirmware, base::Unretained(this)), | 334 base::Bind(&HelpHandler::OnOSFirmware, base::Unretained(this)), |
340 &tracker_); | 335 &tracker_); |
341 | 336 |
342 web_ui()->CallJavascriptFunction( | 337 web_ui()->CallJavascriptFunction( |
343 "help.HelpPage.updateEnableReleaseChannel", | 338 "help.HelpPage.updateEnableReleaseChannel", |
344 base::FundamentalValue(CanChangeChannel())); | 339 base::FundamentalValue(CanChangeChannel())); |
345 | 340 |
346 if (g_build_date_string == NULL) { | 341 base::Time build_time = base::SysInfo::GetLsbReleaseTime(); |
347 // If |g_build_date_string| is |NULL|, the date has not yet been assigned. | 342 string16 build_date = base::TimeFormatFriendlyDate(build_time); |
348 // Get the date of the last lsb-release file modification. | 343 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", |
349 base::FileUtilProxy::GetFileInfo( | 344 base::StringValue(build_date)); |
350 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(), | |
351 base::SysInfo::GetLsbReleaseFilePath(), | |
352 base::Bind(&HelpHandler::ProcessLsbFileInfo, | |
353 weak_factory_.GetWeakPtr())); | |
354 } else { | |
355 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", | |
356 *g_build_date_string); | |
357 } | |
358 #endif // defined(OS_CHROMEOS) | 345 #endif // defined(OS_CHROMEOS) |
359 | 346 |
360 version_updater_->CheckForUpdate( | 347 version_updater_->CheckForUpdate( |
361 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)) | 348 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)) |
362 #if defined(OS_MACOSX) | 349 #if defined(OS_MACOSX) |
363 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) | 350 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) |
364 #endif | 351 #endif |
365 ); | 352 ); |
366 | 353 |
367 #if defined(OS_CHROMEOS) | 354 #if defined(OS_CHROMEOS) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 void HelpHandler::OnCurrentChannel(const std::string& channel) { | 526 void HelpHandler::OnCurrentChannel(const std::string& channel) { |
540 web_ui()->CallJavascriptFunction( | 527 web_ui()->CallJavascriptFunction( |
541 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); | 528 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); |
542 } | 529 } |
543 | 530 |
544 void HelpHandler::OnTargetChannel(const std::string& channel) { | 531 void HelpHandler::OnTargetChannel(const std::string& channel) { |
545 web_ui()->CallJavascriptFunction( | 532 web_ui()->CallJavascriptFunction( |
546 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); | 533 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); |
547 } | 534 } |
548 | 535 |
549 void HelpHandler::ProcessLsbFileInfo( | |
550 base::PlatformFileError error, const base::PlatformFileInfo& file_info) { | |
551 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
552 | |
553 // If |g_build_date_string| is not |NULL|, then the file's information has | |
554 // already been retrieved by another tab. | |
555 if (g_build_date_string == NULL) { | |
556 base::Time time; | |
557 if (error == base::PLATFORM_FILE_OK) { | |
558 // Retrieves the time at which the Chrome OS build was created. | |
559 // Each time a new build is created, /etc/lsb-release is modified with the | |
560 // new version numbers of the release. | |
561 time = file_info.last_modified; | |
562 } else { | |
563 // If the time of the build cannot be retrieved, return and do not | |
564 // display the "Build Date" section. | |
565 return; | |
566 } | |
567 | |
568 // Note that this string will be internationalized. | |
569 string16 build_date = base::TimeFormatFriendlyDate(time); | |
570 g_build_date_string = Value::CreateStringValue(build_date); | |
571 } | |
572 | |
573 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", | |
574 *g_build_date_string); | |
575 } | |
576 #endif // defined(OS_CHROMEOS) | 536 #endif // defined(OS_CHROMEOS) |
OLD | NEW |