blob: 50f3ce4d5968ab5b6f3ad6bf178d126e55433f3c [file] [log] [blame]
[email protected]831d8d62012-11-30 02:46:131// 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.
4
5#include "remoting/host/usage_stats_consent.h"
6
dcheng0765c492016-04-06 22:41:537#include <memory>
[email protected]831d8d62012-11-30 02:46:138#include <string>
9
[email protected]b7c8d9b2012-12-10 23:37:0310#include "base/command_line.h"
[email protected]57999812013-02-24 05:40:5211#include "base/files/file_path.h"
[email protected]831d8d62012-11-30 02:46:1312#include "base/logging.h"
wez3b6ea0372014-11-23 02:03:1913#include "base/values.h"
[email protected]b7c8d9b2012-12-10 23:37:0314#include "remoting/host/config_file_watcher.h"
wez3b6ea0372014-11-23 02:03:1915#include "remoting/host/host_config.h"
[email protected]831d8d62012-11-30 02:46:1316
17namespace remoting {
18
19bool GetUsageStatsConsent(bool* allowed, bool* set_by_policy) {
20 *set_by_policy = false;
[email protected]831d8d62012-11-30 02:46:1321 *allowed = false;
[email protected]b7c8d9b2012-12-10 23:37:0322
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.
[email protected]b982d512014-05-23 09:42:0226 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
[email protected]b7c8d9b2012-12-10 23:37:0327 if (command_line->HasSwitch(kHostConfigSwitchName)) {
[email protected]a3ef4832013-02-02 05:12:3328 base::FilePath config_file_path =
[email protected]b7c8d9b2012-12-10 23:37:0329 command_line->GetSwitchValuePath(kHostConfigSwitchName);
dcheng0765c492016-04-06 22:41:5330 std::unique_ptr<base::DictionaryValue> host_config(
wez3b6ea0372014-11-23 02:03:1931 HostConfigFromJsonFile(config_file_path));
32 if (host_config) {
33 return host_config->GetBoolean(kUsageStatsConsentConfigPath, allowed);
[email protected]b7c8d9b2012-12-10 23:37:0334 }
35 }
36 return false;
[email protected]831d8d62012-11-30 02:46:1337}
38
39bool IsUsageStatsAllowed() {
40 bool allowed;
41 bool set_by_policy;
42 return GetUsageStatsConsent(&allowed, &set_by_policy) && allowed;
43}
44
45bool SetUsageStatsConsent(bool allowed) {
46 NOTIMPLEMENTED();
47 return false;
48}
49
50} // namespace remoting