]> khamidou — GitHub mirrors - electron.git/commitdiff
Enable setting icon for addUserTasks
authorCheng Zhao <zcbenz@gmail.com>
Mon, 17 Nov 2014 09:35:51 +0000 (17:35 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 17 Nov 2014 09:35:51 +0000 (17:35 +0800)
atom/browser/api/atom_api_app.cc
atom/browser/browser.h
atom/browser/browser_win.cc

index ce56c0da30c1d381ffc5004aac1d4652f516b20d..d6f8072461585c3215c827d82ccc8f5d3579d7da 100644 (file)
@@ -35,6 +35,7 @@ using atom::Browser;
 
 namespace mate {
 
+#if defined(OS_WIN)
 template<>
 struct Converter<Browser::UserTask> {
   static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
@@ -45,11 +46,15 @@ struct Converter<Browser::UserTask> {
     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
 
index 69f61da84f2c5b5e9baf12b53742666ad80de922..a22680acdc9056f37cd52ac05bc44551d2e73d4c 100644 (file)
@@ -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.
index 9e4db535b2322b17aba21ae85dec19dcf35075de..c8620f26578ffb098e5cf487fdfaf6c81ccd2f1e 100644 (file)
@@ -96,6 +96,11 @@ void Browser::AddUserTasks(const std::vector<UserTask>& 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<IPropertyStore> property_store = link;
     if (!base::win::SetStringValueForPropertyStore(property_store, PKEY_Title,
                                                    task.title.c_str()))