Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(521)

Side by Side Diff: remoting/host/plugin/daemon_controller_mac.cc

Issue 10537182: The user's consent to crash dumps reporting can now be set via the UI (Windows only). The checkbox … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/plugin/daemon_controller.h" 5 #include "remoting/host/plugin/daemon_controller.h"
6 6
7 #include <launch.h> 7 #include <launch.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/json/json_writer.h" 16 #include "base/json/json_writer.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/mac/foundation_util.h" 18 #include "base/mac/foundation_util.h"
19 #include "base/mac/launchd.h" 19 #include "base/mac/launchd.h"
20 #include "base/mac/mac_logging.h" 20 #include "base/mac/mac_logging.h"
21 #include "base/mac/mac_util.h" 21 #include "base/mac/mac_util.h"
22 #include "base/mac/scoped_launch_data.h" 22 #include "base/mac/scoped_launch_data.h"
23 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
24 #include "base/time.h" 24 #include "base/time.h"
25 #include "base/values.h" 25 #include "base/values.h"
26 #include "remoting/host/json_host_config.h" 26 #include "remoting/host/json_host_config.h"
27 #include "remoting/host/usage_stats_consent.h"
27 28
28 namespace remoting { 29 namespace remoting {
29 30
30 namespace { 31 namespace {
31 32
32 // The NSSystemDirectories.h header has a conflicting definition of 33 // The NSSystemDirectories.h header has a conflicting definition of
33 // NSSearchPathDirectory with the one in base/mac/foundation_util.h. 34 // NSSearchPathDirectory with the one in base/mac/foundation_util.h.
34 // Foundation.h would work, but it can only be included from Objective-C files. 35 // Foundation.h would work, but it can only be included from Objective-C files.
35 // Therefore, we define the needed constants here. 36 // Therefore, we define the needed constants here.
36 const int NSLibraryDirectory = 5; 37 const int NSLibraryDirectory = 5;
(...skipping 20 matching lines...) Expand all
57 58
58 class DaemonControllerMac : public remoting::DaemonController { 59 class DaemonControllerMac : public remoting::DaemonController {
59 public: 60 public:
60 DaemonControllerMac(); 61 DaemonControllerMac();
61 virtual ~DaemonControllerMac(); 62 virtual ~DaemonControllerMac();
62 63
63 virtual State GetState() OVERRIDE; 64 virtual State GetState() OVERRIDE;
64 virtual void GetConfig(const GetConfigCallback& callback) OVERRIDE; 65 virtual void GetConfig(const GetConfigCallback& callback) OVERRIDE;
65 virtual void SetConfigAndStart( 66 virtual void SetConfigAndStart(
66 scoped_ptr<base::DictionaryValue> config, 67 scoped_ptr<base::DictionaryValue> config,
67 const CompletionCallback& done_callback) OVERRIDE; 68 bool consent,
69 const CompletionCallback& done) OVERRIDE;
68 virtual void UpdateConfig(scoped_ptr<base::DictionaryValue> config, 70 virtual void UpdateConfig(scoped_ptr<base::DictionaryValue> config,
69 const CompletionCallback& done_callback) OVERRIDE; 71 const CompletionCallback& done_callback) OVERRIDE;
70 virtual void Stop(const CompletionCallback& done_callback) OVERRIDE; 72 virtual void Stop(const CompletionCallback& done_callback) OVERRIDE;
71 virtual void SetWindow(void* window_handle) OVERRIDE; 73 virtual void SetWindow(void* window_handle) OVERRIDE;
72 virtual void GetVersion(const GetVersionCallback& done_callback) OVERRIDE; 74 virtual void GetVersion(const GetVersionCallback& done_callback) OVERRIDE;
75 virtual void GetUsageStatsConsent(
76 const GetUsageStatsConsentCallback& callback) OVERRIDE;
73 77
74 private: 78 private:
75 void DoGetConfig(const GetConfigCallback& callback); 79 void DoGetConfig(const GetConfigCallback& callback);
76 void DoGetVersion(const GetVersionCallback& callback); 80 void DoGetVersion(const GetVersionCallback& callback);
77 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config, 81 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config,
78 const CompletionCallback& done_callback); 82 const CompletionCallback& done);
79 void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config, 83 void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config,
80 const CompletionCallback& done_callback); 84 const CompletionCallback& done_callback);
81 void DoStop(const CompletionCallback& done_callback); 85 void DoStop(const CompletionCallback& done_callback);
82 86
83 void ShowPreferencePane(const std::string& config_data, 87 void ShowPreferencePane(const std::string& config_data,
84 const CompletionCallback& done_callback); 88 const CompletionCallback& done_callback);
85 void RegisterForPreferencePaneNotifications( 89 void RegisterForPreferencePaneNotifications(
86 const CompletionCallback &done_callback); 90 const CompletionCallback &done_callback);
87 void DeregisterForPreferencePaneNotifications(); 91 void DeregisterForPreferencePaneNotifications();
88 void PreferencePaneCallbackDelegate(CFStringRef name); 92 void PreferencePaneCallbackDelegate(CFStringRef name);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // base::Unretained() is safe, since this object owns the thread and therefore 145 // base::Unretained() is safe, since this object owns the thread and therefore
142 // outlives it. 146 // outlives it.
143 auth_thread_.message_loop_proxy()->PostTask( 147 auth_thread_.message_loop_proxy()->PostTask(
144 FROM_HERE, 148 FROM_HERE,
145 base::Bind(&DaemonControllerMac::DoGetConfig, base::Unretained(this), 149 base::Bind(&DaemonControllerMac::DoGetConfig, base::Unretained(this),
146 callback)); 150 callback));
147 } 151 }
148 152
149 void DaemonControllerMac::SetConfigAndStart( 153 void DaemonControllerMac::SetConfigAndStart(
150 scoped_ptr<base::DictionaryValue> config, 154 scoped_ptr<base::DictionaryValue> config,
151 const CompletionCallback& done_callback) { 155 bool /* consent */,
156 const CompletionCallback& done) {
152 auth_thread_.message_loop_proxy()->PostTask( 157 auth_thread_.message_loop_proxy()->PostTask(
153 FROM_HERE, base::Bind( 158 FROM_HERE, base::Bind(
154 &DaemonControllerMac::DoSetConfigAndStart, base::Unretained(this), 159 &DaemonControllerMac::DoSetConfigAndStart, base::Unretained(this),
155 base::Passed(&config), done_callback)); 160 base::Passed(&config), done));
156 } 161 }
157 162
158 void DaemonControllerMac::UpdateConfig( 163 void DaemonControllerMac::UpdateConfig(
159 scoped_ptr<base::DictionaryValue> config, 164 scoped_ptr<base::DictionaryValue> config,
160 const CompletionCallback& done_callback) { 165 const CompletionCallback& done_callback) {
161 auth_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( 166 auth_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
162 &DaemonControllerMac::DoUpdateConfig, base::Unretained(this), 167 &DaemonControllerMac::DoUpdateConfig, base::Unretained(this),
163 base::Passed(&config), done_callback)); 168 base::Passed(&config), done_callback));
164 } 169 }
165 170
166 void DaemonControllerMac::Stop(const CompletionCallback& done_callback) { 171 void DaemonControllerMac::Stop(const CompletionCallback& done_callback) {
167 auth_thread_.message_loop_proxy()->PostTask( 172 auth_thread_.message_loop_proxy()->PostTask(
168 FROM_HERE, base::Bind( 173 FROM_HERE, base::Bind(
169 &DaemonControllerMac::DoStop, base::Unretained(this), done_callback)); 174 &DaemonControllerMac::DoStop, base::Unretained(this), done_callback));
170 } 175 }
171 176
172 void DaemonControllerMac::SetWindow(void* window_handle) { 177 void DaemonControllerMac::SetWindow(void* window_handle) {
173 // noop 178 // noop
174 } 179 }
175 180
176 void DaemonControllerMac::GetVersion(const GetVersionCallback& callback) { 181 void DaemonControllerMac::GetVersion(const GetVersionCallback& callback) {
177 auth_thread_.message_loop_proxy()->PostTask( 182 auth_thread_.message_loop_proxy()->PostTask(
178 FROM_HERE, 183 FROM_HERE,
179 base::Bind(&DaemonControllerMac::DoGetVersion, base::Unretained(this), 184 base::Bind(&DaemonControllerMac::DoGetVersion, base::Unretained(this),
180 callback)); 185 callback));
181 } 186 }
182 187
188 void DaemonControllerMac::GetUsageStatsConsent(
189 const GetUsageStatsConsentCallback& callback) {
190 // Crash dump collection is not implemented on Mac yet.
191 // http://crbug.com/130678.
192 callback.Run(false, false, false);
193 }
194
183 void DaemonControllerMac::DoGetConfig(const GetConfigCallback& callback) { 195 void DaemonControllerMac::DoGetConfig(const GetConfigCallback& callback) {
184 FilePath config_path(kHostConfigFile); 196 FilePath config_path(kHostConfigFile);
185 JsonHostConfig host_config(config_path); 197 JsonHostConfig host_config(config_path);
186 scoped_ptr<base::DictionaryValue> config; 198 scoped_ptr<base::DictionaryValue> config;
187 199
188 if (host_config.Read()) { 200 if (host_config.Read()) {
189 config.reset(new base::DictionaryValue()); 201 config.reset(new base::DictionaryValue());
190 std::string value; 202 std::string value;
191 if (host_config.GetString(kHostIdConfigPath, &value)) 203 if (host_config.GetString(kHostIdConfigPath, &value))
192 config.get()->SetString(kHostIdConfigPath, value); 204 config.get()->SetString(kHostIdConfigPath, value);
(...skipping 23 matching lines...) Expand all
216 } 228 }
217 } 229 }
218 version = result; 230 version = result;
219 } 231 }
220 } 232 }
221 callback.Run(version); 233 callback.Run(version);
222 } 234 }
223 235
224 void DaemonControllerMac::DoSetConfigAndStart( 236 void DaemonControllerMac::DoSetConfigAndStart(
225 scoped_ptr<base::DictionaryValue> config, 237 scoped_ptr<base::DictionaryValue> config,
226 const CompletionCallback& done_callback) { 238 const CompletionCallback& done) {
227 std::string config_data; 239 std::string config_data;
228 base::JSONWriter::Write(config.get(), &config_data); 240 base::JSONWriter::Write(config.get(), &config_data);
229 ShowPreferencePane(config_data, done_callback); 241 ShowPreferencePane(config_data, done);
230 } 242 }
231 243
232 void DaemonControllerMac::DoUpdateConfig( 244 void DaemonControllerMac::DoUpdateConfig(
233 scoped_ptr<base::DictionaryValue> config, 245 scoped_ptr<base::DictionaryValue> config,
234 const CompletionCallback& done_callback) { 246 const CompletionCallback& done_callback) {
235 FilePath config_file_path(kHostConfigFile); 247 FilePath config_file_path(kHostConfigFile);
236 JsonHostConfig config_file(config_file_path); 248 JsonHostConfig config_file(config_file_path);
237 if (!config_file.Read()) { 249 if (!config_file.Read()) {
238 done_callback.Run(RESULT_FAILED); 250 done_callback.Run(RESULT_FAILED);
239 return; 251 return;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 384 }
373 } 385 }
374 386
375 } // namespace 387 } // namespace
376 388
377 scoped_ptr<DaemonController> remoting::DaemonController::Create() { 389 scoped_ptr<DaemonController> remoting::DaemonController::Create() {
378 return scoped_ptr<DaemonController>(new DaemonControllerMac()); 390 return scoped_ptr<DaemonController>(new DaemonControllerMac());
379 } 391 }
380 392
381 } // namespace remoting 393 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698