[email protected] | 831d8d6 | 2012-11-30 02:46:13 | [diff] [blame] | 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 | |||||
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 7 | #include <memory> |
[email protected] | 831d8d6 | 2012-11-30 02:46:13 | [diff] [blame] | 8 | #include <string> |
9 | |||||
[email protected] | b7c8d9b | 2012-12-10 23:37:03 | [diff] [blame] | 10 | #include "base/command_line.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 11 | #include "base/files/file_path.h" |
[email protected] | 831d8d6 | 2012-11-30 02:46:13 | [diff] [blame] | 12 | #include "base/logging.h" |
wez | 3b6ea037 | 2014-11-23 02:03:19 | [diff] [blame] | 13 | #include "base/values.h" |
[email protected] | b7c8d9b | 2012-12-10 23:37:03 | [diff] [blame] | 14 | #include "remoting/host/config_file_watcher.h" |
wez | 3b6ea037 | 2014-11-23 02:03:19 | [diff] [blame] | 15 | #include "remoting/host/host_config.h" |
[email protected] | 831d8d6 | 2012-11-30 02:46:13 | [diff] [blame] | 16 | |
17 | namespace remoting { | ||||
18 | |||||
19 | bool GetUsageStatsConsent(bool* allowed, bool* set_by_policy) { | ||||
20 | *set_by_policy = false; | ||||
[email protected] | 831d8d6 | 2012-11-30 02:46:13 | [diff] [blame] | 21 | *allowed = false; |
[email protected] | b7c8d9b | 2012-12-10 23:37:03 | [diff] [blame] | 22 | |
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] | b982d51 | 2014-05-23 09:42:02 | [diff] [blame] | 26 | base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
[email protected] | b7c8d9b | 2012-12-10 23:37:03 | [diff] [blame] | 27 | if (command_line->HasSwitch(kHostConfigSwitchName)) { |
[email protected] | a3ef483 | 2013-02-02 05:12:33 | [diff] [blame] | 28 | base::FilePath config_file_path = |
[email protected] | b7c8d9b | 2012-12-10 23:37:03 | [diff] [blame] | 29 | command_line->GetSwitchValuePath(kHostConfigSwitchName); |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 30 | std::unique_ptr<base::DictionaryValue> host_config( |
wez | 3b6ea037 | 2014-11-23 02:03:19 | [diff] [blame] | 31 | HostConfigFromJsonFile(config_file_path)); |
32 | if (host_config) { | ||||
33 | return host_config->GetBoolean(kUsageStatsConsentConfigPath, allowed); | ||||
[email protected] | b7c8d9b | 2012-12-10 23:37:03 | [diff] [blame] | 34 | } |
35 | } | ||||
36 | return false; | ||||
[email protected] | 831d8d6 | 2012-11-30 02:46:13 | [diff] [blame] | 37 | } |
38 | |||||
39 | bool IsUsageStatsAllowed() { | ||||
40 | bool allowed; | ||||
41 | bool set_by_policy; | ||||
42 | return GetUsageStatsConsent(&allowed, &set_by_policy) && allowed; | ||||
43 | } | ||||
44 | |||||
45 | bool SetUsageStatsConsent(bool allowed) { | ||||
46 | NOTIMPLEMENTED(); | ||||
47 | return false; | ||||
48 | } | ||||
49 | |||||
50 | } // namespace remoting |