summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/help/help_utils_chromeos.cc
blob: 7896f0c6804fdd5108ec2cad6c4f3e8ca93e448e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/webui/help/help_utils_chromeos.h"

#include <algorithm>

#include "base/logging.h"
#include "base/values.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/network/network_type_pattern.h"
#include "chromeos/settings/cros_settings_names.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/l10n/l10n_util.h"

namespace {

const bool kDefaultUpdateOverCellularAllowed = false;

}  // namespace

namespace help_utils_chromeos {

bool IsUpdateOverCellularAllowed() {
  chromeos::CrosSettings* settings = chromeos::CrosSettings::Get();
  if (!settings)
    return kDefaultUpdateOverCellularAllowed;

  const base::Value* raw_types_value =
      settings->GetPref(chromeos::kAllowedConnectionTypesForUpdate);
  if (!raw_types_value)
    return kDefaultUpdateOverCellularAllowed;
  const base::ListValue* types_value;
  CHECK(raw_types_value->GetAsList(&types_value));
  for (size_t i = 0; i < types_value->GetSize(); ++i) {
    int connection_type;
    if (!types_value->GetInteger(i, &connection_type)) {
      LOG(WARNING) << "Can't parse connection type #" << i;
      continue;
    }
    if (connection_type == 4)
      return true;
  }
  return kDefaultUpdateOverCellularAllowed;
}

base::string16 GetConnectionTypeAsUTF16(const std::string& type) {
  if (chromeos::NetworkTypePattern::Ethernet().MatchesType(type))
    return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_ETHERNET);
  if (type == shill::kTypeWifi)
    return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIFI);
  if (type == shill::kTypeWimax)
    return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_WIMAX);
  if (type == shill::kTypeBluetooth)
    return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_BLUETOOTH);
  if (type == shill::kTypeCellular)
    return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_CELLULAR);
  if (type == shill::kTypeVPN)
    return l10n_util::GetStringUTF16(IDS_NETWORK_TYPE_VPN);
  NOTREACHED();
  return base::string16();
}

}  // namespace help_utils_chromeos