Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | ||||
6 | |||||
avi | 0f23343 | 2015-12-25 02:23:38 | [diff] [blame] | 7 | #include <stddef.h> |
8 | |||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 9 | #include <algorithm> |
10 | |||||
Yeunjoo Choi | 6baf306 | 2021-11-08 02:51:10 | [diff] [blame] | 11 | #include "ash/components/settings/cros_settings_names.h" |
Henrique Ferreiro | f3fbcea2 | 2021-02-05 23:12:19 | [diff] [blame] | 12 | #include "ash/constants/ash_switches.h" |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 13 | #include "base/logging.h" |
14 | #include "base/values.h" | ||||
Yeunjoo Choi | 5097e9c | 2021-02-25 08:46:52 | [diff] [blame] | 15 | #include "chrome/browser/ash/settings/cros_settings.h" |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 16 | |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 17 | namespace help_utils_chromeos { |
18 | |||||
weidongg | a02f7da | 2017-05-23 17:12:11 | [diff] [blame] | 19 | bool IsUpdateOverCellularAllowed(bool interactive) { |
20 | // If this is a Cellular First device or the user actively checks for update, | ||||
21 | // the default is to allow updates over cellular. | ||||
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 22 | bool default_update_over_cellular_allowed = |
Henrique Ferreiro | 93dd33b | 2022-01-18 16:06:45 | [diff] [blame] | 23 | interactive ? true : ash::switches::IsCellularFirstDevice(); |
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 24 | |
25 | // Device Policy overrides the defaults. | ||||
Yeunjoo Choi | d461f87 | 2021-03-11 06:52:19 | [diff] [blame] | 26 | ash::CrosSettings* settings = ash::CrosSettings::Get(); |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 27 | if (!settings) |
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 28 | return default_update_over_cellular_allowed; |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 29 | |
Alex Cooper | f47262cc | 2021-07-17 04:11:21 | [diff] [blame] | 30 | const base::Value* types_value = |
Yeunjoo Choi | f6e9d4a | 2021-11-10 02:50:28 | [diff] [blame] | 31 | settings->GetPref(ash::kAllowedConnectionTypesForUpdate); |
Alex Cooper | f47262cc | 2021-07-17 04:11:21 | [diff] [blame] | 32 | if (!types_value) |
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 33 | return default_update_over_cellular_allowed; |
Alex Cooper | f47262cc | 2021-07-17 04:11:21 | [diff] [blame] | 34 | CHECK(types_value->is_list()); |
David Bertoni | fe117fd | 2022-10-04 19:53:01 | [diff] [blame^] | 35 | const auto& list = types_value->GetList(); |
Alex Cooper | f47262cc | 2021-07-17 04:11:21 | [diff] [blame] | 36 | for (size_t i = 0; i < list.size(); ++i) { |
37 | if (!list[i].is_int()) { | ||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 38 | LOG(WARNING) << "Can't parse connection type #" << i; |
39 | continue; | ||||
40 | } | ||||
Alex Cooper | f47262cc | 2021-07-17 04:11:21 | [diff] [blame] | 41 | |
42 | if (list[i].GetInt() == 4) | ||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 43 | return true; |
44 | } | ||||
weidongg | a02f7da | 2017-05-23 17:12:11 | [diff] [blame] | 45 | // Device policy does not allow updates over cellular, as cellular is not |
46 | // included in allowed connection types for updates. | ||||
47 | return false; | ||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 48 | } |
49 | |||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 50 | } // namespace help_utils_chromeos |