| 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/mac/me2me_preference_pane.h" | 5 #import "remoting/host/mac/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 <errno.h> | 9 #include <errno.h> |
| 10 #include <launch.h> | 10 #include <launch.h> |
| 11 #import <PreferencePanes/PreferencePanes.h> | 11 #import <PreferencePanes/PreferencePanes.h> |
| 12 #import <SecurityInterface/SFAuthorizationView.h> | 12 #import <SecurityInterface/SFAuthorizationView.h> |
| 13 #include <stddef.h> | 13 #include <stddef.h> |
| 14 #include <stdlib.h> | 14 #include <stdlib.h> |
| 15 #include <unistd.h> | 15 #include <unistd.h> |
| 16 | 16 |
| 17 #include <fstream> | 17 #include <fstream> |
| 18 #include <memory> | 18 #include <memory> |
| 19 | 19 |
| 20 #include "base/files/file_util.h" | |
| 21 #include "base/mac/authorization_util.h" | 20 #include "base/mac/authorization_util.h" |
| 22 #include "base/mac/launchd.h" | 21 #include "base/mac/launchd.h" |
| 23 #include "base/mac/mac_logging.h" | 22 #include "base/mac/mac_logging.h" |
| 24 #include "base/mac/scoped_launch_data.h" | 23 #include "base/mac/scoped_launch_data.h" |
| 25 #include "base/posix/eintr_wrapper.h" | 24 #include "base/posix/eintr_wrapper.h" |
| 26 #include "remoting/host/host_config.h" | 25 #include "remoting/host/host_config.h" |
| 27 #include "remoting/host/mac/constants_mac.h" | 26 #include "remoting/host/mac/constants_mac.h" |
| 28 #import "remoting/host/mac/me2me_preference_pane_confirm_pin.h" | 27 #import "remoting/host/mac/me2me_preference_pane_confirm_pin.h" |
| 29 #import "remoting/host/mac/me2me_preference_pane_disable.h" | 28 #import "remoting/host/mac/me2me_preference_pane_disable.h" |
| 30 #include "remoting/host/pin_hash.h" | 29 #include "remoting/host/pin_hash.h" |
| 31 #include "third_party/jsoncpp/source/include/json/reader.h" | 30 #include "third_party/jsoncpp/source/include/json/reader.h" |
| 32 #include "third_party/jsoncpp/source/include/json/writer.h" | 31 #include "third_party/jsoncpp/source/include/json/writer.h" |
| 33 | 32 |
| 34 namespace { | 33 namespace { |
| 35 | 34 |
| 36 bool GetTemporaryConfigFilePath(std::string* path) { | 35 bool GetTemporaryConfigFilePath(std::string* path) { |
| 37 base::FilePath ret; | 36 NSString* filename = NSTemporaryDirectory(); |
| 37 if (filename == nil) |
| 38 return false; |
| 38 | 39 |
| 39 if (!base::GetTempPath(&ret)) { | 40 *path = [[NSString stringWithFormat:@"%@/%s", |
| 40 return false; | 41 filename, remoting::kHostConfigFileName] UTF8String]; |
| 41 } | |
| 42 | |
| 43 ret = ret.Append(remoting::kHostConfigFileName); | |
| 44 | |
| 45 // This should be safe on OS X because utf8 is always supported. | |
| 46 *path = ret.AsUTF8Unsafe(); | |
| 47 return true; | 42 return true; |
| 48 } | 43 } |
| 49 | 44 |
| 50 bool IsConfigValid(const remoting::JsonHostConfig* config) { | 45 bool IsConfigValid(const remoting::JsonHostConfig* config) { |
| 51 std::string value; | 46 std::string value; |
| 52 return (config->GetString(remoting::kHostIdConfigPath, &value) && | 47 return (config->GetString(remoting::kHostIdConfigPath, &value) && |
| 53 config->GetString(remoting::kHostSecretHashConfigPath, &value) && | 48 config->GetString(remoting::kHostSecretHashConfigPath, &value) && |
| 54 config->GetString(remoting::kXmppLoginConfigPath, &value)); | 49 config->GetString(remoting::kXmppLoginConfigPath, &value)); |
| 55 } | 50 } |
| 56 | 51 |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil]; | 580 NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil]; |
| 586 [task setLaunchPath:command]; | 581 [task setLaunchPath:command]; |
| 587 [task setArguments:arguments]; | 582 [task setArguments:arguments]; |
| 588 [task setStandardInput:[NSPipe pipe]]; | 583 [task setStandardInput:[NSPipe pipe]]; |
| 589 [task launch]; | 584 [task launch]; |
| 590 [task release]; | 585 [task release]; |
| 591 [NSApp terminate:nil]; | 586 [NSApp terminate:nil]; |
| 592 } | 587 } |
| 593 | 588 |
| 594 @end | 589 @end |
| OLD | NEW |