From 0c8889220b623987e29419b6e0dff618f1cbf415 Mon Sep 17 00:00:00 2001 From: yan Date: Fri, 4 Dec 2015 17:41:01 -0800 Subject: [PATCH 1/5] Load about:blank instead of brave as default url --- js/constants/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/constants/config.js b/js/constants/config.js index 739da298e34..45ce1a13207 100644 --- a/js/constants/config.js +++ b/js/constants/config.js @@ -17,7 +17,7 @@ export default { height: 100 }, defaultLocale: 'en-US', - defaultUrl: 'http://www.brave.com', + defaultUrl: 'about:blank', urlBarSuggestions: { maxTopSites: 5, maxSearch: 3, From 32198f5c55c9a7fa5af02c4b60857dc5e807b9a1 Mon Sep 17 00:00:00 2001 From: yan Date: Fri, 4 Dec 2015 17:41:26 -0800 Subject: [PATCH 2/5] Update url bar during redirects and tab switches Update the URL bar at load start instead of load end since that is what most browsers do. --- js/components/frame.js | 10 +++++++--- js/components/urlBar.js | 7 +++++++ js/stores/appStore.js | 4 ---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/js/components/frame.js b/js/components/frame.js index 044819450fb..0632b65eb51 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -80,14 +80,18 @@ class Frame extends ImmutableComponent { this.webview.addEventListener('dom-ready', () => { console.log('dom is ready') }) - this.webview.addEventListener('did-get-redirect-request', (oldUrl, newUrl) => { - console.log('got redirect', newUrl) - AppActions.setNavBarInput(newUrl) + this.webview.addEventListener('did-get-redirect-request', (event) => { + // Update the url bar for top-level location changes + if (event.isMainFrame) { + console.log('got redirect', event.oldURL, event.newURL) + AppActions.setNavBarInput(event.newURL) + } }) this.webview.addEventListener('did-start-loading', () => { console.log('spinner start loading') AppActions.onWebviewLoadStart( this.props.frame) + AppActions.setNavBarInput(this.props.frame.get('location')) }) this.webview.addEventListener('did-stop-loading', () => { console.log('spinner stop loading') diff --git a/js/components/urlBar.js b/js/components/urlBar.js index 23567c3e38d..da570a17f3f 100644 --- a/js/components/urlBar.js +++ b/js/components/urlBar.js @@ -63,6 +63,13 @@ class UrlBar extends ImmutableComponent { AppActions.setNavBarFocused(true) } + componentWillReceiveProps (newProps) { + let location = newProps.activeFrameProps.get('location') // TODO: update this during redirects + if (location !== this.props.activeFrameProps.get('location')) { + AppActions.setNavBarInput(location) + } + } + render () { return
{ appStore.emitChange() break case AppConstants.APP_WEBVIEW_LOAD_END: - // Only update for the active frame. - if (action.frameProps === appState.getIn(['frames', FrameStateUtil.findIndexForFrameKey(appState.get('frames'), appState.get('activeFrameKey'))])) { - updateNavBarInput(action.location) - } appState = appState.mergeIn(['frames', FrameStateUtil.getFramePropsIndex(appState.get('frames'), action.frameProps)], { loading: false }) From a5d708db614684a2ace02c53f619bb9fbbe280a0 Mon Sep 17 00:00:00 2001 From: yan Date: Mon, 7 Dec 2015 15:08:12 -0800 Subject: [PATCH 3/5] s/setNavBarInput/setNavBarUserInput --- js/actions/appActions.js | 2 +- js/components/frame.js | 4 ++-- js/components/urlBar.js | 4 ++-- js/components/urlBarSuggestions.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/actions/appActions.js b/js/actions/appActions.js index de3ea394bb2..1545e4de8ee 100644 --- a/js/actions/appActions.js +++ b/js/actions/appActions.js @@ -18,7 +18,7 @@ const AppActions = { }) }, - setNavBarInput: function (location) { + setNavBarUserInput: function (location) { AppDispatcher.dispatch({ actionType: AppConstants.APP_SET_NAVBAR_INPUT, location diff --git a/js/components/frame.js b/js/components/frame.js index 0632b65eb51..d8d7e71eb04 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -84,14 +84,14 @@ class Frame extends ImmutableComponent { // Update the url bar for top-level location changes if (event.isMainFrame) { console.log('got redirect', event.oldURL, event.newURL) - AppActions.setNavBarInput(event.newURL) + AppActions.setNavBarUserInput(event.newURL) } }) this.webview.addEventListener('did-start-loading', () => { console.log('spinner start loading') AppActions.onWebviewLoadStart( this.props.frame) - AppActions.setNavBarInput(this.props.frame.get('location')) + AppActions.setNavBarUserInput(this.props.frame.get('location')) }) this.webview.addEventListener('did-stop-loading', () => { console.log('spinner stop loading') diff --git a/js/components/urlBar.js b/js/components/urlBar.js index da570a17f3f..3411a3b0fc0 100644 --- a/js/components/urlBar.js +++ b/js/components/urlBar.js @@ -55,7 +55,7 @@ class UrlBar extends ImmutableComponent { } onChange (e) { - AppActions.setNavBarInput(e.target.value) + AppActions.setNavBarUserInput(e.target.value) } onFocus (e) { @@ -66,7 +66,7 @@ class UrlBar extends ImmutableComponent { componentWillReceiveProps (newProps) { let location = newProps.activeFrameProps.get('location') // TODO: update this during redirects if (location !== this.props.activeFrameProps.get('location')) { - AppActions.setNavBarInput(location) + AppActions.setNavBarUserInput(location) } } diff --git a/js/components/urlBarSuggestions.js b/js/components/urlBarSuggestions.js index 73f127daaf7..44ef3189e88 100644 --- a/js/components/urlBarSuggestions.js +++ b/js/components/urlBarSuggestions.js @@ -92,7 +92,7 @@ class UrlBarSuggestions extends ImmutableComponent { let navigateClickHandler = formatUrl => site => { let location = formatUrl(site) - AppActions.setNavBarInput(location) + AppActions.setNavBarUserInput(location) AppActions.loadUrl(location) this.blur() } From 364500140b256d318427d16ec1f751c8cd59efa5 Mon Sep 17 00:00:00 2001 From: yan Date: Mon, 7 Dec 2015 17:56:51 -0800 Subject: [PATCH 4/5] Set the frame location attribute on redirects & load start --- js/actions/appActions.js | 11 +++++++++++ js/components/frame.js | 13 ++++++++----- js/components/urlBar.js | 7 ------- js/constants/appConstants.js | 3 ++- js/stores/appStore.js | 12 ++++++++++++ 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/js/actions/appActions.js b/js/actions/appActions.js index 1545e4de8ee..16a29dc743f 100644 --- a/js/actions/appActions.js +++ b/js/actions/appActions.js @@ -18,6 +18,17 @@ const AppActions = { }) }, + setLocation: function (loc, key) { + if (UrlUtil.isURL(loc)) { + loc = UrlUtil.getUrlFromInput(loc) + } + AppDispatcher.dispatch({ + actionType: AppConstants.APP_SET_LOCATION, + location: loc, + key: key + }) + }, + setNavBarUserInput: function (location) { AppDispatcher.dispatch({ actionType: AppConstants.APP_SET_NAVBAR_INPUT, diff --git a/js/components/frame.js b/js/components/frame.js index d8d7e71eb04..9a0dfccdcb7 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -83,15 +83,18 @@ class Frame extends ImmutableComponent { this.webview.addEventListener('did-get-redirect-request', (event) => { // Update the url bar for top-level location changes if (event.isMainFrame) { - console.log('got redirect', event.oldURL, event.newURL) - AppActions.setNavBarUserInput(event.newURL) + let key = this.props.frame.get('key') + console.log('got redirect', event.oldURL, event.newURL, key) + AppActions.setLocation(event.newURL, key) } }) this.webview.addEventListener('did-start-loading', () => { - console.log('spinner start loading') + let key = this.props.frame.get('key') + let location = this.props.frame.get('location') + console.log('spinner start loading', location, key) AppActions.onWebviewLoadStart( this.props.frame) - AppActions.setNavBarUserInput(this.props.frame.get('location')) + AppActions.setLocation(location, key) }) this.webview.addEventListener('did-stop-loading', () => { console.log('spinner stop loading') @@ -130,7 +133,7 @@ class Frame extends ImmutableComponent { })}> } diff --git a/js/components/urlBar.js b/js/components/urlBar.js index 3411a3b0fc0..91f6927ac4e 100644 --- a/js/components/urlBar.js +++ b/js/components/urlBar.js @@ -63,13 +63,6 @@ class UrlBar extends ImmutableComponent { AppActions.setNavBarFocused(true) } - componentWillReceiveProps (newProps) { - let location = newProps.activeFrameProps.get('location') // TODO: update this during redirects - if (location !== this.props.activeFrameProps.get('location')) { - AppActions.setNavBarUserInput(location) - } - } - render () { return title: '' }) +const setLocation = (loc, key) => { + console.log('updating location', loc, key) + key = key || appState.get('activeFrameKey') + appState = appState.mergeIn(['frames', FrameStateUtil.findIndexForFrameKey(appState.get('frames'), key)], { + location: loc + }) +} + const updateNavBarInput = (loc) => { appState = appState.setIn(['ui', 'navbar', 'urlbar', 'location'], loc) appState = appState.setIn(['ui', 'navbar', 'urlbar', 'urlPreview'], null) @@ -79,6 +87,10 @@ AppDispatcher.register((action) => { updateUrl(action.location) appStore.emitChange() break + case AppConstants.APP_SET_LOCATION: + setLocation(action.location, action.key) + appStore.emitChange() + break case AppConstants.APP_SET_NAVBAR_INPUT: updateNavBarInput(action.location) appStore.emitChange() From 223ef997fcff291a6d58b288e7979f8169ba6fde Mon Sep 17 00:00:00 2001 From: yan Date: Mon, 7 Dec 2015 18:20:45 -0800 Subject: [PATCH 5/5] Update urlbar UI when frame location changes --- js/components/urlBar.js | 7 +++++++ js/stores/appStore.js | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/js/components/urlBar.js b/js/components/urlBar.js index 91f6927ac4e..7d3e5b9524d 100644 --- a/js/components/urlBar.js +++ b/js/components/urlBar.js @@ -63,6 +63,13 @@ class UrlBar extends ImmutableComponent { AppActions.setNavBarFocused(true) } + componentWillReceiveProps (newProps) { + let location = newProps.activeFrameProps.get('location') + if (location !== this.props.activeFrameProps.get('location')) { + AppActions.setLocation(location) + } + } + render () { return }) const setLocation = (loc, key) => { - console.log('updating location', loc, key) key = key || appState.get('activeFrameKey') + console.log('updating location', loc, key) appState = appState.mergeIn(['frames', FrameStateUtil.findIndexForFrameKey(appState.get('frames'), key)], { location: loc }) + // Update the displayed location in the urlbar + if (key === appState.get('activeFrameKey')) { + updateNavBarInput(loc) + } } const updateNavBarInput = (loc) => {