File: ui_proxy_config_service.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (88 lines) | stat: -rw-r--r-- 3,570 bytes parent folder | download | duplicates (8)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_
#define CHROMEOS_ASH_COMPONENTS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_

#include <string>

#include "base/component_export.h"
#include "base/memory/raw_ptr.h"
#include "base/values.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/proxy_config/proxy_prefs.h"

class PrefService;

namespace ash {

class NetworkProfileHandler;
class NetworkState;
class NetworkStateHandler;

// This class provides an interface to the UI for getting a network proxy
// configuration.
// NOTE: This class must be rebuilt with the primary user's profile prefs when
// the primary user logs in.
// ALSO NOTE: The provided PrefService instances are used both to retrieve proxy
// configurations set by an extension, and for ONC policy information associated
// with a network. (Per-network proxy configurations are stored in Shill,
// but ONC policy configuration is stored in PrefService).
class COMPONENT_EXPORT(CHROMEOS_NETWORK) UIProxyConfigService {
 public:
  // |local_state_prefs| must not be null. |profile_prefs| can be
  // null if there is no logged in user, in which case only the local state
  // (device) prefs will be used. See note above.
  UIProxyConfigService(PrefService* profile_prefs,
                       PrefService* local_state_prefs,
                       NetworkStateHandler* network_state_handler,
                       NetworkProfileHandler* network_profile_handler);

  UIProxyConfigService(const UIProxyConfigService&) = delete;
  UIProxyConfigService& operator=(const UIProxyConfigService&) = delete;

  ~UIProxyConfigService();

  // Generates ONC dictionary for proxy settings enforced for the network, and
  // writes them to |proxy_settings|. The proxy settings that will be written to
  // |proxy_settings| will be one of the following (in order of preference):
  // * A proxy enforced by a user policy (provided by kProxy prefence).
  // * A proxy set by an extension in the active PrefService (also provided by
  //   kProxy pref).
  // * A proxy set by an ONC policy associated with |network_guid|.
  //
  // |proxy_settings| is expected to be a dictionary value containing ONC proxy
  // settings, and will generally contain the proxy settings reported by shill
  // (which will have user set per-network proxy settings, if they are
  // available).
  //
  // Returns whether |proxy_settings| have been changed.
  bool MergeEnforcedProxyConfig(const std::string& network_guid,
                                base::Value::Dict* proxy_settings);

  // Returns the ProxyMode for |network|. The returned result is used to display
  // a privacy warning to the user in the system tray.
  ProxyPrefs::ProxyMode ProxyModeForNetwork(const NetworkState* network);

 private:
  void OnPreferenceChanged(const std::string& pref_name);

  // GUID of network used for current_ui_config_.
  std::string current_ui_network_guid_;

  raw_ptr<PrefService> profile_prefs_;  // unowned
  PrefChangeRegistrar profile_registrar_;

  raw_ptr<PrefService> local_state_prefs_;  // unowned
  PrefChangeRegistrar local_state_registrar_;

  raw_ptr<NetworkStateHandler, DanglingUntriaged>
      network_state_handler_;  // unowned
  raw_ptr<NetworkProfileHandler, DanglingUntriaged>
      network_profile_handler_;  // unowned
};

}  // namespace ash

#endif  // CHROMEOS_ASH_COMPONENTS_NETWORK_PROXY_UI_PROXY_CONFIG_SERVICE_H_