Windows/Mac native context menus via Chrome Packaged Apps

376 views
Skip to first unread message

hlandao

unread,
Aug 29, 2013, 8:38:25 AM8/29/13
to chromi...@chromium.org
Hello,

Is there a way to add an item to the native context menus of windows/mac with Chrome Packaged App ?




Thanks,
Hadar.

Joe Marini

unread,
Aug 29, 2013, 12:17:04 PM8/29/13
to hlandao, Chromium Apps
I'm not sure what you mean by the "native" context menus. Does the http://developer.chrome.com/apps/contextMenus.html API do what you want?



--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-app...@chromium.org.
To post to this group, send email to chromi...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.



--
Joe Marini
Developer Advocate / Chrome

James Mortensen

unread,
Sep 1, 2013, 12:13:00 AM9/1/13
to chromi...@chromium.org
Joe, this is awesome! Nice work Chromium team.  


hlandao - Here's a few examples:

    /*
     * Adds a right click menu to the app with a setting to toggle auto-answer on and off.
     *
     */ 
    chrome.contextMenus.create(
    {
    "type":"checkbox",
    "title":"Enable Auto Answer",
    "contexts":["all"],
    "id":"auto-answer"
    }
    );

The above right click menu item will have a checkbox when on and no check when off. It appears wherever you right click thanks to "all", but you can target different scenarios, like only having the item show when right clicking a video, or the launcher, for instance.



    /*
     * Adds in the right click menu for Advanced and the Advanced Configuration and Debug Menu
     *
     */
    chrome.contextMenus.create(
    {
    "type":"normal",
    "title":"Advanced",
    "contexts":["all"],
    "id":"advanced"
    }
    );

    chrome.contextMenus.create(
    {
    "type":"normal",
    "title":"Configuration",
    "contexts":["all"],
    "id":"configuration",
            "parentId":"advanced"
    }
    );

    chrome.contextMenus.create(
    {
    "type":"normal",
    "title":"Debug",
    "contexts":["all"],
    "id":"debug",
            "parentId":"advanced"
    }
    );
    

The above 3 code blocks add in an Advanced menu item that expands into a submenu. The parentId links items inside the submenu to the parent item.


And of course there's the behavior. In Apps, the only way to bind click events is with this handler.  I'm actually going to use switch on the info.menuItemId instead, so I don't have to nest if's and can make it more readable, but this will get you started.

    chrome.contextMenus.onClicked.addListener(function(info, tab) { 
   console.info("info = " + info);iii= info;
   console.info("tab = " + tab); 
   if(info.menuItemId == "auto-answer" && info.checked == false) {
       console.info("turn off auto answer");
       chrome.contextMenus.update("auto-answer",
    {
    "type":"checkbox",
    "title":"Enable Auto Answer",
    "contexts":["all"],
    }
   );

   } else if(info.menuItemId == "auto-answer" && info.checked == true) {
       console.info("turn on auto-answer");
       chrome.contextMenus.update("auto-answer",
    {
    "type":"checkbox",
    "title":"Disable Auto Answer",
    "contexts":["all"],
    }
   );
   }
});


Good luck!

James

hlandao

unread,
Sep 1, 2013, 9:16:40 AM9/1/13
to chromi...@chromium.org, hlandao
Hi

I actually referred to the native windows-explorer / osX-finder context menus.

Thanks.

James Mortensen

unread,
Sep 1, 2013, 1:20:21 PM9/1/13
to chromi...@chromium.org, hlandao
Canary does have launcher icons, if that's what you mean. 

That leads me to this: The common theme I'm seeing here is that you're not doing a good job of explaining yourself. Do you mind using more detail than just one sentence, so we don't keep wasting time giving you stuff that isn't what you're looking for?

For instance, perhaps you could describe a use case from start to finish, so we can more easily picture what you're trying to achieve.

Hope this helps!
James

Victor Khimenko

unread,
Sep 1, 2013, 1:48:42 PM9/1/13
to James Mortensen, Chromium Apps, hlandao
On Sun, Sep 1, 2013 at 9:20 PM, James Mortensen <james.m...@a-cti.com> wrote:
Canary does have launcher icons, if that's what you mean. 

I doubt he meant launcher icons. He clearly talks about Windows Explorer context menu:
 
That leads me to this: The common theme I'm seeing here is that you're not doing a good job of explaining yourself. Do you mind using more detail than just one sentence, so we don't keep wasting time giving you stuff that isn't what you're looking for?

First time he indeed was unclear, but second request is quite clear: "Windows Explorer context menu" is very well-known object and it makes perfect sense for the application to be there if it's designed to process files of certain structure (or even all files for certain applications). You can obviously add even Chrome application there by changing registry, but I'm not sure if Chrome can do that automatically for you.
 
For instance, perhaps you could describe a use case from start to finish, so we can more easily picture what you're trying to achieve.
 
Example use-case: right-click on any file in Windows Explorer, see "Share with my friend in Google+" menu item; said menu contains list of few your best friend and when you click on it file is opened in selected webapp and shared with chosen friend.

James Mortensen

unread,
Sep 1, 2013, 2:06:11 PM9/1/13
to Victor Khimenko, Chromium Apps, hlandao
What's clear to one person may not be clear to another. So, glad you were able to clarify, Victor. Just hope you're right. Thanks!

If that's the case, then it looks like the answer is no, it's not possible.  Here's a list of the different contexts for where context menus can be added:

contexts optional array of enum of "all""page""frame""selection""link""editable""image""video","audio", or "launcher" )

From implementing context menus in my own app, I've discovered that "all" puts the context menu option everywhere in the app, although surprisingly it doesn't put it on the launcher. Even with the launcher context it doesn't place it on the launcher.  Seems that's broken/not implemented yet.

Of course, it doesn't place it in the finder context menu either. I'm on a Mac though.  I'm not testing in Windows, but if it's implemented the same there then there's likely no way to add it there either.

What's missing is an "explorer" context or a "file" context, so that the option could be configured to show whenever users right click on a file or within the Finder/Windows Explorer windows.  I agree that would be useful to have for apps that work with files.

Hope this helps!
James

James Mortensen
Project Manager, AnswerConnect, Inc.
866-707-4590
james.m...@a-cti.com

Joe Marini

unread,
Sep 3, 2013, 2:45:33 PM9/3/13
to James Mortensen, Victor Khimenko, Chromium Apps, hlandao
Right, there's currently not a way to do that.

Stefan Roesch

unread,
Apr 18, 2014, 2:14:55 PM4/18/14
to chromi...@chromium.org, James Mortensen, Victor Khimenko, hlandao

On OSX this doesn't seem to show anything when I right-click my launcher item...


      chrome.contextMenus.create({

        "id": "my id",

        "title": "my title",

        "contexts": ["launcher"]

      }, function(e) {

        console.log('launcher menu');

      });

Ben Wells

unread,
Apr 21, 2014, 8:51:11 PM4/21/14
to Stefan Roesch, Chromium Apps, James Mortensen, Victor Khimenko, hlandao
AFAIK this only got implemented in ChromeOS. It really should be added everywhere. I logged 365525 to fix this.


Stefan Roesch

unread,
Apr 29, 2014, 5:38:52 PM4/29/14
to chromi...@chromium.org, Stefan Roesch, James Mortensen, Victor Khimenko, hlandao
awesome.  as this partially would solve a separate issue:


since it's possible to hide all windows and then you can never get focus of the app again in OSX

Stefan Roesch

unread,
Jun 4, 2014, 4:06:30 PM6/4/14
to chromi...@chromium.org, rab...@firespotter.com, james.m...@a-cti.com, kh...@google.com, hla...@gmail.com
any updates here?  getting close to shipping and usability on OSX is still sub-par

Morgan Yarbrough

unread,
Jul 12, 2014, 7:40:47 AM7/12/14
to chromi...@chromium.org, rab...@firespotter.com, james.m...@a-cti.com, kh...@google.com, hla...@gmail.com
Any updates? The lack of a context menu in Windows Explorer to open files makes Chrome Apps seem like a poor options for any app that is used to work on local files... 

Ben Wells

unread,
Jul 16, 2014, 2:24:45 AM7/16/14
to Morgan Yarbrough, Matt Giuca, Jack Hou, Chromium Apps, Stefan Roesch, James Mortensen, Victor Khimenko, Hadar Landao
+jackhou and mgiuca who are the engineers working on this.

Matt Giuca

unread,
Jul 16, 2014, 2:30:22 AM7/16/14
to Ben Wells, Morgan Yarbrough, Jack Hou, Chromium Apps, Stefan Roesch, James Mortensen, Victor Khimenko, Hadar Landao
Note: Jack and I are not (to my knowledge) working on Windows or Mac context menu integration. We're working on file associations (the file_handlers attribute in the manifest will automatically associate file types in Windows/Mac with the Chrome app). I don't know of any current effort to make contexts work with Windows Explorer.

(I think the correct behaviour here is to add items to the right-click menu for an active app in the Windows taskbar, but I'm not very familiar with this API.)

Stefan Roesch

unread,
Jul 16, 2014, 4:19:23 AM7/16/14
to Matt Giuca, Ben Wells, Morgan Yarbrough, Jack Hou, Chromium Apps, James Mortensen, Victor Khimenko, Hadar Landao
bummer...

adding badges and right-click menus to the osx dock icons or the application top-bar menu would be super helpful.
Reply all
Reply to author
Forward
0 new messages