| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Implementation of a work item that replaces the contents of one registry key |
| 6 // with that of another (i.e., the destination is erased prior to the copy). |
| 7 |
| 5 #include "chrome/installer/util/copy_reg_key_work_item.h" | 8 #include "chrome/installer/util/copy_reg_key_work_item.h" |
| 6 | 9 |
| 7 #include <shlwapi.h> | 10 #include <shlwapi.h> |
| 8 | 11 |
| 9 #include "base/logging.h" | 12 #include "base/logging.h" |
| 10 #include "base/win/registry.h" | 13 #include "base/win/registry.h" |
| 11 | 14 |
| 12 using base::win::RegKey; | 15 using base::win::RegKey; |
| 13 | 16 |
| 14 CopyRegKeyWorkItem::~CopyRegKeyWorkItem() { | 17 CopyRegKeyWorkItem::~CopyRegKeyWorkItem() { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } else { | 76 } else { |
| 74 result = SHCopyKey(predefined_root_, source_key_path_.c_str(), | 77 result = SHCopyKey(predefined_root_, source_key_path_.c_str(), |
| 75 dest_key.Handle(), 0); | 78 dest_key.Handle(), 0); |
| 76 switch (result) { | 79 switch (result) { |
| 77 case ERROR_FILE_NOT_FOUND: | 80 case ERROR_FILE_NOT_FOUND: |
| 78 // The source didn't exist, so neither should the destination. | 81 // The source didn't exist, so neither should the destination. |
| 79 dest_key.Close(); | 82 dest_key.Close(); |
| 80 SHDeleteKey(predefined_root_, dest_key_path_.c_str()); | 83 SHDeleteKey(predefined_root_, dest_key_path_.c_str()); |
| 81 // Handle like a success. | 84 // Handle like a success. |
| 82 result = ERROR_SUCCESS; | 85 result = ERROR_SUCCESS; |
| 83 // -- FALL THROUGH TO SUCCESS CASE -- | 86 // -- Fall through to success case. -- |
| 84 case ERROR_SUCCESS: | 87 case ERROR_SUCCESS: |
| 85 break; | 88 break; |
| 86 default: | 89 default: |
| 87 LOG(ERROR) << "Failed to copy key from " << source_key_path_ << " to " | 90 LOG(ERROR) << "Failed to copy key from " << source_key_path_ << " to " |
| 88 << dest_key_path_ << ", result: " << result; | 91 << dest_key_path_ << ", result: " << result; |
| 89 break; | 92 break; |
| 90 } | 93 } |
| 91 } | 94 } |
| 92 } | 95 } |
| 93 | 96 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 106 LOG(ERROR) << "Failed to delete key at " << dest_key_path_ | 109 LOG(ERROR) << "Failed to delete key at " << dest_key_path_ |
| 107 << " in rollback, result: " << result; | 110 << " in rollback, result: " << result; |
| 108 } | 111 } |
| 109 | 112 |
| 110 // Restore the old contents. The restoration takes on its default security | 113 // Restore the old contents. The restoration takes on its default security |
| 111 // attributes; any custom attributes are lost. | 114 // attributes; any custom attributes are lost. |
| 112 if (!backup_.WriteTo(predefined_root_, dest_key_path_.c_str())) | 115 if (!backup_.WriteTo(predefined_root_, dest_key_path_.c_str())) |
| 113 LOG(ERROR) << "Failed to restore key in rollback."; | 116 LOG(ERROR) << "Failed to restore key in rollback."; |
| 114 } | 117 } |
| 115 } | 118 } |
| OLD | NEW |