Use base::string16 and base::JoinString instead of custom methods
This commit is contained in:
parent
ca971e978e
commit
73246112d2
1 changed files with 11 additions and 17 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "base/win/registry.h"
|
#include "base/win/registry.h"
|
||||||
#include "base/win/windows_version.h"
|
#include "base/win/windows_version.h"
|
||||||
#include "atom/common/atom_version.h"
|
#include "atom/common/atom_version.h"
|
||||||
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -125,38 +126,31 @@ bool Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
|
||||||
return SUCCEEDED(destinations->CommitList());
|
return SUCCEEDED(destinations->CommitList());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetProtocolLaunchPath(std::string protocol, mate::Arguments* args, std::wstring* exe) {
|
bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
|
||||||
// Read in optional exe path arg
|
// Read in optional exe path arg
|
||||||
std::wstring exePath;
|
base::string16 exePath;
|
||||||
std::string rawExePath;
|
|
||||||
|
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
|
|
||||||
if (!args->GetNext(&rawExePath)) {
|
if (!args->GetNext(&exePath)) {
|
||||||
if (!PathService::Get(base::FILE_EXE, &path)) {
|
if (!PathService::Get(base::FILE_EXE, &path)) {
|
||||||
LOG(ERROR) << "Error getting app exe path";
|
LOG(ERROR) << "Error getting app exe path";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Executable Path
|
// Executable Path
|
||||||
exePath = path.value();
|
exePath = path.value();
|
||||||
} else {
|
|
||||||
exePath.assign(rawExePath.begin(), rawExePath.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read in optional args arg
|
// Read in optional args arg
|
||||||
std::vector<std::string> launchArgs;
|
std::vector<base::string16> launchArgs;
|
||||||
args->GetNext(&launchArgs);
|
args->GetNext(&launchArgs);
|
||||||
|
|
||||||
*exe = L"\"" + exePath + L"\" ";
|
|
||||||
|
|
||||||
// Parse launch args into a string of space spearated args
|
// Parse launch args into a string of space spearated args
|
||||||
|
base::string16 launchArgString;
|
||||||
if (launchArgs.size() != 0) {
|
if (launchArgs.size() != 0) {
|
||||||
std::string launchArgString = base::JoinString(launchArgs, " ");
|
launchArgString = base::JoinString(launchArgs, L" ");
|
||||||
std::wstring wLaunchArgString;
|
|
||||||
wLaunchArgString.assign(launchArgString.begin(), launchArgString.end());
|
|
||||||
*exe = *exe + L"\"" + wLaunchArgString + L"\"";
|
|
||||||
}
|
}
|
||||||
*exe = *exe + L"\"%1\"";
|
*exe = base::StringPrintf(L"\"%s\" %s \"%%1\"", exePath.c_str(), launchArgString.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +184,7 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
std::wstring exe;
|
std::wstring exe;
|
||||||
if (!GetProtocolLaunchPath(protocol, args, &exe)) {
|
if (!GetProtocolLaunchPath(args, &exe)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (exe == L"")
|
if (exe == L"")
|
||||||
|
@ -226,7 +220,7 @@ bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::wstring exe;
|
std::wstring exe;
|
||||||
if (!GetProtocolLaunchPath(protocol, args, &exe)) {
|
if (!GetProtocolLaunchPath(args, &exe)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +254,7 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::wstring exe;
|
std::wstring exe;
|
||||||
if (!GetProtocolLaunchPath(protocol, args, &exe)) {
|
if (!GetProtocolLaunchPath(args, &exe)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue