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

Commit

Permalink
Merge pull request #3206 from bsclifton/back-forward-nav-enhancements
Browse files Browse the repository at this point in the history
Adds about:history, sets back/forward nav limit, more efficient dynamic menus
  • Loading branch information
bbondy authored Aug 17, 2016
2 parents 9772ea2 + 8a044fc commit 9117d47
Show file tree
Hide file tree
Showing 24 changed files with 851 additions and 169 deletions.
20 changes: 20 additions & 0 deletions app/extensions/brave/about-history.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html>
<head>
<meta charset="utf-8">
<meta name="availableLanguages" content="">
<meta name="defaultLanguage" content="en-US">
<meta name='theme-color' content='#035500'>
<link rel="shortcut icon"type="image/x-icon" href="data:image/x-icon;,">
<title data-l10n-id="historyTitle"></title>
<script src='js/about.js'></script>
<script src="ext/l20n.min.js" async></script>
<link rel="localization" href="locales/{locale}/history.properties">
</head>
<body>
<div id="appContainer"/>
</body>
</html>
2 changes: 2 additions & 0 deletions app/extensions/brave/locales/en-US/history.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
historyTitle=History
history=History
4 changes: 3 additions & 1 deletion app/extensions/brave/locales/en-US/menu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ home=Home
back=Back
forward=Forward
reopenLastClosedWindow=Reopen Last Closed Window
showAllHistory=Show All History
showAllHistory=Show History
clearHistory=Clear History...
clearCache=Clear Cache...
clearSiteData=Clear All Cookies and Site Data...
recentlyClosed=Recently Closed
recentlyVisited=Recently Visited
bookmarks=Bookmarks
addToFavoritesBar=Add to Favorites Bar
window=Window
Expand Down
30 changes: 24 additions & 6 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const siteSettings = require('../js/state/siteSettings')
const spellCheck = require('./spellCheck')
const flash = require('../js/flash')
const contentSettings = require('../js/state/contentSettings')
const FrameStateUtil = require('../js/state/frameStateUtil')

// Used to collect the per window state when shutting down the application
let perWindowState = []
Expand Down Expand Up @@ -294,6 +295,19 @@ app.on('ready', () => {
saveIfAllCollected()
})

// Window state must be fetched from main process; this is fired once it's retrieved
ipcMain.on(messages.RESPONSE_MENU_DATA_FOR_WINDOW, (wnd, windowState) => {
if (windowState) {
const activeFrame = FrameStateUtil.getActiveFrame(Immutable.fromJS(windowState))
const windowData = Immutable.fromJS({
location: activeFrame.get('location'),
closedFrames: windowState.closedFrames
})

Menu.init(AppStore.getState(), windowData)
}
})

ipcMain.on(messages.LAST_WINDOW_STATE, (wnd, data) => {
if (data) {
lastWindowState = data
Expand Down Expand Up @@ -367,8 +381,7 @@ app.on('ready', () => {
// reset the browser window. This will default to en-US if
// not yet configured.
locale.init(initialState.settings[settings.LANGUAGE], (strings) => {
// Initialize after localization strings async loaded
Menu.init(AppStore.getState().get('settings'), AppStore.getState().get('sites'))
Menu.init(AppStore.getState(), null)
})

// Do this after loading the state
Expand Down Expand Up @@ -439,9 +452,9 @@ app.on('ready', () => {
}
})

ipcMain.on(messages.UPDATE_APP_MENU, (e, args) => {
if (args && typeof args.bookmarked === 'boolean') {
Menu.updateBookmarkedStatus(args.bookmarked)
ipcMain.on(messages.UPDATE_MENU_BOOKMARKED_STATUS, (e, isBookmarked) => {
if (typeof isBookmarked === 'boolean') {
Menu.updateBookmarkedStatus(isBookmarked)
}
})

Expand Down Expand Up @@ -522,8 +535,13 @@ app.on('ready', () => {

// save app state every 5 minutes regardless of update frequency
setInterval(initiateSessionStateSave, 1000 * 60 * 5)

AppStore.addChangeListener(() => {
Menu.init(AppStore.getState().get('settings'), AppStore.getState().get('sites'))
if (BrowserWindow.getFocusedWindow()) {
BrowserWindow.getFocusedWindow().webContents.send(messages.REQUEST_MENU_DATA_FOR_WINDOW)
} else {
Menu.init(AppStore.getState(), null)
}
})

let masterKey
Expand Down
2 changes: 2 additions & 0 deletions app/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ var rendererIdentifiers = function () {
'clearCache',
'clearHistory',
'clearSiteData',
'recentlyClosed',
'recentlyVisited',
'bookmarks',
'addToFavoritesBar',
'window',
Expand Down
Loading

0 comments on commit 9117d47

Please sign in to comment.