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