win: Set app user model ID
This ID is used by Windows to identify your application.
This commit is contained in:
parent
78322b5231
commit
528f7bd45f
3 changed files with 24 additions and 1 deletions
|
@ -70,6 +70,10 @@ std::string Browser::GetName() const {
|
||||||
|
|
||||||
void Browser::SetName(const std::string& name) {
|
void Browser::SetName(const std::string& name) {
|
||||||
name_override_ = name;
|
name_override_ = name;
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
SetAppUserModelID(name);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Browser::OpenFile(const std::string& file_path) {
|
bool Browser::OpenFile(const std::string& file_path) {
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
#include "atom/browser/browser_observer.h"
|
#include "atom/browser/browser_observer.h"
|
||||||
#include "atom/browser/window_list_observer.h"
|
#include "atom/browser/window_list_observer.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include "base/strings/string16.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
class FilePath;
|
class FilePath;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +80,11 @@ class Browser : public WindowListObserver {
|
||||||
void DockSetMenu(ui::MenuModel* model);
|
void DockSetMenu(ui::MenuModel* model);
|
||||||
#endif // defined(OS_MACOSX)
|
#endif // defined(OS_MACOSX)
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
// Set the application user model ID, called when "SetName" is called.
|
||||||
|
void SetAppUserModelID(const std::string& name);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Tell the application to open a file.
|
// Tell the application to open a file.
|
||||||
bool OpenFile(const std::string& file_path);
|
bool OpenFile(const std::string& file_path);
|
||||||
|
|
||||||
|
@ -126,6 +135,10 @@ class Browser : public WindowListObserver {
|
||||||
std::string version_override_;
|
std::string version_override_;
|
||||||
std::string name_override_;
|
std::string name_override_;
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
base::string16 app_user_model_id_;
|
||||||
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Browser);
|
DISALLOW_COPY_AND_ASSIGN(Browser);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -54,11 +54,17 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
SHARDAPPIDINFO info;
|
SHARDAPPIDINFO info;
|
||||||
info.psi = item;
|
info.psi = item;
|
||||||
info.pszAppID = L"Atom";
|
info.pszAppID = app_user_model_id_.c_str();
|
||||||
SHAddToRecentDocs(SHARD_APPIDINFO, &info);
|
SHAddToRecentDocs(SHARD_APPIDINFO, &info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Browser::SetAppUserModelID(const std::string& name) {
|
||||||
|
app_user_model_id_ = base::UTF8ToUTF16(
|
||||||
|
base::StringPrintf("atom-shell.app.%s", name));
|
||||||
|
SetCurrentProcessExplicitAppUserModelID(app_user_model_id_.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
std::string Browser::GetExecutableFileVersion() const {
|
std::string Browser::GetExecutableFileVersion() const {
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue