Skip to content

Commit

Permalink
Set extension icon in context menu
Browse files Browse the repository at this point in the history
requires brave/muon#86
fix brave#5292

Auditors: @bridiver, @bbondy

Test Plan:
1. Enable pocket
2. right click to popup context menu
3. Save to pocket should have icon
  • Loading branch information
darkdh committed Nov 2, 2016
1 parent 5de9547 commit 661f0f4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/browser/extensions/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const contextMenus = {
extensionActions.contextMenuAllRemoved(extensionId)
})
})
process.on('chrome-context-menus-create', (extensionId, menuItemId, properties) => {
process.on('chrome-context-menus-create', (extensionId, menuItemId, properties, icon) => {
setImmediate(() => {
extensionActions.contextMenuCreated(extensionId, menuItemId, properties)
extensionActions.contextMenuCreated(extensionId, menuItemId, properties, icon)
})
})
}
Expand Down
6 changes: 4 additions & 2 deletions app/common/actions/extensionActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ const extensionActions = {
* @param {string} extensionId - the extension id
* @param {string} menuItemId - the id of the menu item that was clicked
* @param {object} properties - createProperties of chrome.contextMenus.create
* @param {string} icon - 16x16 extension icon
*/
contextMenuCreated: function (extensionId, menuItemId, properties) {
contextMenuCreated: function (extensionId, menuItemId, properties, icon) {
AppDispatcher.dispatch({
actionType: ExtensionConstants.CONTEXT_MENU_CREATED,
extensionId,
menuItemId,
properties
properties,
icon
})
},

Expand Down
6 changes: 5 additions & 1 deletion app/common/state/extensionState.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ const extensionState = {
state = state.setIn(['extensions', action.get('extensionId'), 'contextMenus'], new Immutable.List())
}
let contextMenus = state.getIn(['extensions', action.get('extensionId'), 'contextMenus'])
let basePath = state.getIn(['extensions', action.get('extensionId'), 'base_path'])
basePath = decodeURI(basePath)
basePath = basePath.replace('file://', '')
return state.setIn(['extensions', action.get('extensionId'), 'contextMenus'],
contextMenus.push({
extensionId: action.get('extensionId'),
menuItemId: action.get('menuItemId'),
properties: action.get('properties').toJS()
properties: action.get('properties').toJS(),
icon: basePath + '/' + action.get('icon')
}))
} else {
return state
Expand Down
3 changes: 2 additions & 1 deletion js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,8 @@ function mainTemplateInit (nodeProps, frame) {
extensionActions.contextMenuClicked(
extensionContextMenu.extensionId, frame.get('tabId'), info)
}
}
},
icon: extensionContextMenu.icon
})
templateMap[extensionContextMenu.menuItemId] = template[template.length - 1]
}
Expand Down

0 comments on commit 661f0f4

Please sign in to comment.