OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #ifndef CRASHPAD_CLIENT_SETTINGS_MAC_H_ |
| 16 #define CRASHPAD_CLIENT_SETTINGS_MAC_H_ |
| 17 |
| 18 #import <Foundation/Foundation.h> |
| 19 |
| 20 #include "base/files/file_path.h" |
| 21 #include "base/mac/scoped_nsobject.h" |
| 22 #include "client/settings.h" |
| 23 #include "util/file/file_io.h" |
| 24 |
| 25 namespace crashpad { |
| 26 namespace internal { |
| 27 |
| 28 //! \brief An implementation of the Settings interface, which stores the values |
| 29 //! in a property list (plist) file. |
| 30 //! |
| 31 //! This class makes use of Foundation, and as such requires the presence of an |
| 32 //! autorelease pool to properly manage memory. |
| 33 class SettingsMac : public Settings { |
| 34 public: |
| 35 explicit SettingsMac(const base::FilePath& prefs_file); |
| 36 ~SettingsMac() override; |
| 37 |
| 38 bool Initialize(); |
| 39 |
| 40 // Settings: |
| 41 bool GetClientID(std::string* client_id) override; |
| 42 bool GetUploadsEnabled(bool* enabled) override; |
| 43 bool SetUploadsEnabled(bool enabled) override; |
| 44 bool GetLastUploadAttemptTime(time_t* time) override; |
| 45 bool SetLastUploadAttemptTime(time_t time) override; |
| 46 |
| 47 private: |
| 48 base::scoped_nsobject<NSMutableDictionary> ReadPlist(FileHandle fd); |
| 49 bool WritePlist(FileHandle fd, NSDictionary* plist); |
| 50 |
| 51 base::scoped_nsobject<id> GetSetting(NSString* key); |
| 52 bool SetSetting(NSString* key, NSObject* value); |
| 53 |
| 54 const char* prefs_file() { return prefs_file_.value().c_str(); }; |
| 55 |
| 56 base::FilePath prefs_file_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(SettingsMac); |
| 59 }; |
| 60 |
| 61 } // namespace internal |
| 62 } // namespace crashpad |
| 63 |
| 64 #endif // CRASHPAD_CLIENT_SETTINGS_MAC_H_ |
OLD | NEW |