Chromium Code Reviews| 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" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/files/file_util.h" | |
| 14 #include "base/location.h" | |
| 13 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 14 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | |
| 15 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/values.h" | 19 #include "base/values.h" |
| 17 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_commands.h" | 23 #include "chrome/browser/ui/browser_commands.h" |
| 21 #include "chrome/browser/ui/browser_finder.h" | 24 #include "chrome/browser/ui/browser_finder.h" |
| 22 #include "chrome/browser/ui/chrome_pages.h" | 25 #include "chrome/browser/ui/chrome_pages.h" |
| 23 #include "chrome/common/chrome_content_client.h" | 26 #include "chrome/common/chrome_content_client.h" |
| 24 #include "chrome/common/chrome_version_info.h" | 27 #include "chrome/common/chrome_version_info.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 #include "components/user_manager/user_manager.h" | 60 #include "components/user_manager/user_manager.h" |
| 58 #endif | 61 #endif |
| 59 | 62 |
| 60 using base::ListValue; | 63 using base::ListValue; |
| 61 using content::BrowserThread; | 64 using content::BrowserThread; |
| 62 | 65 |
| 63 namespace { | 66 namespace { |
| 64 | 67 |
| 65 #if defined(OS_CHROMEOS) | 68 #if defined(OS_CHROMEOS) |
| 66 | 69 |
| 70 const char kFCCLabelTextPath[] = "fcc/label.txt"; | |
| 71 | |
| 67 // Returns message that informs user that for update it's better to | 72 // Returns message that informs user that for update it's better to |
| 68 // connect to a network of one of the allowed types. | 73 // connect to a network of one of the allowed types. |
| 69 base::string16 GetAllowedConnectionTypesMessage() { | 74 base::string16 GetAllowedConnectionTypesMessage() { |
| 70 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) { | 75 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) { |
| 71 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED); | 76 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED); |
| 72 } else { | 77 } else { |
| 73 return l10n_util::GetStringUTF16( | 78 return l10n_util::GetStringUTF16( |
| 74 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED); | 79 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED); |
| 75 } | 80 } |
| 76 } | 81 } |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 web_ui()->CallJavascriptFunction( | 382 web_ui()->CallJavascriptFunction( |
| 378 "help.HelpPage.updateIsEnterpriseManaged", | 383 "help.HelpPage.updateIsEnterpriseManaged", |
| 379 base::FundamentalValue(IsEnterpriseManaged())); | 384 base::FundamentalValue(IsEnterpriseManaged())); |
| 380 // First argument to GetChannel() is a flag that indicates whether | 385 // First argument to GetChannel() is a flag that indicates whether |
| 381 // current channel should be returned (if true) or target channel | 386 // current channel should be returned (if true) or target channel |
| 382 // (otherwise). | 387 // (otherwise). |
| 383 version_updater_->GetChannel(true, | 388 version_updater_->GetChannel(true, |
| 384 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); | 389 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); |
| 385 version_updater_->GetChannel(false, | 390 version_updater_->GetChannel(false, |
| 386 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); | 391 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); |
| 392 | |
| 393 BrowserThread::PostTask( | |
| 394 BrowserThread::FILE, FROM_HERE, | |
| 395 base::Bind(&HelpHandler::LoadFCCLabelText, weak_factory_.GetWeakPtr())); | |
|
satorux1
2014/12/04 08:20:04
This code is incorrect. You cannot use a UI-thread
| |
| 387 #endif | 396 #endif |
| 388 } | 397 } |
| 389 | 398 |
| 390 #if defined(OS_MACOSX) | 399 #if defined(OS_MACOSX) |
| 391 void HelpHandler::PromoteUpdater(const base::ListValue* args) { | 400 void HelpHandler::PromoteUpdater(const base::ListValue* args) { |
| 392 version_updater_->PromoteUpdater(); | 401 version_updater_->PromoteUpdater(); |
| 393 } | 402 } |
| 394 #endif | 403 #endif |
| 395 | 404 |
| 396 void HelpHandler::RelaunchNow(const base::ListValue* args) { | 405 void HelpHandler::RelaunchNow(const base::ListValue* args) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 void HelpHandler::OnCurrentChannel(const std::string& channel) { | 567 void HelpHandler::OnCurrentChannel(const std::string& channel) { |
| 559 web_ui()->CallJavascriptFunction( | 568 web_ui()->CallJavascriptFunction( |
| 560 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); | 569 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); |
| 561 } | 570 } |
| 562 | 571 |
| 563 void HelpHandler::OnTargetChannel(const std::string& channel) { | 572 void HelpHandler::OnTargetChannel(const std::string& channel) { |
| 564 web_ui()->CallJavascriptFunction( | 573 web_ui()->CallJavascriptFunction( |
| 565 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); | 574 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); |
| 566 } | 575 } |
| 567 | 576 |
| 577 void HelpHandler::LoadFCCLabelText() { | |
| 578 base::FilePath path(std::string(chrome::kChromeOSAssetPath) + | |
| 579 kFCCLabelTextPath); | |
| 580 std::string contents; | |
| 581 if (base::ReadFileToString(path, &contents)) { | |
| 582 // Remove unnecessary whitespace. | |
| 583 base::StringValue label(base::CollapseWhitespaceASCII(contents, true)); | |
| 584 web_ui()->CallJavascriptFunction("help.HelpPage.setProductLabelText", | |
|
satorux1
2014/12/04 08:20:04
This code is probably incorrect too. It looks unsa
| |
| 585 label); | |
| 586 } | |
| 587 } | |
| 588 | |
| 568 #endif // defined(OS_CHROMEOS) | 589 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |