Index: remoting/host/plugin/daemon_controller_mac.cc |
diff --git a/remoting/host/plugin/daemon_controller_mac.cc b/remoting/host/plugin/daemon_controller_mac.cc |
index 2edd16217532cf74f875ffa54b98672d2c4c1264..61e8575df4c54305ed4dd8cd42ab1c1a16055de7 100644 |
--- a/remoting/host/plugin/daemon_controller_mac.cc |
+++ b/remoting/host/plugin/daemon_controller_mac.cc |
@@ -20,6 +20,7 @@ |
#include "base/mac/mac_logging.h" |
#include "base/mac/mac_util.h" |
#include "base/mac/scoped_launch_data.h" |
+#include "base/sys_string_conversions.h" |
#include "base/threading/thread.h" |
#include "base/time.h" |
#include "base/values.h" |
@@ -43,6 +44,13 @@ const int NSLibraryDirectory = 5; |
// The preferences panel is not yet sandboxed, but err on the side of caution. |
#define kUpdateSucceededNotificationName kServiceName ".update_succeeded" |
#define kUpdateFailedNotificationName kServiceName ".update_failed" |
+#define kUserCanceledNotificationName kServiceName ".user_canceled" |
+ |
+const char* all_notifications[] = { |
+ kUpdateSucceededNotificationName, |
+ kUpdateFailedNotificationName, |
+ kUserCanceledNotificationName |
+}; |
#define kConfigDir "/Library/PrivilegedHelperTools/" |
@@ -110,16 +118,15 @@ DaemonControllerMac::~DaemonControllerMac() { |
} |
void DaemonControllerMac::DeregisterForPreferencePaneNotifications() { |
- CFNotificationCenterRemoveObserver( |
- CFNotificationCenterGetDistributedCenter(), |
- this, |
- CFSTR(kUpdateSucceededNotificationName), |
- NULL); |
- CFNotificationCenterRemoveObserver( |
- CFNotificationCenterGetDistributedCenter(), |
- this, |
- CFSTR(kUpdateFailedNotificationName), |
- NULL); |
+ for (size_t i = 0; i < arraysize(all_notifications); i++) { |
+ base::mac::ScopedCFTypeRef<CFStringRef> cfstring( |
+ base::SysUTF8ToCFStringRef(all_notifications[i])); |
+ CFNotificationCenterRemoveObserver( |
+ CFNotificationCenterGetDistributedCenter(), |
+ this, |
+ cfstring, |
+ NULL); |
+ } |
} |
DaemonController::State DaemonControllerMac::GetState() { |
@@ -325,20 +332,17 @@ void DaemonControllerMac::RegisterForPreferencePaneNotifications( |
DCHECK(current_callback_.is_null()); |
current_callback_ = done_callback; |
- CFNotificationCenterAddObserver( |
- CFNotificationCenterGetDistributedCenter(), |
- this, |
- &DaemonControllerMac::PreferencePaneCallback, |
- CFSTR(kUpdateSucceededNotificationName), |
- NULL, |
- CFNotificationSuspensionBehaviorDeliverImmediately); |
- CFNotificationCenterAddObserver( |
- CFNotificationCenterGetDistributedCenter(), |
- this, |
- &DaemonControllerMac::PreferencePaneCallback, |
- CFSTR(kUpdateFailedNotificationName), |
- NULL, |
- CFNotificationSuspensionBehaviorDeliverImmediately); |
+ for (size_t i = 0; i < arraysize(all_notifications); i++) { |
+ base::mac::ScopedCFTypeRef<CFStringRef> cfstring( |
+ base::SysUTF8ToCFStringRef(all_notifications[i])); |
+ CFNotificationCenterAddObserver( |
+ CFNotificationCenterGetDistributedCenter(), |
+ this, |
+ &DaemonControllerMac::PreferencePaneCallback, |
+ cfstring, |
+ NULL, |
+ CFNotificationSuspensionBehaviorDeliverImmediately); |
+ } |
} |
void DaemonControllerMac::PreferencePaneCallbackDelegate(CFStringRef name) { |
@@ -348,6 +352,9 @@ void DaemonControllerMac::PreferencePaneCallbackDelegate(CFStringRef name) { |
result = RESULT_OK; |
} else if (CFStringCompare(name, CFSTR(kUpdateFailedNotificationName), 0) == |
kCFCompareEqualTo) { |
+ result = RESULT_FAILED; |
+ } else if (CFStringCompare(name, CFSTR(kUserCanceledNotificationName), 0) == |
+ kCFCompareEqualTo) { |
result = RESULT_CANCELLED; |
} else { |
LOG(WARNING) << "Ignoring unexpected notification: " << name; |