From 0b1b0940d23c174b5437d5cceb42ca1e62d6e2fe Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 17 Nov 2014 17:35:51 +0800 Subject: [PATCH] Enable setting icon for addUserTasks --- atom/browser/api/atom_api_app.cc | 5 +++++ atom/browser/browser.h | 2 ++ atom/browser/browser_win.cc | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index ce56c0da30c1..d6f807246158 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -35,6 +35,7 @@ using atom::Browser; namespace mate { +#if defined(OS_WIN) template<> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Handle val, @@ -45,11 +46,15 @@ struct Converter { if (!dict.Get("program", &(out->program)) || !dict.Get("title", &(out->title))) return false; + if (dict.Get("iconPath", &(out->icon_path)) && + !dict.Get("iconIndex", &(out->icon_index))) + return false; dict.Get("arguments", &(out->arguments)); dict.Get("description", &(out->description)); return true; } }; +#endif } // namespace mate diff --git a/atom/browser/browser.h b/atom/browser/browser.h index 69f61da84f2c..a22680acdc90 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -91,6 +91,8 @@ class Browser : public WindowListObserver { base::string16 arguments; base::string16 title; base::string16 description; + base::FilePath icon_path; + int icon_index; }; // Add a custom task to jump list. diff --git a/atom/browser/browser_win.cc b/atom/browser/browser_win.cc index 9e4db535b232..c8620f26578f 100644 --- a/atom/browser/browser_win.cc +++ b/atom/browser/browser_win.cc @@ -96,6 +96,11 @@ void Browser::AddUserTasks(const std::vector& tasks) { FAILED(link->SetDescription(task.description.c_str()))) return; + if (!task.icon_path.empty() && + FAILED(link->SetIconLocation(task.icon_path.value().c_str(), + task.icon_index))) + return; + CComQIPtr property_store = link; if (!base::win::SetStringValueForPropertyStore(property_store, PKEY_Title, task.title.c_str()))