|
@@ -156,12 +156,14 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
|
|
base::string16 keyPath = L"Software\\Classes\\";
|
|
|
|
|
|
// Command Key
|
|
|
- base::string16 protocol16 = base::UTF8ToUTF16(protocol);
|
|
|
- base::string16 cmdPath = keyPath + protocol16 + L"\\shell\\open\\command";
|
|
|
+ base::string16 wprotocol = base::UTF8ToUTF16(protocol);
|
|
|
+ base::string16 shellPath = wprotocol + L"\\shell";
|
|
|
+ base::string16 cmdPath = keyPath + shellPath + L"\\open\\command";
|
|
|
|
|
|
- base::win::RegKey key;
|
|
|
+ base::win::RegKey classesKey;
|
|
|
base::win::RegKey commandKey;
|
|
|
- if (FAILED(key.Open(root, keyPath.c_str(), KEY_ALL_ACCESS)))
|
|
|
+
|
|
|
+ if (FAILED(classesKey.Open(root, keyPath.c_str(), KEY_ALL_ACCESS)))
|
|
|
// Classes key doesn't exist, that's concerning, but I guess we're not the default handler
|
|
|
return true;
|
|
|
|
|
@@ -180,11 +182,22 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
|
|
|
|
|
if (keyVal == exe) {
|
|
|
// Let's kill the key
|
|
|
- if (FAILED(key.DeleteKey(protocol16 + L"shell")))
|
|
|
+ if (FAILED(classesKey.DeleteKey(shellPath.c_str())))
|
|
|
return false;
|
|
|
|
|
|
- // If empty, delete
|
|
|
- key.DeleteEmptyKey(protocol16);
|
|
|
+ // Let's clean up after ourselves
|
|
|
+ base::win::RegKey protocolKey;
|
|
|
+ base::string16 protocolPath = keyPath + wprotocol;
|
|
|
+
|
|
|
+ if (SUCCEEDED(protocolKey.Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) {
|
|
|
+ protocolKey.DeleteValue(L"URL Protocol");
|
|
|
+
|
|
|
+ // Overwrite the default value to be empty, we can't delete it right away
|
|
|
+ protocolKey.WriteValue(L"", L"");
|
|
|
+ }
|
|
|
+
|
|
|
+ // If now empty, delete the whole key
|
|
|
+ classesKey.DeleteEmptyKey(wprotocol.c_str());
|
|
|
|
|
|
return true;
|
|
|
} else {
|