Chromium Code Reviews| 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 #import "remoting/host/me2me_preference_pane.h" | 5 #import "remoting/host/me2me_preference_pane.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #include <CommonCrypto/CommonHMAC.h> | 8 #include <CommonCrypto/CommonHMAC.h> |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <launch.h> | 10 #include <launch.h> |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 const char* command = is_service_running_ ? "--save-config" : "--enable"; | 516 const char* command = is_service_running_ ? "--save-config" : "--enable"; |
| 517 if (![self runHelperAsRootWithCommand:command | 517 if (![self runHelperAsRootWithCommand:command |
| 518 inputData:serialized_config]) { | 518 inputData:serialized_config]) { |
| 519 NSLog(@"Failed to run the helper tool"); | 519 NSLog(@"Failed to run the helper tool"); |
| 520 [self showError]; | 520 [self showError]; |
| 521 return; | 521 return; |
| 522 } | 522 } |
| 523 | 523 |
| 524 have_new_config_ = NO; | 524 have_new_config_ = NO; |
| 525 | 525 |
| 526 // If the service is running, send a signal to cause it to reload its | 526 // Start the service. |
|
Wez
2012/08/24 22:20:38
nit: "Ensure the service is started".
alexeypa (please no reviews)
2012/08/27 23:16:41
Done.
| |
| 527 // configuration, otherwise start the service. | 527 if (!is_service_running_) { |
| 528 if (is_service_running_) { | |
| 529 pid_t job_pid = base::mac::PIDForJob(remoting::kServiceName); | |
| 530 if (job_pid > 0) { | |
| 531 kill(job_pid, SIGHUP); | |
| 532 } else { | |
| 533 NSLog(@"Failed to obtain PID of service %s", remoting::kServiceName); | |
| 534 [self showError]; | |
| 535 } | |
| 536 } else { | |
| 537 [self sendJobControlMessage:LAUNCH_KEY_STARTJOB]; | 528 [self sendJobControlMessage:LAUNCH_KEY_STARTJOB]; |
| 538 } | 529 } |
| 539 | 530 |
| 540 // Broadcast a distributed notification to inform the plugin that the | 531 // Broadcast a distributed notification to inform the plugin that the |
| 541 // configuration has been applied. | 532 // configuration has been applied. |
| 542 [self notifyPlugin:UPDATE_SUCCEEDED_NOTIFICATION_NAME]; | 533 [self notifyPlugin:UPDATE_SUCCEEDED_NOTIFICATION_NAME]; |
| 543 } | 534 } |
| 544 | 535 |
| 545 - (BOOL)runHelperAsRootWithCommand:(const char*)command | 536 - (BOOL)runHelperAsRootWithCommand:(const char*)command |
| 546 inputData:(const std::string&)input_data { | 537 inputData:(const std::string&)input_data { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 754 NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil]; | 745 NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil]; |
| 755 [task setLaunchPath:command]; | 746 [task setLaunchPath:command]; |
| 756 [task setArguments:arguments]; | 747 [task setArguments:arguments]; |
| 757 [task setStandardInput:[NSPipe pipe]]; | 748 [task setStandardInput:[NSPipe pipe]]; |
| 758 [task launch]; | 749 [task launch]; |
| 759 [task release]; | 750 [task release]; |
| 760 [NSApp terminate:nil]; | 751 [NSApp terminate:nil]; |
| 761 } | 752 } |
| 762 | 753 |
| 763 @end | 754 @end |
| OLD | NEW |