| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 #if defined(OS_MACOSX) | 43 #if defined(OS_MACOSX) |
| 44 #include "chrome/browser/mac/obsolete_system.h" | 44 #include "chrome/browser/mac/obsolete_system.h" |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 #if defined(OS_CHROMEOS) | 47 #if defined(OS_CHROMEOS) |
| 48 #include "base/files/file_util_proxy.h" | 48 #include "base/files/file_util_proxy.h" |
| 49 #include "base/i18n/time_formatting.h" | 49 #include "base/i18n/time_formatting.h" |
| 50 #include "base/prefs/pref_service.h" | 50 #include "base/prefs/pref_service.h" |
| 51 #include "base/sys_info.h" | 51 #include "base/sys_info.h" |
| 52 #include "base/task_runner_util.h" |
| 52 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 53 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
| 53 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" | 54 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" |
| 54 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 55 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 55 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 56 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 56 #include "chrome/browser/chromeos/settings/cros_settings.h" | 57 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 57 #include "chrome/browser/profiles/profile.h" | 58 #include "chrome/browser/profiles/profile.h" |
| 58 #include "chrome/browser/ui/webui/chromeos/image_source.h" | 59 #include "chrome/browser/ui/webui/chromeos/image_source.h" |
| 59 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | 60 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" |
| 60 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h" | 61 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h" |
| 61 #include "chromeos/chromeos_switches.h" | 62 #include "chromeos/chromeos_switches.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance() | 120 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance() |
| 120 ->GetForBrowserContext(profile); | 121 ->GetForBrowserContext(profile); |
| 121 // On non managed machines we have local owner who is the only one to change | 122 // On non managed machines we have local owner who is the only one to change |
| 122 // anything. Ensure that ReleaseChannelDelegated is false. | 123 // anything. Ensure that ReleaseChannelDelegated is false. |
| 123 if (service && service->IsOwner()) | 124 if (service && service->IsOwner()) |
| 124 return !value; | 125 return !value; |
| 125 } | 126 } |
| 126 return false; | 127 return false; |
| 127 } | 128 } |
| 128 | 129 |
| 130 // Reads the file containing the FCC label text, if found. Must be called from |
| 131 // the blocking pool. |
| 132 std::string ReadFCCLabelText() { |
| 133 const base::FilePath asset_dir(FILE_PATH_LITERAL(chrome::kChromeOSAssetPath)); |
| 134 const base::FilePath label_file_path = |
| 135 asset_dir.AppendASCII(kFCCLabelTextPath); |
| 136 |
| 137 std::string contents; |
| 138 if (base::ReadFileToString(label_file_path, &contents)) |
| 139 return contents; |
| 140 return std::string(); |
| 141 } |
| 142 |
| 129 #endif // defined(OS_CHROMEOS) | 143 #endif // defined(OS_CHROMEOS) |
| 130 | 144 |
| 131 } // namespace | 145 } // namespace |
| 132 | 146 |
| 133 HelpHandler::HelpHandler() | 147 HelpHandler::HelpHandler() |
| 134 : version_updater_(VersionUpdater::Create(nullptr)), weak_factory_(this) { | 148 : version_updater_(VersionUpdater::Create(nullptr)), weak_factory_(this) { |
| 135 } | 149 } |
| 136 | 150 |
| 137 HelpHandler::~HelpHandler() { | 151 HelpHandler::~HelpHandler() { |
| 138 } | 152 } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 "help.HelpPage.updateIsEnterpriseManaged", | 410 "help.HelpPage.updateIsEnterpriseManaged", |
| 397 base::FundamentalValue(IsEnterpriseManaged())); | 411 base::FundamentalValue(IsEnterpriseManaged())); |
| 398 // First argument to GetChannel() is a flag that indicates whether | 412 // First argument to GetChannel() is a flag that indicates whether |
| 399 // current channel should be returned (if true) or target channel | 413 // current channel should be returned (if true) or target channel |
| 400 // (otherwise). | 414 // (otherwise). |
| 401 version_updater_->GetChannel(true, | 415 version_updater_->GetChannel(true, |
| 402 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); | 416 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); |
| 403 version_updater_->GetChannel(false, | 417 version_updater_->GetChannel(false, |
| 404 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); | 418 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); |
| 405 | 419 |
| 406 BrowserThread::PostTask( | 420 base::PostTaskAndReplyWithResult( |
| 407 BrowserThread::FILE, FROM_HERE, | 421 content::BrowserThread::GetBlockingPool(), |
| 408 base::Bind(&HelpHandler::LoadFCCLabelText, weak_factory_.GetWeakPtr())); | 422 FROM_HERE, |
| 423 base::Bind(&ReadFCCLabelText), |
| 424 base::Bind(&HelpHandler::OnFCCLabelTextRead, |
| 425 weak_factory_.GetWeakPtr())); |
| 409 #endif | 426 #endif |
| 410 } | 427 } |
| 411 | 428 |
| 412 #if defined(OS_MACOSX) | 429 #if defined(OS_MACOSX) |
| 413 void HelpHandler::PromoteUpdater(const base::ListValue* args) { | 430 void HelpHandler::PromoteUpdater(const base::ListValue* args) { |
| 414 version_updater_->PromoteUpdater(); | 431 version_updater_->PromoteUpdater(); |
| 415 } | 432 } |
| 416 #endif | 433 #endif |
| 417 | 434 |
| 418 void HelpHandler::RelaunchNow(const base::ListValue* args) { | 435 void HelpHandler::RelaunchNow(const base::ListValue* args) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 void HelpHandler::OnCurrentChannel(const std::string& channel) { | 597 void HelpHandler::OnCurrentChannel(const std::string& channel) { |
| 581 web_ui()->CallJavascriptFunction( | 598 web_ui()->CallJavascriptFunction( |
| 582 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); | 599 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); |
| 583 } | 600 } |
| 584 | 601 |
| 585 void HelpHandler::OnTargetChannel(const std::string& channel) { | 602 void HelpHandler::OnTargetChannel(const std::string& channel) { |
| 586 web_ui()->CallJavascriptFunction( | 603 web_ui()->CallJavascriptFunction( |
| 587 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); | 604 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); |
| 588 } | 605 } |
| 589 | 606 |
| 590 void HelpHandler::LoadFCCLabelText() { | 607 void HelpHandler::OnFCCLabelTextRead(std::string text) { |
| 591 base::FilePath path(std::string(chrome::kChromeOSAssetPath) + | 608 // Remove unnecessary whitespace. |
| 592 kFCCLabelTextPath); | 609 text = base::CollapseWhitespaceASCII(text, true); |
| 593 std::string contents; | 610 if (text.empty()) |
| 594 if (base::ReadFileToString(path, &contents)) { | 611 return; |
| 595 // Remove unnecessary whitespace. | 612 base::StringValue label(text); |
| 596 base::StringValue label(base::CollapseWhitespaceASCII(contents, true)); | 613 web_ui()->CallJavascriptFunction("help.HelpPage.setProductLabelText", label); |
| 597 web_ui()->CallJavascriptFunction("help.HelpPage.setProductLabelText", | |
| 598 label); | |
| 599 } | |
| 600 } | 614 } |
| 601 | 615 |
| 602 #endif // defined(OS_CHROMEOS) | 616 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |