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 11, 2017
1 parent c708af7 commit 8085f63
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 3 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 @@ -519,6 +519,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!
9 changes: 8 additions & 1 deletion app/renderer/components/navigation/browserAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ class BrowserAction extends React.Component {
const currentWindow = state.get('currentWindow')
const activeFrame = frameStateUtil.getActiveFrame(currentWindow) || Immutable.Map()
const activeTabId = activeFrame.get('tabId') || tabState.TAB_ID_NONE
const browserActions = extensionState.getBrowserActionByTabId(state, ownProps.extensionId, activeTabId)
let browserActions = extensionState.getBrowserActionByTabId(state, ownProps.extensionId, activeTabId)
let tabAction = browserActions.getIn(['tabs', activeTabId.toString()])

if (tabAction) {
tabAction = tabAction.set('title', browserActions.get('title'))
tabAction = tabAction.set('base_path', browserActions.get('base_path'))
browserActions = tabAction
}

const props = {}
// used in renderer
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 @@ -132,6 +139,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 @@ -203,6 +203,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 @@ -96,7 +96,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 8085f63

Please sign in to comment.