| 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/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/win/registry.h" | 9 #include "base/win/registry.h" |
| 10 #include "chrome/installer/util/registry_entry.h" | 10 #include "chrome/installer/util/registry_entry.h" |
| 11 #include "chrome/installer/util/shell_util.h" | 11 #include "chrome/installer/util/shell_util.h" |
| 12 | 12 |
| 13 ScopedUserProtocolEntry::ScopedUserProtocolEntry() { | 13 ScopedUserProtocolEntry::ScopedUserProtocolEntry(const wchar_t* protocol) { |
| 14 entries_.push_back(new RegistryEntry( | 14 entries_.push_back(new RegistryEntry( |
| 15 base::FilePath(ShellUtil::kRegClasses).Append(L"http").value(), | 15 base::FilePath(ShellUtil::kRegClasses).Append(protocol).value(), |
| 16 ShellUtil::kRegUrlProtocol, base::string16())); | 16 ShellUtil::kRegUrlProtocol, base::string16())); |
| 17 if (!entries_.back()->KeyExistsInRegistry(RegistryEntry::LOOK_IN_HKCU) && | 17 if (!entries_.back()->KeyExistsInRegistry(RegistryEntry::LOOK_IN_HKCU) && |
| 18 ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries_)) { | 18 ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries_)) { |
| 19 return; | 19 return; |
| 20 } | 20 } |
| 21 entries_.clear(); | 21 entries_.clear(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 ScopedUserProtocolEntry::~ScopedUserProtocolEntry() { | 24 ScopedUserProtocolEntry::~ScopedUserProtocolEntry() { |
| 25 // The empty key is deleted only if it's created by ctor(). | 25 // The empty key is deleted only if it's created by ctor(). |
| (...skipping 14 matching lines...) Expand all Loading... |
| 40 // There is no subkey. | 40 // There is no subkey. |
| 41 if (base::win::RegistryKeyIterator(HKEY_CURRENT_USER, | 41 if (base::win::RegistryKeyIterator(HKEY_CURRENT_USER, |
| 42 entries_.back()->key_path().c_str()) | 42 entries_.back()->key_path().c_str()) |
| 43 .SubkeyCount() > 0) { | 43 .SubkeyCount() > 0) { |
| 44 return; | 44 return; |
| 45 } | 45 } |
| 46 | 46 |
| 47 entries_.back()->set_removal_flag(RegistryEntry::RemovalFlag::KEY); | 47 entries_.back()->set_removal_flag(RegistryEntry::RemovalFlag::KEY); |
| 48 ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries_); | 48 ShellUtil::AddRegistryEntries(HKEY_CURRENT_USER, entries_); |
| 49 } | 49 } |
| OLD | NEW |