// Add a custom task to jump list.
void SetUserTasks(const std::vector<UserTask>& tasks);
- // Set the application user model ID, called when "SetName" is called.
- void SetAppUserModelID(const std::string& name);
+ // Set the application user model ID.
+ void SetAppUserModelID(const base::string16& name);
+
+ // Returns the application user model ID, if there isn't one, then create
+ // one from app's name.
+ // The returned string managed by Browser, and should not be modified.
+ PCWSTR GetAppUserModelID();
#endif
// Tell the application to open a file.
if (SUCCEEDED(hr)) {
SHARDAPPIDINFO info;
info.psi = item;
- info.pszAppID = app_user_model_id_.c_str();
+ info.pszAppID = GetAppUserModelID();
SHAddToRecentDocs(SHARD_APPIDINFO, &info);
}
}
if (FAILED(destinations.CoCreateInstance(CLSID_ApplicationDestinations,
NULL, CLSCTX_INPROC_SERVER)))
return;
- if (FAILED(destinations->SetAppID(app_user_model_id_.c_str())))
+ if (FAILED(destinations->SetAppID(GetAppUserModelID())))
return;
destinations->RemoveAllDestinations();
}
CComPtr<ICustomDestinationList> destinations;
if (FAILED(destinations.CoCreateInstance(CLSID_DestinationList)))
return;
- if (FAILED(destinations->SetAppID(app_user_model_id_.c_str())))
+ if (FAILED(destinations->SetAppID(GetAppUserModelID())))
return;
// Start a transaction that updates the JumpList of this application.
destinations->CommitList();
}
-void Browser::SetAppUserModelID(const std::string& name) {
- app_user_model_id_ = base::string16(L"electron.app.");
- app_user_model_id_ += base::UTF8ToUTF16(name);
+void Browser::SetAppUserModelID(const base::string16& name) {
+ app_user_model_id_ = name;
SetCurrentProcessExplicitAppUserModelID(app_user_model_id_.c_str());
}
+PCWSTR Browser::GetAppUserModelID() {
+ if (app_user_model_id_.empty())
+ SetAppUserModelID(base::UTF8ToUTF16(GetName()));
+
+ return app_user_model_id_.c_str();
+}
+
std::string Browser::GetExecutableFileVersion() const {
base::FilePath path;
if (PathService::Get(base::FILE_EXE, &path)) {