Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Adds support for Honey, and resolves a couple bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansampson committed May 1, 2017
1 parent 2dce3c5 commit efb0eb2
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/common/state/extensionState.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const extensionState = {

browserActionBackgroundImage: (browserAction, tabId) => {
tabId = tabId ? tabId.toString() : '-1'
let path = browserAction.get('path')
let path = browserAction.getIn(['tabs', tabId, 'path']) || browserAction.get('path')
let basePath = browserAction.get('base_path')
if (path && basePath) {
// Older extensions may provide a string path
Expand Down
6 changes: 6 additions & 0 deletions app/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,12 @@ module.exports.init = () => {
disableExtension(config.vimiumExtensionId)
}

if (getSetting(settings.HONEY_ENABLED)) {
registerComponent(config.honeyExtensionId)
} else {
disableExtension(config.honeyExtensionId)
}

if (appStore.getState().getIn(['widevine', 'enabled'])) {
registerComponent(config.widevineComponentId)
}
Expand Down
Binary file added app/extensions/brave/img/extensions/honey-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/en-US/extensions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ torrent= Torrent Viewer
torrentDesc=Uses WebTorrent to display torrents directly in the browser. Supports torrent files and magnet links.
vimium= Vimium
vimiumDesc=
honey=Honey
honeyDesc=Automatically find and apply coupon codes when you shop online!
13 changes: 9 additions & 4 deletions app/renderer/components/navigation/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,18 @@ class Navigator extends ImmutableComponent {
.map((extension) => extensionState.getBrowserActionByTabId(this.props.appState, extension.get('id'), activeTabId))
.filter((browserAction) => browserAction)

let buttons = extensionBrowserActions.map((browserAction, id) =>
<BrowserAction
browserAction={browserAction}
let buttons = extensionBrowserActions.map((browserAction, id) => {
let tabAction = browserAction.getIn(['tabs', activeTabId.toString()])
if (tabAction) {
tabAction = tabAction.set('title', browserAction.get('title'))
tabAction = tabAction.set('base_path', browserAction.get('base_path'))
}
return <BrowserAction
browserAction={tabAction || browserAction}
extensionId={id}
tabId={activeTabId}
popupWindowSrc={this.props.windowState.getIn(['popupWindowDetail', 'src'])} />
).values()
}).values()
buttons = Array.from(buttons)
if (buttons.length > 0) {
buttons.push(<span className='buttonSeparator' />)
Expand Down
10 changes: 10 additions & 0 deletions app/renderer/lib/extensionsUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const pocket = config.PocketExtensionId
const sync = config.syncExtensionId
const webtorrent = config.torrentExtensionId
const vimium = config.vimiumExtensionId
const honey = config.honeyExtensionId

/**
* Stores dummy data for all known extensions based on vault-updater extension manifest.
Expand Down Expand Up @@ -49,6 +50,12 @@ const dummyData = [
name: 'saveToPocket',
description: 'saveToPocketDesc',
icon: 'img/extensions/pocket-128.png'
},
{
id: honey,
name: 'honey',
description: 'honeyDesc',
icon: 'img/extensions/honey-128.png'
}
// { id: 'vimium' // TBD }
]
Expand Down Expand Up @@ -129,6 +136,9 @@ module.exports.getExtensionKey = (extensionId) => {
case vimium:
extensionSetting = settings.VIMIUM_ENABLED
break
case honey:
extensionSetting = settings.HONEY_ENABLED
break
default:
break
}
Expand Down
1 change: 1 addition & 0 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ AppStore
'bookmarks.toolbar.showOnlyFavicon': boolean, // true if only favicons should be shown on the bookmarks toolbar
'extensions.pocket.enabled': boolean, // true if pocket is enabled
'extensions.vimium.enabled': boolean, // true if vimium is enabled
'extensions.honey.enabled': boolean, // true if Honey is enabled
'general.autohide-menu': boolean, // true if the Windows menu should be autohidden
'general.bookmarks-toolbar-mode': boolean, // true to show bookmakrs toolbar
'general.check-default-on-startup': boolean, // true to check whether brave is default browser on startup
Expand Down
1 change: 1 addition & 0 deletions js/constants/appConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ module.exports = {
'shutdown.clear-site-settings': false,
'extensions.pocket.enabled': false,
'extensions.vimium.enabled': false,
'extensions.honey.enabled': false,
'general.bookmarks-toolbar-mode': null,
'general.is-default-browser': null,
'notification-add-funds-timestamp': null,
Expand Down
1 change: 1 addition & 0 deletions js/constants/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = {
PDFJSExtensionId: 'jdbefljfgobbmcidnmpjamcbhnbphjnb',
PocketExtensionId: 'niloccemoadcdkdjlinkgdfekeahmflj',
vimiumExtensionId: 'dbepggeogbaibhgnhhndojpepiihcmeb',
honeyExtensionId: 'bmnlcjabgnpnenekpadlanbbkooimhnj',
widevineComponentId: 'oimompecagnajdejgnnjijobebaeigek',
coinbaseOrigin: 'https://buy.coinbase.com',
newtab: {
Expand Down
3 changes: 2 additions & 1 deletion js/constants/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ const settings = {
SHOW_BOOKMARKS_TOOLBAR_FAVICON: 'bookmarks.toolbar.showFavicon',
SHOW_BOOKMARKS_TOOLBAR_ONLY_FAVICON: 'bookmarks.toolbar.showOnlyFavicon',
POCKET_ENABLED: 'extensions.pocket.enabled',
VIMIUM_ENABLED: 'extensions.vimium.enabled'
VIMIUM_ENABLED: 'extensions.vimium.enabled',
HONEY_ENABLED: 'extensions.honey.enabled'
}

module.exports = settings
13 changes: 13 additions & 0 deletions test/about/extensionsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ describe('about:extensions', function () {
.url(pocketURL)
})
})
describe('Honey', function () {
Brave.beforeAll(this)
before(function * () {
yield setup(this.app.client)
})
it('installs when preference is enabled', function * () {
yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.changeSetting(settingsConst.HONEY_ENABLED, true)
.tabByIndex(0)
.waitForVisible('[data-extension-id="bmnlcjabgnpnenekpadlanbbkooimhnj"]', extensionDownloadWaitTime)
})
})
describe('Vimium', function () {
Brave.beforeAll(this)
before(function * () {
Expand Down

0 comments on commit efb0eb2

Please sign in to comment.