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 <memory> |
7 #include <string> | 8 #include <string> |
8 | 9 |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "remoting/host/config_file_watcher.h" | 14 #include "remoting/host/config_file_watcher.h" |
15 #include "remoting/host/host_config.h" | 15 #include "remoting/host/host_config.h" |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 | 18 |
19 bool GetUsageStatsConsent(bool* allowed, bool* set_by_policy) { | 19 bool GetUsageStatsConsent(bool* allowed, bool* set_by_policy) { |
20 *set_by_policy = false; | 20 *set_by_policy = false; |
21 *allowed = false; | 21 *allowed = false; |
22 | 22 |
23 // Normally, the ConfigFileWatcher class would be used for retrieving config | 23 // Normally, the ConfigFileWatcher class would be used for retrieving config |
24 // settings, but this code needs to execute before Breakpad is initialised, | 24 // settings, but this code needs to execute before Breakpad is initialised, |
25 // which itself should happen as early as possible during startup. | 25 // which itself should happen as early as possible during startup. |
26 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 26 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
27 if (command_line->HasSwitch(kHostConfigSwitchName)) { | 27 if (command_line->HasSwitch(kHostConfigSwitchName)) { |
28 base::FilePath config_file_path = | 28 base::FilePath config_file_path = |
29 command_line->GetSwitchValuePath(kHostConfigSwitchName); | 29 command_line->GetSwitchValuePath(kHostConfigSwitchName); |
30 scoped_ptr<base::DictionaryValue> host_config( | 30 std::unique_ptr<base::DictionaryValue> host_config( |
31 HostConfigFromJsonFile(config_file_path)); | 31 HostConfigFromJsonFile(config_file_path)); |
32 if (host_config) { | 32 if (host_config) { |
33 return host_config->GetBoolean(kUsageStatsConsentConfigPath, allowed); | 33 return host_config->GetBoolean(kUsageStatsConsentConfigPath, allowed); |
34 } | 34 } |
35 } | 35 } |
36 return false; | 36 return false; |
37 } | 37 } |
38 | 38 |
39 bool IsUsageStatsAllowed() { | 39 bool IsUsageStatsAllowed() { |
40 bool allowed; | 40 bool allowed; |
41 bool set_by_policy; | 41 bool set_by_policy; |
42 return GetUsageStatsConsent(&allowed, &set_by_policy) && allowed; | 42 return GetUsageStatsConsent(&allowed, &set_by_policy) && allowed; |
43 } | 43 } |
44 | 44 |
45 bool SetUsageStatsConsent(bool allowed) { | 45 bool SetUsageStatsConsent(bool allowed) { |
46 NOTIMPLEMENTED(); | 46 NOTIMPLEMENTED(); |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
50 } // namespace remoting | 50 } // namespace remoting |
OLD | NEW |