1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/host/usage_stats_consent.h"
9 #include "base/command_line.h"
10 #include "base/files/file_path.h"
11 #include "base/logging.h"
12 #include "remoting/host/config_file_watcher.h"
13 #include "remoting/host/json_host_config.h"
17 bool GetUsageStatsConsent(bool* allowed
, bool* set_by_policy
) {
18 *set_by_policy
= false;
21 // Normally, the ConfigFileWatcher class would be used for retrieving config
22 // settings, but this code needs to execute before Breakpad is initialised,
23 // which itself should happen as early as possible during startup.
24 CommandLine
* command_line
= CommandLine::ForCurrentProcess();
25 if (command_line
->HasSwitch(kHostConfigSwitchName
)) {
26 base::FilePath config_file_path
=
27 command_line
->GetSwitchValuePath(kHostConfigSwitchName
);
28 JsonHostConfig
host_config(config_file_path
);
29 if (host_config
.Read()) {
30 return host_config
.GetBoolean(kUsageStatsConsentConfigPath
, allowed
);
36 bool IsUsageStatsAllowed() {
39 return GetUsageStatsConsent(&allowed
, &set_by_policy
) && allowed
;
42 bool SetUsageStatsConsent(bool allowed
) {
47 } // namespace remoting