win: Set app user model ID in one place

Fix #3297.
Fix #2573.
This commit is contained in:
Cheng Zhao 2015-11-03 15:09:31 +08:00
Родитель 7c7a7b96de
Коммит 9047f81835
6 изменённых файлов: 16 добавлений и 21 удалений

Просмотреть файл

@ -7,10 +7,6 @@
#include <string>
#include <vector>
#if defined(OS_WIN)
#include <shlobj.h>
#endif
#include "atom/browser/api/atom_api_menu.h"
#include "atom/browser/api/atom_api_session.h"
#include "atom/browser/api/atom_api_web_contents.h"
@ -299,13 +295,6 @@ void App::SetDesktopName(const std::string& desktop_name) {
#endif
}
void App::SetAppUserModelId(const std::string& app_id) {
#if defined(OS_WIN)
base::string16 app_id_utf16 = base::UTF8ToUTF16(app_id);
SetCurrentProcessExplicitAppUserModelID(app_id_utf16.c_str());
#endif
}
void App::AllowNTLMCredentialsForAllDomains(bool should_allow) {
auto browser_context = static_cast<AtomBrowserContext*>(
AtomBrowserMainParts::Get()->browser_context());
@ -360,6 +349,8 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
base::Bind(&Browser::AddRecentDocument, browser))
.SetMethod("clearRecentDocuments",
base::Bind(&Browser::ClearRecentDocuments, browser))
.SetMethod("setAppUserModelId",
base::Bind(&Browser::SetAppUserModelID, browser))
#if defined(OS_WIN)
.SetMethod("setUserTasks",
base::Bind(&Browser::SetUserTasks, browser))
@ -367,7 +358,6 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
.SetMethod("setPath", &App::SetPath)
.SetMethod("getPath", &App::GetPath)
.SetMethod("setDesktopName", &App::SetDesktopName)
.SetMethod("setAppUserModelId", &App::SetAppUserModelId)
.SetMethod("allowNTLMCredentialsForAllDomains",
&App::AllowNTLMCredentialsForAllDomains)
.SetMethod("getLocale", &App::GetLocale)

Просмотреть файл

@ -67,7 +67,6 @@ class App : public mate::EventEmitter,
const base::FilePath& path);
void SetDesktopName(const std::string& desktop_name);
void SetAppUserModelId(const std::string& app_id);
void AllowNTLMCredentialsForAllDomains(bool should_allow);
bool MakeSingleInstance(
const ProcessSingleton::NotificationCallback& callback);

Просмотреть файл

@ -66,6 +66,9 @@ class Browser : public WindowListObserver {
// Clear the recent documents list.
void ClearRecentDocuments();
// Set the application user model ID.
void SetAppUserModelID(const base::string16& name);
#if defined(OS_MACOSX)
// Bounce the dock icon.
enum BounceType {
@ -100,9 +103,6 @@ class Browser : public WindowListObserver {
// Add a custom task to jump list.
void SetUserTasks(const std::vector<UserTask>& tasks);
// 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.

Просмотреть файл

@ -31,6 +31,9 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
void Browser::ClearRecentDocuments() {
}
void Browser::SetAppUserModelID(const base::string16& name) {
}
std::string Browser::GetExecutableFileVersion() const {
return brightray::GetApplicationVersion();
}

Просмотреть файл

@ -26,6 +26,9 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
void Browser::ClearRecentDocuments() {
}
void Browser::SetAppUserModelID(const base::string16& name) {
}
std::string Browser::GetExecutableFileVersion() const {
return brightray::GetApplicationVersion();
}

Просмотреть файл

@ -71,6 +71,11 @@ void Browser::ClearRecentDocuments() {
destinations->RemoveAllDestinations();
}
void Browser::SetAppUserModelID(const base::string16& name) {
app_user_model_id_ = name;
SetCurrentProcessExplicitAppUserModelID(app_user_model_id_.c_str());
}
void Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
CComPtr<ICustomDestinationList> destinations;
if (FAILED(destinations.CoCreateInstance(CLSID_DestinationList)))
@ -117,11 +122,6 @@ void Browser::SetUserTasks(const std::vector<UserTask>& tasks) {
destinations->CommitList();
}
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()));