Skip to content

Commit

Permalink
UrlBarIcon uses now only primitives
Browse files Browse the repository at this point in the history
Resolves brave#9753

Auditors: @bsclifton @bridiver

Test Plan:
  • Loading branch information
NejcZdovc committed Jun 28, 2017
1 parent 22c07e6 commit 5bccd02
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
6 changes: 4 additions & 2 deletions app/renderer/components/navigation/urlBarIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ class UrlBarIcon extends React.Component {

onDragStart (e) {
dndData.setupDataTransferURL(e.dataTransfer, this.props.location, this.props.title)
dndData.setupDataTransferBraveData(e.dataTransfer, dragTypes.TAB, this.props.activeFrame)
dndData.setupDataTransferBraveData(e.dataTransfer, dragTypes.TAB, Immutable.fromJS({
activeFrameKey: this.props.activeFrameKey
}))
}

mergeProps (state, ownProps) {
Expand All @@ -138,7 +140,7 @@ class UrlBarIcon extends React.Component {

// used in other functions
props.title = activeFrame.get('title', '')
props.activeFrame = activeFrame // TODO (nejc) only primitives
props.activeFrameKey = activeFrame.get('key')

return props
}
Expand Down
12 changes: 12 additions & 0 deletions app/renderer/reducers/frameReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const Immutable = require('immutable')
const appConstants = require('../../../js/constants/appConstants')
const windowConstants = require('../../../js/constants/windowConstants')
const config = require('../../../js/constants/config')
const siteTags = require('../../../js/constants/siteTags')

// Actions
const appActions = require('../../../js/actions/appActions')
Expand All @@ -21,6 +22,7 @@ const {getCurrentWindowId} = require('../currentWindow')
const {getSourceAboutUrl, getSourceMagnetUrl} = require('../../../js/lib/appUrlUtil')
const {isURL, isPotentialPhishingUrl, getUrlFromInput} = require('../../../js/lib/urlutil')
const settings = require('../../../js/constants/settings')
const siteUtil = require('../../../js/state/siteUtil')
const {getSetting} = require('../../../js/settings')

const setFullScreen = (state, action) => {
Expand Down Expand Up @@ -191,6 +193,16 @@ const frameReducer = (state, action, immutableAction) => {
case windowConstants.WINDOW_SET_FULL_SCREEN:
state = setFullScreen(state, action)
break

case windowConstants.WINDOW_ON_FRAME_BOOKMARK:
{
const frameProps = frameStateUtil.getFrameByKey(state, action.frameKey)
if (frameProps) {
const bookmark = siteUtil.getDetailFromFrame(frameProps, siteTags.BOOKMARK)
appActions.addSite(bookmark, siteTags.BOOKMARK)
}
break
}
}

return state
Expand Down
7 changes: 7 additions & 0 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,13 @@ const windowActions = {
partition,
tabId
})
},

onFrameBookmark: function (frameKey) {
dispatch({
actionType: windowConstants.WINDOW_ON_FRAME_BOOKMARK,
frameKey
})
}
}

Expand Down
3 changes: 2 additions & 1 deletion js/constants/windowConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ const windowConstants = {
WINDOW_SHOULD_OPEN_DEV_TOOLS: _,
WINDOW_SET_ALL_AUDIO_MUTED: _,
WINDOW_ON_GO_BACK_LONG: _,
WINDOW_ON_GO_FORWARD_LONG: _
WINDOW_ON_GO_FORWARD_LONG: _,
WINDOW_ON_FRAME_BOOKMARK: _
}

module.exports = mapValuesByKeys(windowConstants)
9 changes: 2 additions & 7 deletions js/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const appActions = require('./actions/appActions')
const ReactDOM = require('react-dom')
const dndData = require('./dndData')
const dragTypes = require('./constants/dragTypes')
const siteTags = require('./constants/siteTags')
const siteUtil = require('./state/siteUtil')
const appStoreRenderer = require('./stores/appStoreRenderer')
const {getCurrentWindowId} = require('../app/renderer/currentWindow')
const {ESC} = require('../app/common/constants/keyCodes.js')
Expand Down Expand Up @@ -137,11 +135,8 @@ module.exports.isMiddle = (domNode, clientX) => {
module.exports.prepareBookmarkDataFromCompatible = (dataTransfer) => {
let bookmark = dndData.getDragData(dataTransfer, dragTypes.BOOKMARK)
if (!bookmark) {
const frameProps = dndData.getDragData(dataTransfer, dragTypes.TAB)
if (frameProps) {
bookmark = siteUtil.getDetailFromFrame(frameProps, siteTags.BOOKMARK)
appActions.addSite(bookmark, siteTags.BOOKMARK)
}
const frame = dndData.getDragData(dataTransfer, dragTypes.TAB)
windowActions.onFrameBookmark(frame.get('activeFrameKey'))
}
return bookmark
}

0 comments on commit 5bccd02

Please sign in to comment.