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

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: Address review comments 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
« no previous file with comments | « remoting/host/me2me_preference_pane.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0412f6dde81826d504a871560682ed7b4020007b 100644
--- a/remoting/host/me2me_preference_pane.mm
+++ b/remoting/host/me2me_preference_pane.mm
@@ -276,6 +276,12 @@ std::string JsonHostConfig::GetSerializedData() const {
}
- (void)readNewConfig {
+ if ([self restartPanelIfDifferentVersionInstalled]) {
+ // Don't read any new config if the version is mismatched. Return control
+ // to the main run-loop instead, so the application can be terminated.
+ return;
+ }
+
std::string file;
if (!GetTemporaryConfigFilePath(&file)) {
LOG(ERROR) << "Failed to get path of configuration data.";
@@ -518,4 +524,41 @@ std::string JsonHostConfig::GetSerializedData() const {
userInfo:nil];
}
+- (BOOL)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 NO;
+ }
+
+ if ([this_version isEqualToString:disk_version]) {
+ return NO;
+ } else {
+ // 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:@"--relaunch-prefpane", nil];
+ [task setLaunchPath:[NSString stringWithUTF8String:kHelperTool]];
+ [task setArguments:arguments];
+ [task setStandardInput:[NSPipe pipe]];
+ [task launch];
+ [task release];
+ [NSApp terminate:nil];
+ return YES;
+ }
+}
+
@end
« no previous file with comments | « remoting/host/me2me_preference_pane.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698