OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/installer/util/scoped_user_protocol_entry.h" | 5 #include "chrome/installer/util/scoped_user_protocol_entry.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
9 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
10 #include "chrome/installer/util/registry_entry.h" | 11 #include "chrome/installer/util/registry_entry.h" |
11 #include "chrome/installer/util/shell_util.h" | 12 #include "chrome/installer/util/shell_util.h" |
12 | 13 |
13 ScopedUserProtocolEntry::ScopedUserProtocolEntry(const wchar_t* protocol) { | 14 ScopedUserProtocolEntry::ScopedUserProtocolEntry(const wchar_t* protocol) { |
14 entries_.push_back(new RegistryEntry( | 15 entries_.push_back(base::MakeUnique<RegistryEntry>( |
15 base::FilePath(ShellUtil::kRegClasses).Append(protocol).value(), | 16 base::FilePath(ShellUtil::kRegClasses).Append(protocol).value(), |
16 ShellUtil::kRegUrlProtocol, base::string16())); | 17 ShellUtil::kRegUrlProtocol, base::string16())); |
17 if (!entries_.back()->KeyExistsInRegistry(RegistryEntry::LOOK_IN_HKCU) && | 18 if (!entries_.back()->KeyExistsInRegistry(RegistryEntry::LOOK_IN_HKCU) && |
18 ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries_)) { | 19 ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries_)) { |
19 return; | 20 return; |
20 } | 21 } |
21 entries_.clear(); | 22 entries_.clear(); |
22 } | 23 } |
23 | 24 |
24 ScopedUserProtocolEntry::~ScopedUserProtocolEntry() { | 25 ScopedUserProtocolEntry::~ScopedUserProtocolEntry() { |
(...skipping 15 matching lines...) Expand all Loading... |
40 // There is no subkey. | 41 // There is no subkey. |
41 if (base::win::RegistryKeyIterator(HKEY_CURRENT_USER, | 42 if (base::win::RegistryKeyIterator(HKEY_CURRENT_USER, |
42 entries_.back()->key_path().c_str()) | 43 entries_.back()->key_path().c_str()) |
43 .SubkeyCount() > 0) { | 44 .SubkeyCount() > 0) { |
44 return; | 45 return; |
45 } | 46 } |
46 | 47 |
47 entries_.back()->set_removal_flag(RegistryEntry::RemovalFlag::KEY); | 48 entries_.back()->set_removal_flag(RegistryEntry::RemovalFlag::KEY); |
48 ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries_); | 49 ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries_); |
49 } | 50 } |
OLD | NEW |