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

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

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/setup/daemon_controller.h" 5 #include "remoting/host/setup/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
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 void DaemonControllerMac::GetUsageStatsConsent( 168 void DaemonControllerMac::GetUsageStatsConsent(
169 const GetUsageStatsConsentCallback& callback) { 169 const GetUsageStatsConsentCallback& callback) {
170 auth_thread_.message_loop_proxy()->PostTask( 170 auth_thread_.message_loop_proxy()->PostTask(
171 FROM_HERE, 171 FROM_HERE,
172 base::Bind(&DaemonControllerMac::DoGetUsageStatsConsent, 172 base::Bind(&DaemonControllerMac::DoGetUsageStatsConsent,
173 base::Unretained(this), callback)); 173 base::Unretained(this), callback));
174 } 174 }
175 175
176 void DaemonControllerMac::DoGetConfig(const GetConfigCallback& callback) { 176 void DaemonControllerMac::DoGetConfig(const GetConfigCallback& callback) {
177 FilePath config_path(kHostConfigFilePath); 177 base::FilePath config_path(kHostConfigFilePath);
178 JsonHostConfig host_config(config_path); 178 JsonHostConfig host_config(config_path);
179 scoped_ptr<base::DictionaryValue> config; 179 scoped_ptr<base::DictionaryValue> config;
180 180
181 if (host_config.Read()) { 181 if (host_config.Read()) {
182 config.reset(new base::DictionaryValue()); 182 config.reset(new base::DictionaryValue());
183 std::string value; 183 std::string value;
184 if (host_config.GetString(kHostIdConfigPath, &value)) 184 if (host_config.GetString(kHostIdConfigPath, &value))
185 config.get()->SetString(kHostIdConfigPath, value); 185 config.get()->SetString(kHostIdConfigPath, value);
186 if (host_config.GetString(kXmppLoginConfigPath, &value)) 186 if (host_config.GetString(kXmppLoginConfigPath, &value))
187 config.get()->SetString(kXmppLoginConfigPath, value); 187 config.get()->SetString(kXmppLoginConfigPath, value);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 const CompletionCallback& done) { 220 const CompletionCallback& done) {
221 config->SetBoolean(kUsageStatsConsentConfigPath, consent); 221 config->SetBoolean(kUsageStatsConsentConfigPath, consent);
222 std::string config_data; 222 std::string config_data;
223 base::JSONWriter::Write(config.get(), &config_data); 223 base::JSONWriter::Write(config.get(), &config_data);
224 ShowPreferencePane(config_data, done); 224 ShowPreferencePane(config_data, done);
225 } 225 }
226 226
227 void DaemonControllerMac::DoUpdateConfig( 227 void DaemonControllerMac::DoUpdateConfig(
228 scoped_ptr<base::DictionaryValue> config, 228 scoped_ptr<base::DictionaryValue> config,
229 const CompletionCallback& done_callback) { 229 const CompletionCallback& done_callback) {
230 FilePath config_file_path(kHostConfigFilePath); 230 base::FilePath config_file_path(kHostConfigFilePath);
231 JsonHostConfig config_file(config_file_path); 231 JsonHostConfig config_file(config_file_path);
232 if (!config_file.Read()) { 232 if (!config_file.Read()) {
233 done_callback.Run(RESULT_FAILED); 233 done_callback.Run(RESULT_FAILED);
234 return; 234 return;
235 } 235 }
236 if (!config_file.CopyFrom(config.get())) { 236 if (!config_file.CopyFrom(config.get())) {
237 LOG(ERROR) << "Failed to update configuration."; 237 LOG(ERROR) << "Failed to update configuration.";
238 done_callback.Run(RESULT_FAILED); 238 done_callback.Run(RESULT_FAILED);
239 return; 239 return;
240 } 240 }
241 241
242 std::string config_data = config_file.GetSerializedData(); 242 std::string config_data = config_file.GetSerializedData();
243 ShowPreferencePane(config_data, done_callback); 243 ShowPreferencePane(config_data, done_callback);
244 } 244 }
245 245
246 void DaemonControllerMac::DoGetUsageStatsConsent( 246 void DaemonControllerMac::DoGetUsageStatsConsent(
247 const GetUsageStatsConsentCallback& callback) { 247 const GetUsageStatsConsentCallback& callback) {
248 bool allowed = false; 248 bool allowed = false;
249 FilePath config_file_path(kHostConfigFilePath); 249 base::FilePath config_file_path(kHostConfigFilePath);
250 JsonHostConfig host_config(config_file_path); 250 JsonHostConfig host_config(config_file_path);
251 if (host_config.Read()) { 251 if (host_config.Read()) {
252 host_config.GetBoolean(kUsageStatsConsentConfigPath, &allowed); 252 host_config.GetBoolean(kUsageStatsConsentConfigPath, &allowed);
253 } 253 }
254 // set_by_policy is not yet supported. 254 // set_by_policy is not yet supported.
255 callback.Run(true, allowed, false /* set_by_policy */); 255 callback.Run(true, allowed, false /* set_by_policy */);
256 } 256 }
257 257
258 void DaemonControllerMac::ShowPreferencePane( 258 void DaemonControllerMac::ShowPreferencePane(
259 const std::string& config_data, const CompletionCallback& done_callback) { 259 const std::string& config_data, const CompletionCallback& done_callback) {
260 if (DoShowPreferencePane(config_data)) { 260 if (DoShowPreferencePane(config_data)) {
261 RegisterForPreferencePaneNotifications(done_callback); 261 RegisterForPreferencePaneNotifications(done_callback);
262 } else { 262 } else {
263 done_callback.Run(RESULT_FAILED); 263 done_callback.Run(RESULT_FAILED);
264 } 264 }
265 } 265 }
266 266
267 bool DaemonControllerMac::DoShowPreferencePane(const std::string& config_data) { 267 bool DaemonControllerMac::DoShowPreferencePane(const std::string& config_data) {
268 if (!config_data.empty()) { 268 if (!config_data.empty()) {
269 FilePath config_path; 269 base::FilePath config_path;
270 if (!file_util::GetTempDir(&config_path)) { 270 if (!file_util::GetTempDir(&config_path)) {
271 LOG(ERROR) << "Failed to get filename for saving configuration data."; 271 LOG(ERROR) << "Failed to get filename for saving configuration data.";
272 return false; 272 return false;
273 } 273 }
274 config_path = config_path.Append(kHostConfigFileName); 274 config_path = config_path.Append(kHostConfigFileName);
275 275
276 int written = file_util::WriteFile(config_path, config_data.data(), 276 int written = file_util::WriteFile(config_path, config_data.data(),
277 config_data.size()); 277 config_data.size());
278 if (written != static_cast<int>(config_data.size())) { 278 if (written != static_cast<int>(config_data.size())) {
279 LOG(ERROR) << "Failed to save configuration data to: " 279 LOG(ERROR) << "Failed to save configuration data to: "
280 << config_path.value(); 280 << config_path.value();
281 return false; 281 return false;
282 } 282 }
283 } 283 }
284 284
285 FilePath pane_path; 285 base::FilePath pane_path;
286 // TODO(lambroslambrou): Use NSPreferencePanesDirectory once we start 286 // TODO(lambroslambrou): Use NSPreferencePanesDirectory once we start
287 // building against SDK 10.6. 287 // building against SDK 10.6.
288 if (!base::mac::GetLocalDirectory(NSLibraryDirectory, &pane_path)) { 288 if (!base::mac::GetLocalDirectory(NSLibraryDirectory, &pane_path)) {
289 LOG(ERROR) << "Failed to get directory for local preference panes."; 289 LOG(ERROR) << "Failed to get directory for local preference panes.";
290 return false; 290 return false;
291 } 291 }
292 pane_path = pane_path.Append("PreferencePanes").Append(kPrefPaneFileName); 292 pane_path = pane_path.Append("PreferencePanes").Append(kPrefPaneFileName);
293 293
294 FSRef pane_path_ref; 294 FSRef pane_path_ref;
295 if (!base::mac::FSRefFromPath(pane_path.value(), &pane_path_ref)) { 295 if (!base::mac::FSRefFromPath(pane_path.value(), &pane_path_ref)) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 376 }
377 } 377 }
378 378
379 } // namespace 379 } // namespace
380 380
381 scoped_ptr<DaemonController> remoting::DaemonController::Create() { 381 scoped_ptr<DaemonController> remoting::DaemonController::Create() {
382 return scoped_ptr<DaemonController>(new DaemonControllerMac()); 382 return scoped_ptr<DaemonController>(new DaemonControllerMac());
383 } 383 }
384 384
385 } // namespace remoting 385 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/setup/daemon_controller_linux.cc ('k') | remoting/host/usage_stats_consent_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698