blob: 19175bd98a29c79ad4c3eb66fad005f88311e364 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2013 The Chromium Authors
[email protected]7207a9c2013-06-08 00:18:092// 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
avi0f233432015-12-25 02:23:387#include <stddef.h>
8
[email protected]7207a9c2013-06-08 00:18:099#include <algorithm>
10
Henrique Ferreirof3fbcea22021-02-05 23:12:1911#include "ash/constants/ash_switches.h"
[email protected]7207a9c2013-06-08 00:18:0912#include "base/logging.h"
13#include "base/values.h"
Hidehiko Abed9d288eb72024-04-10 09:10:0914#include "chromeos/ash/components/settings/cros_settings.h"
Henrique Ferreiro1eaedc42022-10-05 15:33:4715#include "chromeos/ash/components/settings/cros_settings_names.h"
[email protected]7207a9c2013-06-08 00:18:0916
[email protected]7207a9c2013-06-08 00:18:0917namespace help_utils_chromeos {
18
weidongga02f7da2017-05-23 17:12:1119bool 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.
kumarniranjanb9afef62017-03-02 21:42:2222 bool default_update_over_cellular_allowed =
Henrique Ferreiro93dd33b2022-01-18 16:06:4523 interactive ? true : ash::switches::IsCellularFirstDevice();
kumarniranjanb9afef62017-03-02 21:42:2224
25 // Device Policy overrides the defaults.
Yeunjoo Choid461f872021-03-11 06:52:1926 ash::CrosSettings* settings = ash::CrosSettings::Get();
Peter Kastinga4863242024-12-23 00:19:4327 if (!settings) {
kumarniranjanb9afef62017-03-02 21:42:2228 return default_update_over_cellular_allowed;
Peter Kastinga4863242024-12-23 00:19:4329 }
[email protected]7207a9c2013-06-08 00:18:0930
Alex Cooperf47262cc2021-07-17 04:11:2131 const base::Value* types_value =
Yeunjoo Choif6e9d4a2021-11-10 02:50:2832 settings->GetPref(ash::kAllowedConnectionTypesForUpdate);
Peter Kastinga4863242024-12-23 00:19:4333 if (!types_value) {
kumarniranjanb9afef62017-03-02 21:42:2234 return default_update_over_cellular_allowed;
Peter Kastinga4863242024-12-23 00:19:4335 }
Alex Cooperf47262cc2021-07-17 04:11:2136 CHECK(types_value->is_list());
David Bertonife117fd2022-10-04 19:53:0137 const auto& list = types_value->GetList();
Alex Cooperf47262cc2021-07-17 04:11:2138 for (size_t i = 0; i < list.size(); ++i) {
39 if (!list[i].is_int()) {
[email protected]7207a9c2013-06-08 00:18:0940 LOG(WARNING) << "Can't parse connection type #" << i;
41 continue;
42 }
Alex Cooperf47262cc2021-07-17 04:11:2143
Peter Kastinga4863242024-12-23 00:19:4344 if (list[i].GetInt() == 4) {
[email protected]7207a9c2013-06-08 00:18:0945 return true;
Peter Kastinga4863242024-12-23 00:19:4346 }
[email protected]7207a9c2013-06-08 00:18:0947 }
weidongga02f7da2017-05-23 17:12:1148 // 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]7207a9c2013-06-08 00:18:0951}
52
[email protected]7207a9c2013-06-08 00:18:0953} // namespace help_utils_chromeos