From c356301aeff81537221bf84c17b5774647cf613a Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Wed, 20 Jul 2016 15:57:35 +0800 Subject: [PATCH 1/2] search image on context menu fix #2606 --- .../brave/locales/en-US/menu.properties | 1 + app/locale.js | 1 + js/contextMenus.js | 17 +++++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/extensions/brave/locales/en-US/menu.properties b/app/extensions/brave/locales/en-US/menu.properties index 3dadea44de2..dfd7efd32a6 100644 --- a/app/extensions/brave/locales/en-US/menu.properties +++ b/app/extensions/brave/locales/en-US/menu.properties @@ -109,6 +109,7 @@ saveImage=Save Image... openImageInNewTab=Open Image in New Tab copyImageAddress=Copy Image Address copyImage=Copy Image +searchImage=Search Image viewPageSource=View Page Source addToReadingList=Add to reading list about=About diff --git a/app/locale.js b/app/locale.js index 2217b7a6d3d..0bf074f15b0 100644 --- a/app/locale.js +++ b/app/locale.js @@ -28,6 +28,7 @@ var rendererIdentifiers = function () { 'openImageInNewTab', 'saveImage', 'copyImage', + 'searchImage', 'copyLinkAddress', 'copyEmailAddress', 'saveLinkAs', diff --git a/js/contextMenus.js b/js/contextMenus.js index a89c96f759b..db32c7f868d 100644 --- a/js/contextMenus.js +++ b/js/contextMenus.js @@ -765,9 +765,22 @@ function mainTemplateInit (nodeProps, frame) { } } }, - copyAddressMenuItem('copyImageAddress', nodeProps.srcURL), - CommonMenu.separatorMenuItem + copyAddressMenuItem('copyImageAddress', nodeProps.srcURL) ) + if (nodeProps.srcURL && urlParse(nodeProps.srcURL).protocol !== 'data:') { + template.push( + { + label: locale.translation('searchImage'), + click: (item) => { + let searchUrl = windowStore.getState().getIn(['searchDetail', 'searchURL']) + .replace('{searchTerms}', encodeURIComponent(nodeProps.srcURL)) + .replace('?q', 'byimage?image_url') + windowActions.newFrame({ location: searchUrl }, true) + } + } + ) + } + template.push(CommonMenu.separatorMenuItem) } if (isInputField) { From efa122935b96520114a745d58aa928db485e7d8f Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Wed, 20 Jul 2016 22:52:07 +0800 Subject: [PATCH 2/2] search image support only by google for now --- js/contextMenus.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/contextMenus.js b/js/contextMenus.js index db32c7f868d..eb3d4068be1 100644 --- a/js/contextMenus.js +++ b/js/contextMenus.js @@ -767,7 +767,8 @@ function mainTemplateInit (nodeProps, frame) { }, copyAddressMenuItem('copyImageAddress', nodeProps.srcURL) ) - if (nodeProps.srcURL && urlParse(nodeProps.srcURL).protocol !== 'data:') { + if (getSetting(settings.DEFAULT_SEARCH_ENGINE) === 'content/search/google.xml' && + nodeProps.srcURL && urlParse(nodeProps.srcURL).protocol !== 'data:') { template.push( { label: locale.translation('searchImage'),