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

Unified Diff: remoting/host/me2me_preference_pane.mm

Issue 10413065: Restart Mac pref-pane if version mismatch detected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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/me2me_preference_pane.mm
diff --git a/remoting/host/me2me_preference_pane.mm b/remoting/host/me2me_preference_pane.mm
index da116af5a7340f9e05f5d9168e2fc116009a630c..5eaff5cb9d973a3e289c3c8c7f07929911f8ef53 100644
--- a/remoting/host/me2me_preference_pane.mm
+++ b/remoting/host/me2me_preference_pane.mm
@@ -276,6 +276,8 @@ std::string JsonHostConfig::GetSerializedData() const {
}
- (void)readNewConfig {
+ [self restartPanelIfDifferentVersionInstalled];
+
std::string file;
if (!GetTemporaryConfigFilePath(&file)) {
LOG(ERROR) << "Failed to get path of configuration data.";
@@ -518,4 +520,38 @@ std::string JsonHostConfig::GetSerializedData() const {
userInfo:nil];
}
+- (void)restartPanelIfDifferentVersionInstalled {
+ NSBundle* this_bundle = [NSBundle bundleForClass:[self class]];
+ NSDictionary* this_plist = [this_bundle infoDictionary];
+ NSString* this_version = [this_plist objectForKey:@"CFBundleVersion"];
+
+ NSString* bundle_path = [this_bundle bundlePath];
+ NSString* plist_path =
+ [bundle_path stringByAppendingString:@"/Contents/Info.plist"];
+ NSDictionary* disk_plist =
+ [NSDictionary dictionaryWithContentsOfFile:plist_path];
+ NSString* disk_version = [disk_plist objectForKey:@"CFBundleVersion"];
+
+ if (disk_version == nil) {
+ LOG(ERROR) << "Failed to get installed version information";
+ [self showError];
+ return;
+ }
+
+ if (![this_version isEqualToString:disk_version]) {
Jamie 2012/05/23 01:17:17 Optional: My ObjC knowledge is not enough to know
Lambros 2012/05/24 00:54:50 I'm not sure which method is better, so I'll leave
+ // Terminate and relaunch System Preferences.
+
+ // TODO(lambroslambrou): Improve this when System Preferences supports
+ // dynamic reloading of pref-panes.
+ NSTask* task = [[NSTask alloc] init];
+ NSArray* arguments = [NSArray arrayWithObjects:@"--launch-prefpane", nil];
+ [task setLaunchPath:[NSString stringWithUTF8String:kHelperTool]];
+ [task setArguments:arguments];
+ [task setStandardInput:[NSPipe pipe]];
+ [task launch];
+ [task release];
+ [NSApp terminate:nil];
dcaiafa 2012/05/23 17:16:19 I don't think terminate: is like exit(). The code
Lambros 2012/05/24 00:54:50 Good catch! The following code would've loaded an
+ }
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698