| 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/version_updater_chromeos.h" | 5 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const bool kDefaultAutoUpdateDisabled = false; | 48 const bool kDefaultAutoUpdateDisabled = false; |
| 49 | 49 |
| 50 NetworkStatus GetNetworkStatus(bool interactive, | 50 NetworkStatus GetNetworkStatus(bool interactive, |
| 51 const chromeos::NetworkState* network) { | 51 const chromeos::NetworkState* network) { |
| 52 if (!network || !network->IsConnectedState()) // Offline state. | 52 if (!network || !network->IsConnectedState()) // Offline state. |
| 53 return NETWORK_STATUS_OFFLINE; | 53 return NETWORK_STATUS_OFFLINE; |
| 54 | 54 |
| 55 if (network->type() == shill::kTypeBluetooth) | 55 if (network->type() == shill::kTypeBluetooth) |
| 56 return NETWORK_STATUS_DISALLOWED; | 56 return NETWORK_STATUS_DISALLOWED; |
| 57 | 57 |
| 58 if (network->type() == shill::kTypeCellular && | 58 // Treats tethered networks as cellular networks. |
| 59 if (network->IsUsingMobileData() && |
| 59 !help_utils_chromeos::IsUpdateOverCellularAllowed(interactive)) { | 60 !help_utils_chromeos::IsUpdateOverCellularAllowed(interactive)) { |
| 60 return NETWORK_STATUS_DISALLOWED; | 61 return NETWORK_STATUS_DISALLOWED; |
| 61 } | 62 } |
| 62 return NETWORK_STATUS_ALLOWED; | 63 return NETWORK_STATUS_ALLOWED; |
| 63 } | 64 } |
| 64 | 65 |
| 65 // Returns true if auto-update is disabled by the system administrator. | 66 // Returns true if auto-update is disabled by the system administrator. |
| 66 bool IsAutoUpdateDisabled() { | 67 bool IsAutoUpdateDisabled() { |
| 67 bool update_disabled = kDefaultAutoUpdateDisabled; | 68 bool update_disabled = kDefaultAutoUpdateDisabled; |
| 68 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); | 69 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 92 network_state_handler->DefaultNetwork(); | 93 network_state_handler->DefaultNetwork(); |
| 93 | 94 |
| 94 // Don't allow an update if we're currently offline or connected | 95 // Don't allow an update if we're currently offline or connected |
| 95 // to a network for which updates are disallowed. | 96 // to a network for which updates are disallowed. |
| 96 NetworkStatus status = GetNetworkStatus(interactive, network); | 97 NetworkStatus status = GetNetworkStatus(interactive, network); |
| 97 if (status == NETWORK_STATUS_OFFLINE) { | 98 if (status == NETWORK_STATUS_OFFLINE) { |
| 98 callback.Run(VersionUpdater::FAILED_OFFLINE, 0, std::string(), 0, | 99 callback.Run(VersionUpdater::FAILED_OFFLINE, 0, std::string(), 0, |
| 99 l10n_util::GetStringUTF16(IDS_UPGRADE_OFFLINE)); | 100 l10n_util::GetStringUTF16(IDS_UPGRADE_OFFLINE)); |
| 100 return false; | 101 return false; |
| 101 } else if (status == NETWORK_STATUS_DISALLOWED) { | 102 } else if (status == NETWORK_STATUS_DISALLOWED) { |
| 102 base::string16 message = | 103 base::string16 message = l10n_util::GetStringFUTF16( |
| 103 l10n_util::GetStringFUTF16( | 104 IDS_UPGRADE_DISALLOWED, |
| 104 IDS_UPGRADE_DISALLOWED, | 105 help_utils_chromeos::GetConnectionTypeAsUTF16(network)); |
| 105 help_utils_chromeos::GetConnectionTypeAsUTF16(network->type())); | |
| 106 callback.Run(VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED, 0, | 106 callback.Run(VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED, 0, |
| 107 std::string(), 0, message); | 107 std::string(), 0, message); |
| 108 return false; | 108 return false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 return true; | 111 return true; |
| 112 } | 112 } |
| 113 | 113 |
| 114 } // namespace | 114 } // namespace |
| 115 | 115 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 void VersionUpdaterCros::OnUpdateCheck( | 311 void VersionUpdaterCros::OnUpdateCheck( |
| 312 UpdateEngineClient::UpdateCheckResult result) { | 312 UpdateEngineClient::UpdateCheckResult result) { |
| 313 // If version updating is not implemented, this binary is the most up-to-date | 313 // If version updating is not implemented, this binary is the most up-to-date |
| 314 // possible with respect to automatic updating. | 314 // possible with respect to automatic updating. |
| 315 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) | 315 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) |
| 316 callback_.Run(UPDATED, 0, std::string(), 0, base::string16()); | 316 callback_.Run(UPDATED, 0, std::string(), 0, base::string16()); |
| 317 } | 317 } |
| OLD | NEW |