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

Unified Diff: remoting/host/plugin/daemon_controller_mac.cc

Issue 10566013: Detect if user closes the pref-pane without disabling Chromoting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
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;
« remoting/host/me2me_preference_pane.mm ('K') | « remoting/host/me2me_preference_pane.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698