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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/me2me_preference_pane.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "remoting/host/me2me_preference_pane.h" 5 #import "remoting/host/me2me_preference_pane.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <CommonCrypto/CommonHMAC.h> 8 #include <CommonCrypto/CommonHMAC.h>
9 #include <launch.h> 9 #include <launch.h>
10 #import <PreferencePanes/PreferencePanes.h> 10 #import <PreferencePanes/PreferencePanes.h>
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 - (void)updateServiceStatus { 269 - (void)updateServiceStatus {
270 pid_t job_pid = base::mac::PIDForJob(kServiceName); 270 pid_t job_pid = base::mac::PIDForJob(kServiceName);
271 is_service_running_ = (job_pid > 0); 271 is_service_running_ = (job_pid > 0);
272 } 272 }
273 273
274 - (void)updateAuthorizationStatus { 274 - (void)updateAuthorizationStatus {
275 is_pane_unlocked_ = [authorization_view_ updateStatus:authorization_view_]; 275 is_pane_unlocked_ = [authorization_view_ updateStatus:authorization_view_];
276 } 276 }
277 277
278 - (void)readNewConfig { 278 - (void)readNewConfig {
279 if ([self restartPanelIfDifferentVersionInstalled]) {
280 // Don't read any new config if the version is mismatched. Return control
281 // to the main run-loop instead, so the application can be terminated.
282 return;
283 }
284
279 std::string file; 285 std::string file;
280 if (!GetTemporaryConfigFilePath(&file)) { 286 if (!GetTemporaryConfigFilePath(&file)) {
281 LOG(ERROR) << "Failed to get path of configuration data."; 287 LOG(ERROR) << "Failed to get path of configuration data.";
282 [self showError]; 288 [self showError];
283 return; 289 return;
284 } 290 }
285 if (access(file.c_str(), F_OK) != 0) 291 if (access(file.c_str(), F_OK) != 0)
286 return; 292 return;
287 293
288 scoped_ptr<remoting::JsonHostConfig> new_config_( 294 scoped_ptr<remoting::JsonHostConfig> new_config_(
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 517
512 - (void)notifyPlugin:(const char*)message { 518 - (void)notifyPlugin:(const char*)message {
513 NSDistributedNotificationCenter* center = 519 NSDistributedNotificationCenter* center =
514 [NSDistributedNotificationCenter defaultCenter]; 520 [NSDistributedNotificationCenter defaultCenter];
515 NSString* name = [NSString stringWithUTF8String:message]; 521 NSString* name = [NSString stringWithUTF8String:message];
516 [center postNotificationName:name 522 [center postNotificationName:name
517 object:nil 523 object:nil
518 userInfo:nil]; 524 userInfo:nil];
519 } 525 }
520 526
527 - (BOOL)restartPanelIfDifferentVersionInstalled {
528 NSBundle* this_bundle = [NSBundle bundleForClass:[self class]];
529 NSDictionary* this_plist = [this_bundle infoDictionary];
530 NSString* this_version = [this_plist objectForKey:@"CFBundleVersion"];
531
532 NSString* bundle_path = [this_bundle bundlePath];
533 NSString* plist_path =
534 [bundle_path stringByAppendingString:@"/Contents/Info.plist"];
535 NSDictionary* disk_plist =
536 [NSDictionary dictionaryWithContentsOfFile:plist_path];
537 NSString* disk_version = [disk_plist objectForKey:@"CFBundleVersion"];
538
539 if (disk_version == nil) {
540 LOG(ERROR) << "Failed to get installed version information";
541 [self showError];
542 return NO;
543 }
544
545 if ([this_version isEqualToString:disk_version]) {
546 return NO;
547 } else {
548 // Terminate and relaunch System Preferences.
549
550 // TODO(lambroslambrou): Improve this when System Preferences supports
551 // dynamic reloading of pref-panes.
552 NSTask* task = [[NSTask alloc] init];
553 NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil];
554 [task setLaunchPath:[NSString stringWithUTF8String:kHelperTool]];
555 [task setArguments:arguments];
556 [task setStandardInput:[NSPipe pipe]];
557 [task launch];
558 [task release];
559 [NSApp terminate:nil];
560 return YES;
561 }
562 }
563
521 @end 564 @end
OLDNEW
« 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