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 | |||||
Henrique Ferreiro | f3fbcea2 | 2021-02-05 23:12:19 | [diff] [blame] | 11 | #include "ash/constants/ash_switches.h" |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 12 | #include "base/logging.h" |
13 | #include "base/values.h" | ||||
Hidehiko Abe | d9d288eb7 | 2024-04-10 09:10:09 | [diff] [blame] | 14 | #include "chromeos/ash/components/settings/cros_settings.h" |
Henrique Ferreiro | 1eaedc4 | 2022-10-05 15:33:47 | [diff] [blame] | 15 | #include "chromeos/ash/components/settings/cros_settings_names.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(); |
Peter Kasting | a486324 | 2024-12-23 00:19:43 | [diff] [blame] | 27 | if (!settings) { |
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 28 | return default_update_over_cellular_allowed; |
Peter Kasting | a486324 | 2024-12-23 00:19:43 | [diff] [blame] | 29 | } |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 30 | |
Alex Cooper | f47262cc | 2021-07-17 04:11:21 | [diff] [blame] | 31 | const base::Value* types_value = |
Yeunjoo Choi | f6e9d4a | 2021-11-10 02:50:28 | [diff] [blame] | 32 | settings->GetPref(ash::kAllowedConnectionTypesForUpdate); |
Peter Kasting | a486324 | 2024-12-23 00:19:43 | [diff] [blame] | 33 | if (!types_value) { |
kumarniranjan | b9afef6 | 2017-03-02 21:42:22 | [diff] [blame] | 34 | return default_update_over_cellular_allowed; |
Peter Kasting | a486324 | 2024-12-23 00:19:43 | [diff] [blame] | 35 | } |
Alex Cooper | f47262cc | 2021-07-17 04:11:21 | [diff] [blame] | 36 | CHECK(types_value->is_list()); |
David Bertoni | fe117fd | 2022-10-04 19:53:01 | [diff] [blame] | 37 | const auto& list = types_value->GetList(); |
Alex Cooper | f47262cc | 2021-07-17 04:11:21 | [diff] [blame] | 38 | for (size_t i = 0; i < list.size(); ++i) { |
39 | if (!list[i].is_int()) { | ||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 40 | LOG(WARNING) << "Can't parse connection type #" << i; |
41 | continue; | ||||
42 | } | ||||
Alex Cooper | f47262cc | 2021-07-17 04:11:21 | [diff] [blame] | 43 | |
Peter Kasting | a486324 | 2024-12-23 00:19:43 | [diff] [blame] | 44 | if (list[i].GetInt() == 4) { |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 45 | return true; |
Peter Kasting | a486324 | 2024-12-23 00:19:43 | [diff] [blame] | 46 | } |
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 47 | } |
weidongg | a02f7da | 2017-05-23 17:12:11 | [diff] [blame] | 48 | // Device policy does not allow updates over cellular, as cellular is not |
49 | // included in allowed connection types for updates. | ||||
50 | return false; | ||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 51 | } |
52 | |||||
[email protected] | 7207a9c | 2013-06-08 00:18:09 | [diff] [blame] | 53 | } // namespace help_utils_chromeos |