Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 [self restartPanelIfDifferentVersionInstalled]; | |
| 280 | |
| 279 std::string file; | 281 std::string file; |
| 280 if (!GetTemporaryConfigFilePath(&file)) { | 282 if (!GetTemporaryConfigFilePath(&file)) { |
| 281 LOG(ERROR) << "Failed to get path of configuration data."; | 283 LOG(ERROR) << "Failed to get path of configuration data."; |
| 282 [self showError]; | 284 [self showError]; |
| 283 return; | 285 return; |
| 284 } | 286 } |
| 285 if (access(file.c_str(), F_OK) != 0) | 287 if (access(file.c_str(), F_OK) != 0) |
| 286 return; | 288 return; |
| 287 | 289 |
| 288 scoped_ptr<remoting::JsonHostConfig> new_config_( | 290 scoped_ptr<remoting::JsonHostConfig> new_config_( |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 | 513 |
| 512 - (void)notifyPlugin:(const char*)message { | 514 - (void)notifyPlugin:(const char*)message { |
| 513 NSDistributedNotificationCenter* center = | 515 NSDistributedNotificationCenter* center = |
| 514 [NSDistributedNotificationCenter defaultCenter]; | 516 [NSDistributedNotificationCenter defaultCenter]; |
| 515 NSString* name = [NSString stringWithUTF8String:message]; | 517 NSString* name = [NSString stringWithUTF8String:message]; |
| 516 [center postNotificationName:name | 518 [center postNotificationName:name |
| 517 object:nil | 519 object:nil |
| 518 userInfo:nil]; | 520 userInfo:nil]; |
| 519 } | 521 } |
| 520 | 522 |
| 523 - (void)restartPanelIfDifferentVersionInstalled { | |
| 524 NSBundle* this_bundle = [NSBundle bundleForClass:[self class]]; | |
| 525 NSDictionary* this_plist = [this_bundle infoDictionary]; | |
| 526 NSString* this_version = [this_plist objectForKey:@"CFBundleVersion"]; | |
| 527 | |
| 528 NSString* bundle_path = [this_bundle bundlePath]; | |
| 529 NSString* plist_path = | |
| 530 [bundle_path stringByAppendingString:@"/Contents/Info.plist"]; | |
| 531 NSDictionary* disk_plist = | |
| 532 [NSDictionary dictionaryWithContentsOfFile:plist_path]; | |
| 533 NSString* disk_version = [disk_plist objectForKey:@"CFBundleVersion"]; | |
| 534 | |
| 535 if (disk_version == nil) { | |
| 536 LOG(ERROR) << "Failed to get installed version information"; | |
| 537 [self showError]; | |
| 538 return; | |
| 539 } | |
| 540 | |
| 541 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
| |
| 542 // Terminate and relaunch System Preferences. | |
| 543 | |
| 544 // TODO(lambroslambrou): Improve this when System Preferences supports | |
| 545 // dynamic reloading of pref-panes. | |
| 546 NSTask* task = [[NSTask alloc] init]; | |
| 547 NSArray* arguments = [NSArray arrayWithObjects:@"--launch-prefpane", nil]; | |
| 548 [task setLaunchPath:[NSString stringWithUTF8String:kHelperTool]]; | |
| 549 [task setArguments:arguments]; | |
| 550 [task setStandardInput:[NSPipe pipe]]; | |
| 551 [task launch]; | |
| 552 [task release]; | |
| 553 [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
| |
| 554 } | |
| 555 } | |
| 556 | |
| 521 @end | 557 @end |
| OLD | NEW |