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. 4 5 #include "remoting/host/usage_stats_consent.h" 6 7 #include <string> 8 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" 14 15 namespace remoting { 16 17 bool GetUsageStatsConsent(bool* allowed, bool* set_by_policy) { 18 *set_by_policy = false; 19 *allowed = false; 20 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); 31 } 32 } 33 return false; 34 } 35 36 bool IsUsageStatsAllowed() { 37 bool allowed; 38 bool set_by_policy; 39 return GetUsageStatsConsent(&allowed, &set_by_policy) && allowed; 40 } 41 42 bool SetUsageStatsConsent(bool allowed) { 43 NOTIMPLEMENTED(); 44 return false; 45 } 46 47 } // namespace remoting 48