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 "base/memory/scoped_ptr.h"
13 #include "base/values.h"
14 #include "remoting/host/config_file_watcher.h"
15 #include "remoting/host/host_config.h"
19 bool GetUsageStatsConsent(bool* allowed
, bool* set_by_policy
) {
20 *set_by_policy
= false;
23 // Normally, the ConfigFileWatcher class would be used for retrieving config
24 // settings, but this code needs to execute before Breakpad is initialised,
25 // which itself should happen as early as possible during startup.
26 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
27 if (command_line
->HasSwitch(kHostConfigSwitchName
)) {
28 base::FilePath config_file_path
=
29 command_line
->GetSwitchValuePath(kHostConfigSwitchName
);
30 scoped_ptr
<base::DictionaryValue
> host_config(
31 HostConfigFromJsonFile(config_file_path
));
33 return host_config
->GetBoolean(kUsageStatsConsentConfigPath
, allowed
);
39 bool IsUsageStatsAllowed() {
42 return GetUsageStatsConsent(&allowed
, &set_by_policy
) && allowed
;
45 bool SetUsageStatsConsent(bool allowed
) {
50 } // namespace remoting