Cleanup the usages of std::wstring
This commit is contained in:
parent
77dfd3a76c
commit
31b82731ac
1 changed files with 19 additions and 32 deletions
|
@ -61,8 +61,6 @@ bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
|
||||||
base::JoinString(launch_args, L" ").c_str());
|
base::JoinString(launch_args, L" ").c_str());
|
||||||
else
|
else
|
||||||
*exe = base::StringPrintf(L"\"%s\" \"%%1\"", exe->c_str());
|
*exe = base::StringPrintf(L"\"%s\" \"%%1\"", exe->c_str());
|
||||||
LOG(ERROR) << *exe;
|
|
||||||
return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,12 +155,10 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||||
|
|
||||||
// Main Registry Key
|
// Main Registry Key
|
||||||
HKEY root = HKEY_CURRENT_USER;
|
HKEY root = HKEY_CURRENT_USER;
|
||||||
std::string keyPathStr = "Software\\Classes\\" + protocol;
|
base::string16 keyPath = base::UTF8ToUTF16("Software\\Classes\\" + protocol);
|
||||||
std::wstring keyPath = std::wstring(keyPathStr.begin(), keyPathStr.end());
|
|
||||||
|
|
||||||
// Command Key
|
// Command Key
|
||||||
std::string cmdPathStr = keyPathStr + "\\shell\\open\\command";
|
base::string16 cmdPath = keyPath + L"\\shell\\open\\command";
|
||||||
std::wstring cmdPath = std::wstring(cmdPathStr.begin(), cmdPathStr.end());
|
|
||||||
|
|
||||||
base::win::RegKey key;
|
base::win::RegKey key;
|
||||||
base::win::RegKey commandKey;
|
base::win::RegKey commandKey;
|
||||||
|
@ -174,12 +170,12 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||||
// Key doesn't even exist, we can confirm that it is not set
|
// Key doesn't even exist, we can confirm that it is not set
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
std::wstring keyVal;
|
base::string16 keyVal;
|
||||||
if (FAILED(commandKey.ReadValue(L"", &keyVal)))
|
if (FAILED(commandKey.ReadValue(L"", &keyVal)))
|
||||||
// Default value not set, we can confirm that it is not set
|
// Default value not set, we can confirm that it is not set
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
std::wstring exe;
|
base::string16 exe;
|
||||||
if (!GetProtocolLaunchPath(args, &exe))
|
if (!GetProtocolLaunchPath(args, &exe))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -213,20 +209,17 @@ bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
||||||
if (protocol.empty())
|
if (protocol.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::wstring exe;
|
base::string16 exe;
|
||||||
if (!GetProtocolLaunchPath(args, &exe))
|
if (!GetProtocolLaunchPath(args, &exe))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Main Registry Key
|
// Main Registry Key
|
||||||
HKEY root = HKEY_CURRENT_USER;
|
HKEY root = HKEY_CURRENT_USER;
|
||||||
std::string keyPathStr = "Software\\Classes\\" + protocol;
|
base::string16 keyPath = base::UTF8ToUTF16("Software\\Classes\\" + protocol);
|
||||||
std::wstring keyPath = std::wstring(keyPathStr.begin(), keyPathStr.end());
|
base::string16 urlDecl = base::UTF8ToUTF16("URL:" + protocol);
|
||||||
std::string urlDeclStr = "URL:" + protocol;
|
|
||||||
std::wstring urlDecl = std::wstring(urlDeclStr.begin(), urlDeclStr.end());
|
|
||||||
|
|
||||||
// Command Key
|
// Command Key
|
||||||
std::string cmdPathStr = keyPathStr + "\\shell\\open\\command";
|
base::string16 cmdPath = keyPath + L"\\shell\\open\\command";
|
||||||
std::wstring cmdPath = std::wstring(cmdPathStr.begin(), cmdPathStr.end());
|
|
||||||
|
|
||||||
// Write information to registry
|
// Write information to registry
|
||||||
base::win::RegKey key(root, keyPath.c_str(), KEY_ALL_ACCESS);
|
base::win::RegKey key(root, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||||
|
@ -246,18 +239,16 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||||
if (protocol.empty())
|
if (protocol.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::wstring exe;
|
base::string16 exe;
|
||||||
if (!GetProtocolLaunchPath(args, &exe))
|
if (!GetProtocolLaunchPath(args, &exe))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Main Registry Key
|
// Main Registry Key
|
||||||
HKEY root = HKEY_CURRENT_USER;
|
HKEY root = HKEY_CURRENT_USER;
|
||||||
std::string keyPathStr = "Software\\Classes\\" + protocol;
|
base::string16 keyPath = base::UTF8ToUTF16("Software\\Classes\\" + protocol);
|
||||||
std::wstring keyPath = std::wstring(keyPathStr.begin(), keyPathStr.end());
|
|
||||||
|
|
||||||
// Command Key
|
// Command Key
|
||||||
std::string cmdPathStr = keyPathStr + "\\shell\\open\\command";
|
base::string16 cmdPath = keyPath + L"\\shell\\open\\command";
|
||||||
std::wstring cmdPath = std::wstring(cmdPathStr.begin(), cmdPathStr.end());
|
|
||||||
|
|
||||||
base::win::RegKey key;
|
base::win::RegKey key;
|
||||||
base::win::RegKey commandKey;
|
base::win::RegKey commandKey;
|
||||||
|
@ -269,17 +260,13 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||||
// Key doesn't exist, we can confirm that it is not set
|
// Key doesn't exist, we can confirm that it is not set
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::wstring keyVal;
|
base::string16 keyVal;
|
||||||
if (FAILED(commandKey.ReadValue(L"", &keyVal)))
|
if (FAILED(commandKey.ReadValue(L"", &keyVal)))
|
||||||
// Default value not set, we can confirm that it is not set
|
// Default value not set, we can confirm that it is not set
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (keyVal == exe) {
|
// Default value is the same as current file path
|
||||||
// Default value is the same as current file path
|
return keyVal == exe;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Browser::SetBadgeCount(int count) {
|
bool Browser::SetBadgeCount(int count) {
|
||||||
|
@ -287,13 +274,13 @@ bool Browser::SetBadgeCount(int count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
||||||
std::wstring keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||||
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||||
|
|
||||||
if (settings.open_at_login) {
|
if (settings.open_at_login) {
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||||
std::wstring exePath(path.value());
|
base::string16 exePath(path.value());
|
||||||
key.WriteValue(GetAppUserModelID(), exePath.c_str());
|
key.WriteValue(GetAppUserModelID(), exePath.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -303,14 +290,14 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
||||||
|
|
||||||
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
|
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
|
||||||
LoginItemSettings settings;
|
LoginItemSettings settings;
|
||||||
std::wstring keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||||
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||||
std::wstring keyVal;
|
base::string16 keyVal;
|
||||||
|
|
||||||
if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) {
|
if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) {
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||||
std::wstring exePath(path.value());
|
base::string16 exePath(path.value());
|
||||||
settings.open_at_login = keyVal == exePath;
|
settings.open_at_login = keyVal == exePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue