Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_utils_chromeos.h" | 5 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/command_line.h" | |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "chrome/browser/chromeos/settings/cros_settings.h" | 14 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 14 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 16 #include "chromeos/chromeos_switches.h" | |
| 15 #include "chromeos/network/network_type_pattern.h" | 17 #include "chromeos/network/network_type_pattern.h" |
| 16 #include "chromeos/settings/cros_settings_names.h" | 18 #include "chromeos/settings/cros_settings_names.h" |
| 17 #include "third_party/cros_system_api/dbus/service_constants.h" | 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| 21 | 23 |
| 22 const bool kDefaultUpdateOverCellularAllowed = false; | 24 const bool kDefaultUpdateOverCellularAllowed = false; |
|
xiyuan
2017/02/14 17:06:10
We can get rid of this now since the default can c
kumarniranjan
2017/02/28 19:01:39
Done.
| |
| 23 | 25 |
| 24 } // namespace | 26 } // namespace |
| 25 | 27 |
| 26 namespace help_utils_chromeos { | 28 namespace help_utils_chromeos { |
| 27 | 29 |
| 28 bool IsUpdateOverCellularAllowed() { | 30 bool IsUpdateOverCellularAllowed() { |
| 31 bool updateOverCellularAllowed = kDefaultUpdateOverCellularAllowed; | |
|
xiyuan
2017/02/14 17:06:10
updateOverCellularAllowed -> default_update_over_c
kumarniranjan
2017/02/28 19:01:39
Done.
| |
| 32 | |
| 33 // If this is a Cellular First device, allow updates over cellular. | |
| 34 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 35 chromeos::switches::kCellularFirst)) { | |
| 36 updateOverCellularAllowed = true; | |
| 37 } | |
| 38 | |
| 39 // Device Policy overrides the defaults. | |
| 29 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); | 40 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); |
| 30 if (!settings) | 41 if (!settings) |
| 31 return kDefaultUpdateOverCellularAllowed; | 42 return updateOverCellularAllowed; |
| 32 | 43 |
| 33 const base::Value* raw_types_value = | 44 const base::Value* raw_types_value = |
| 34 settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate); | 45 settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate); |
| 35 if (!raw_types_value) | 46 if (!raw_types_value) |
| 36 return kDefaultUpdateOverCellularAllowed; | 47 return updateOverCellularAllowed; |
| 37 const base::ListValue* types_value; | 48 const base::ListValue* types_value; |
| 38 CHECK(raw_types_value->GetAsList(&types_value)); | 49 CHECK(raw_types_value->GetAsList(&types_value)); |
| 39 for (size_t i = 0; i < types_value->GetSize(); ++i) { | 50 for (size_t i = 0; i < types_value->GetSize(); ++i) { |
| 40 int connection_type; | 51 int connection_type; |
| 41 if (!types_value->GetInteger(i, &connection_type)) { | 52 if (!types_value->GetInteger(i, &connection_type)) { |
| 42 LOG(WARNING) << "Can't parse connection type #" << i; | 53 LOG(WARNING) << "Can't parse connection type #" << i; |
| 43 continue; | 54 continue; |
| 44 } | 55 } |
| 45 if (connection_type == 4) | 56 if (connection_type == 4) |
| 46 return true; | 57 return true; |
| 47 } | 58 } |
| 48 return kDefaultUpdateOverCellularAllowed; | 59 return updateOverCellularAllowed; |
| 49 } | 60 } |
| 50 | 61 |
| 51 base::string16 GetConnectionTypeAsUTF16(const std::string& type) { | 62 base::string16 GetConnectionTypeAsUTF16(const std::string& type) { |
| 52 if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type)) | 63 if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type)) |
| 53 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET); | 64 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET); |
| 54 if (type == shill::kTypeWifi) | 65 if (type == shill::kTypeWifi) |
| 55 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI); | 66 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI); |
| 56 if (type == shill::kTypeWimax) | 67 if (type == shill::kTypeWimax) |
| 57 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX); | 68 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX); |
| 58 if (type == shill::kTypeBluetooth) | 69 if (type == shill::kTypeBluetooth) |
| 59 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_BLUETOOTH); | 70 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_BLUETOOTH); |
| 60 if (type == shill::kTypeCellular) | 71 if (type == shill::kTypeCellular) |
| 61 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR); | 72 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR); |
| 62 if (type == shill::kTypeVPN) | 73 if (type == shill::kTypeVPN) |
| 63 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN); | 74 return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN); |
| 64 NOTREACHED(); | 75 NOTREACHED(); |
| 65 return base::string16(); | 76 return base::string16(); |
| 66 } | 77 } |
| 67 | 78 |
| 68 } // namespace help_utils_chromeos | 79 } // namespace help_utils_chromeos |
| OLD | NEW |