summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 21:42:20 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-19 21:42:20 +0000
commit068d487c7a5e00d44097e976a3d14a5a15a68600 (patch)
tree74972f0179425f3f63eca3d7d6dbd31949b7e49d /remoting
parente45877d94e91ed0fab6478370f13f43d8aa174ed (diff)
downloadchromium_src-068d487c7a5e00d44097e976a3d14a5a15a68600.zip
chromium_src-068d487c7a5e00d44097e976a3d14a5a15a68600.tar.gz
chromium_src-068d487c7a5e00d44097e976a3d14a5a15a68600.tar.bz2
Pull Mac Chromoting Host constants into a header file
Many definitions were shared between the Mac pref-pane and the DaemonController (and also the uninstaller app). This CL consolidates them into one place. BUG=none TEST=compiles Review URL: https://chromiumcodereview.appspot.com/10557026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/host/constants_mac.cc11
-rw-r--r--remoting/host/constants_mac.h29
-rw-r--r--remoting/host/installer/mac/uninstaller/remoting_uninstaller.mm18
-rw-r--r--remoting/host/me2me_preference_pane.mm25
-rw-r--r--remoting/host/plugin/daemon_controller_mac.cc19
-rw-r--r--remoting/remoting.gyp4
6 files changed, 63 insertions, 43 deletions
diff --git a/remoting/host/constants_mac.cc b/remoting/host/constants_mac.cc
new file mode 100644
index 0000000..0f7ee1a
--- /dev/null
+++ b/remoting/host/constants_mac.cc
@@ -0,0 +1,11 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/constants_mac.h"
+
+namespace remoting {
+
+const char kHostHelperTool[] = kHostConfigDir kServiceName ".me2me.sh";
+
+} // namespace remoting
diff --git a/remoting/host/constants_mac.h b/remoting/host/constants_mac.h
new file mode 100644
index 0000000..25fd314
--- /dev/null
+++ b/remoting/host/constants_mac.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_CONSTANTS_MAC_H_
+#define REMOTING_HOST_CONSTANTS_MAC_H_
+
+namespace remoting {
+
+// The name of the Remoting Host service that is registered with launchd.
+#define kServiceName "org.chromium.chromoting"
+
+// Use separate named notifications for success and failure because sandboxed
+// components can't include a dictionary when sending distributed notifications.
+// 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 kHostConfigDir "/Library/PrivilegedHelperTools/"
+
+// This helper tool is executed as root to enable/disable/configure the host
+// service.
+// It is also used (as non-root) to provide version information for the
+// installed host components.
+extern const char kHostHelperTool[];
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_CONSTANTS_MAC_H_
diff --git a/remoting/host/installer/mac/uninstaller/remoting_uninstaller.mm b/remoting/host/installer/mac/uninstaller/remoting_uninstaller.mm
index 3ff7fb4..fb3745c 100644
--- a/remoting/host/installer/mac/uninstaller/remoting_uninstaller.mm
+++ b/remoting/host/installer/mac/uninstaller/remoting_uninstaller.mm
@@ -8,6 +8,7 @@
#include "base/mac/scoped_authorizationref.h"
#include "base/mac/scoped_cftyperef.h"
+#include "remoting/host/constants_mac.h"
@implementation RemotingUninstallerAppDelegate
@@ -16,8 +17,7 @@ NSString* const kPrefPaneDir = @"/Library/PreferencePanes";
NSString* const kHelperToolsDir = @"/Library/PrivilegedHelperTools";
NSString* const kApplicationDir = @"/Applications";
-NSString* const kServiceName = @"org.chromium.chromoting";
-NSString* const kPrefPaneName = @"org.chromium.chromoting.prefPane";
+NSString* const kPrefPaneName = @kServiceName ".prefPane";
NSString* const kUninstallerName =
@"Chrome Remote Desktop Host Uninstaller.app";
@@ -134,11 +134,11 @@ const char kKeystonePID[] = "com.google.chrome_remote_desktop";
-(void)shutdownService {
NSString* launchCtl = @"/bin/launchctl";
NSArray* argsStop = [NSArray arrayWithObjects:@"stop",
- kServiceName, nil];
+ @kServiceName, nil];
[self runCommand:launchCtl withArguments:argsStop];
NSString* plist = [NSString stringWithFormat:@"%@/%@.plist",
- kLaunchAgentsDir, kServiceName];
+ kLaunchAgentsDir, @kServiceName];
if ([[NSFileManager defaultManager] fileExistsAtPath:plist]) {
NSArray* argsUnload = [NSArray arrayWithObjects:@"unload",
@"-w", @"-S", @"Aqua", plist, nil];
@@ -153,25 +153,25 @@ const char kKeystonePID[] = "com.google.chrome_remote_desktop";
-(void)remotingUninstallUsingAuth:(AuthorizationRef)authRef {
NSString* host_enabled = [NSString stringWithFormat:@"%@/%@.me2me_enabled",
- kHelperToolsDir, kServiceName];
+ kHelperToolsDir, @kServiceName];
[self sudoDelete:[host_enabled UTF8String] usingAuth:authRef];
[self shutdownService];
NSString* plist = [NSString stringWithFormat:@"%@/%@.plist",
- kLaunchAgentsDir, kServiceName];
+ kLaunchAgentsDir, @kServiceName];
[self sudoDelete:[plist UTF8String] usingAuth:authRef];
NSString* host_binary = [NSString stringWithFormat:@"%@/%@.me2me_host.app",
- kHelperToolsDir, kServiceName];
+ kHelperToolsDir, @kServiceName];
[self sudoDelete:[host_binary UTF8String] usingAuth:authRef];
NSString* host_script = [NSString stringWithFormat:@"%@/%@.me2me.sh",
- kHelperToolsDir, kServiceName];
+ kHelperToolsDir, @kServiceName];
[self sudoDelete:[host_script UTF8String] usingAuth:authRef];
NSString* auth = [NSString stringWithFormat:@"%@/%@.json",
- kHelperToolsDir, kServiceName];
+ kHelperToolsDir, @kServiceName];
[self sudoDelete:[auth UTF8String] usingAuth:authRef];
NSString* prefpane = [NSString stringWithFormat:@"%@/%@",
diff --git a/remoting/host/me2me_preference_pane.mm b/remoting/host/me2me_preference_pane.mm
index c360c4b..a167b08 100644
--- a/remoting/host/me2me_preference_pane.mm
+++ b/remoting/host/me2me_preference_pane.mm
@@ -18,6 +18,7 @@
#include "base/eintr_wrapper.h"
#include "base/mac/scoped_launch_data.h"
#include "base/memory/scoped_ptr.h"
+#include "remoting/host/constants_mac.h"
#include "remoting/host/host_config.h"
#import "remoting/host/me2me_preference_pane_confirm_pin.h"
#import "remoting/host/me2me_preference_pane_disable.h"
@@ -26,21 +27,6 @@
#include "third_party/modp_b64/modp_b64.h"
namespace {
-// The name of the Remoting Host service that is registered with launchd.
-#define kServiceName "org.chromium.chromoting"
-
-// Use separate named notifications for success and failure because sandboxed
-// components can't include a dictionary when sending distributed notifications.
-// 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 kConfigDir "/Library/PrivilegedHelperTools/"
-
-// This helper script is executed as root. It is passed a command-line option
-// (--enable or --disable), which causes it to create or remove a file that
-// informs the host's launch script of whether the host is enabled or disabled.
-const char kHelperTool[] = kConfigDir kServiceName ".me2me.sh";
bool GetTemporaryConfigFilePath(std::string* path) {
NSString* filename = NSTemporaryDirectory();
@@ -572,7 +558,7 @@ std::string JsonHostConfig::GetSerializedData() const {
pid_t pid;
OSStatus status = base::mac::ExecuteWithPrivilegesAndGetPID(
authorization,
- kHelperTool,
+ remoting::kHostHelperTool,
kAuthorizationFlagDefaults,
arguments,
&pipe,
@@ -632,7 +618,8 @@ std::string JsonHostConfig::GetSerializedData() const {
if (WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == 0) {
return YES;
} else {
- NSLog(@"%s failed with exit status %d", kHelperTool, exit_status);
+ NSLog(@"%s failed with exit status %d", remoting::kHostHelperTool,
+ exit_status);
return NO;
}
}
@@ -761,8 +748,10 @@ std::string JsonHostConfig::GetSerializedData() const {
- (void)restartSystemPreferences {
NSTask* task = [[NSTask alloc] init];
+ NSString* command =
+ [NSString stringWithUTF8String:remoting::kHostHelperTool];
NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil];
- [task setLaunchPath:[NSString stringWithUTF8String:kHelperTool]];
+ [task setLaunchPath:command];
[task setArguments:arguments];
[task setStandardInput:[NSPipe pipe]];
[task launch];
diff --git a/remoting/host/plugin/daemon_controller_mac.cc b/remoting/host/plugin/daemon_controller_mac.cc
index 4e23458..9af33cb 100644
--- a/remoting/host/plugin/daemon_controller_mac.cc
+++ b/remoting/host/plugin/daemon_controller_mac.cc
@@ -23,6 +23,7 @@
#include "base/threading/thread.h"
#include "base/time.h"
#include "base/values.h"
+#include "remoting/host/constants_mac.h"
#include "remoting/host/json_host_config.h"
namespace remoting {
@@ -35,25 +36,11 @@ namespace {
// Therefore, we define the needed constants here.
const int NSLibraryDirectory = 5;
-// The name of the Remoting Host service that is registered with launchd.
-#define kServiceName "org.chromium.chromoting"
-
-// Use separate named notifications for success and failure because sandboxed
-// components can't include a dictionary when sending distributed notifications.
-// 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 kConfigDir "/Library/PrivilegedHelperTools/"
-
-// This helper script is used to get the installed host version.
-const char kHostHelperScript[] = kConfigDir kServiceName ".me2me.sh";
-
// Use a single configuration file, instead of separate "auth" and "host" files.
// This is because the SetConfigAndStart() API only provides a single
// dictionary, and splitting this into two dictionaries would require
// knowledge of which keys belong in which files.
-const char kHostConfigFile[] = kConfigDir kServiceName ".json";
+const char kHostConfigFile[] = kHostConfigDir kServiceName ".json";
class DaemonControllerMac : public remoting::DaemonController {
public:
@@ -199,7 +186,7 @@ void DaemonControllerMac::DoGetConfig(const GetConfigCallback& callback) {
void DaemonControllerMac::DoGetVersion(const GetVersionCallback& callback) {
std::string version = "";
- std::string command_line = kHostHelperScript;
+ std::string command_line = remoting::kHostHelperTool;
command_line += " --host-version";
FILE* script_output = popen(command_line.c_str(), "r");
if (script_output) {
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index c1f6d69..7a8f8f3 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -406,6 +406,8 @@
'../third_party/jsoncpp/overrides/src/lib_json/json_value.cpp',
'../third_party/jsoncpp/source/src/lib_json/json_writer.cpp',
'../third_party/modp_b64/modp_b64.cc',
+ 'host/constants_mac.cc',
+ 'host/constants_mac.h',
'host/host_config.cc',
'host/me2me_preference_pane.h',
'host/me2me_preference_pane.mm',
@@ -1120,6 +1122,8 @@
'host/clipboard_mac.mm',
'host/clipboard_win.cc',
'host/constants.h',
+ 'host/constants_mac.cc',
+ 'host/constants_mac.h',
'host/constants_win.cc',
'host/continue_window.h',
'host/continue_window_gtk.cc',