const WindowManager = require('./WindowManager');
const windowManager = new WindowManager();
+const singleInstance = app.requestSingleInstanceLock();
+
let loginCallback;
let mainWindow;
let subWindow;
}
module.exports = class Application {
- loadWindow = () => {
+ loadApplication = () => {
protocol.registerSchemesAsPrivileged([
{ scheme: protocolStr, privileges: { standard: true, bypassCSP: true, secure: true } },
{ scheme: fileProtocolStr, privileges: { standard: false, bypassCSP: true, secure: true } }
console.log('Update downloaded.');
});
- app.on('ready', () => {
- process.env.GOOGLE_API_KEY = config.googleAPIKey;
-
- app.setAppUserModelId(pkg.flast_package_id);
- session.defaultSession.setUserAgent(session.defaultSession.getUserAgent().replace(/ Electron\/[0-9\.]*/g, ''));
-
- autoUpdater.checkForUpdatesAndNotify();
- Menu.setApplicationMenu(null);
-
- windowManager.addWindow();
- // this.loadExtension('gmngpagflejjoblmmamaonmnkghjmebh');
- // this.loadExtension('bdiadchoogngocfifcomfeakccmcecee');
- });
-
- app.on('window-all-closed', () => {
- if (process.platform !== 'darwin') {
- app.quit();
- }
- });
-
- app.on('activate', () => {
- });
-
- app.on('login', (e, webContents, request, authInfo, callback) => {
- e.preventDefault();
-
- subWindow = getBaseWindow(320, 230, 320, 230);
- // subWindow.setParentWindow(mainWindow);
- subWindow.setMovable(false);
- subWindow.setResizable(false);
- subWindow.setMinimizable(false);
- subWindow.setMaximizable(false);
- const startUrl = process.env.ELECTRON_START_URL || url.format({
- pathname: path.join(__dirname, '/../build/index.html'),
- protocol: 'file:',
- slashes: true,
- hash: '/authentication',
+ if (!singleInstance) {
+ app.quit();
+ } else {
+ app.on('second-instance', (e, line, directory) => {
+ windowManager.addWindow();
});
- subWindow.loadURL(startUrl);
- loginCallback = callback;
- });
-
- ipcMain.on('authorization', (event, arg) => {
- loginCallback(arg.username, arg.password);
- subWindow.close();
- });
+ app.on('ready', () => {
+ process.env.GOOGLE_API_KEY = config.googleAPIKey;
+
+ app.setAppUserModelId(pkg.flast_package_id);
+ session.defaultSession.setUserAgent(session.defaultSession.getUserAgent().replace(/ Electron\/[0-9\.]*/g, ''));
+
+ autoUpdater.checkForUpdatesAndNotify();
+ Menu.setApplicationMenu(null);
+
+ windowManager.addWindow();
+ });
+
+ app.on('window-all-closed', () => {
+ if (process.platform !== 'darwin') {
+ app.quit();
+ }
+ });
+
+ app.on('activate', () => {
+ });
+
+ app.on('login', (e, webContents, request, authInfo, callback) => {
+ e.preventDefault();
+
+ subWindow = getBaseWindow(320, 230, 320, 230);
+ // subWindow.setParentWindow(mainWindow);
+ subWindow.setMovable(false);
+ subWindow.setResizable(false);
+ subWindow.setMinimizable(false);
+ subWindow.setMaximizable(false);
+ const startUrl = process.env.ELECTRON_START_URL || url.format({
+ pathname: path.join(__dirname, '/../build/index.html'),
+ protocol: 'file:',
+ slashes: true,
+ hash: '/authentication',
+ });
+
+ subWindow.loadURL(startUrl);
+ loginCallback = callback;
+ });
+
+ ipcMain.on('authorization', (event, arg) => {
+ loginCallback(arg.username, arg.password);
+ subWindow.close();
+ });
+ }
}
loadExtension = (id) => {
const versions = fs.readdirSync(`${extensionDir}/${id}`).sort();
const version = versions.pop();
- // BrowserWindow.addExtension(`${extensionDir}/${id}/${version}`);
- // BrowserWindow.addDevToolsExtension(`${extensionDir}/${id}/${version}`);
extensionsMain.setSession(session.defaultSession);
extensionsMain.load(`${extensionDir}/${id}/${version}`);
}
const Application = require('./Application');
global.Application = new Application();
-global.Application.loadWindow();
\ No newline at end of file
+global.Application.loadApplication();
\ No newline at end of file
ipcMain.on('window-add', (e, args) => {
this.addWindow(args.isPrivate);
});
+
+ ipcMain.on('window-fullScreen', (e, args) => {
+ this.addWindow(args.isPrivate);
+ });
ipcMain.on('window-fixBounds', (e, args) => {
this.windows.forEach((value, key) => {
view.webContents.reloadIgnoringCache();
});
+ localShortcut.register(window, 'F11', () => {
+ const window = this.windows.get(id);
+
+ window.setFullScreen(!window.isFullScreen());
+ this.fixBounds(id, (floatingWindows.indexOf(id) != -1));
+ })
+
this.windows.set(id, window);
if (process.argv != undefined) {
}
registerListeners = (id) => {
- ipcMain.on(`browserview-add-${id}`, (e, args) => {
+ ipcMain.on(`window-fullScreen-${id}`, (e, args) => {
+ const window = this.windows.get(id);
+
+ window.setFullScreen(!window.isFullScreen());
+ this.fixBounds(id, (floatingWindows.indexOf(id) != -1));
+ });
+
+ ipcMain.on(`browserView-add-${id}`, (e, args) => {
this.addView(id, args.url, args.isActive);
});
- ipcMain.on(`browserview-remove-${id}`, (e, args) => {
+ ipcMain.on(`browserView-remove-${id}`, (e, args) => {
this.removeView(id, args.id);
});
- ipcMain.on(`browserview-select-${id}`, (e, args) => {
+ ipcMain.on(`browserView-select-${id}`, (e, args) => {
this.selectView(id, args.id);
});
- ipcMain.on(`browserview-get-${id}`, (e, args) => {
+ ipcMain.on(`browserView-get-${id}`, (e, args) => {
let datas = [];
views[id].map((item) => {
datas.push({ id: item.view.webContents.id, title: item.view.webContents.getTitle(), url, icon: this.getFavicon(url), color: '#0a84ff', isBookmarked: false });
});
- e.sender.send(`browserview-get-${id}`, { views: datas });
+ e.sender.send(`browserView-get-${id}`, { views: datas });
});
- ipcMain.on(`browserview-goBack-${id}`, (e, args) => {
+ ipcMain.on(`browserView-goBack-${id}`, (e, args) => {
views[id].filter(function (view, i) {
if (view.view.webContents.id == args.id) {
let webContents = views[id][i].view.webContents;
});
});
- ipcMain.on(`browserview-goForward-${id}`, (e, args) => {
+ ipcMain.on(`browserView-goForward-${id}`, (e, args) => {
views[id].filter(function (view, i) {
if (view.view.webContents.id == args.id) {
let webContents = views[id][i].view.webContents;
});
});
- ipcMain.on(`browserview-reload-${id}`, (e, args) => {
+ ipcMain.on(`browserView-reload-${id}`, (e, args) => {
views[id].filter(function (view, i) {
if (view.view.webContents.id == args.id) {
let webContents = views[id][i].view.webContents;
});
});
- ipcMain.on(`browserview-stop-${id}`, (e, args) => {
+ ipcMain.on(`browserView-stop-${id}`, (e, args) => {
views[id].filter(function (view, i) {
if (view.view.webContents.id == args.id) {
let webContents = views[id][i].view.webContents;
});
});
- ipcMain.on(`browserview-goHome-${id}`, (e, args) => {
+ ipcMain.on(`browserView-goHome-${id}`, (e, args) => {
views[id].filter(function (view, i) {
if (view.view.webContents.id == args.id) {
let webContents = views[id][i].view.webContents;
});
});
- ipcMain.on(`browserview-loadURL-${id}`, (e, args) => {
+ ipcMain.on(`browserView-loadURL-${id}`, (e, args) => {
views[id].filter(function (view, i) {
if (view.view.webContents.id == args.id) {
let webContents = views[id][i].view.webContents;
});
});
- ipcMain.on(`browserview-loadFile-${id}`, (e, args) => {
+ ipcMain.on(`browserView-loadFile-${id}`, (e, args) => {
views[id].filter(function (view, i) {
if (view.view.webContents.id == args.id) {
let webContents = views[id][i].view.webContents;
});
});
+ ipcMain.on(`browserView-zoomIn-${id}`, (e, args) => {
+ views[id].filter(function (view, i) {
+ if (view.view.webContents.id == args.id) {
+ let webContents = views[id][i].view.webContents;
+ console.log(webContents.getZoomFactor());
+ webContents.setZoomFactor(webContents.getZoomFactor() + 0.1);
+ }
+ });
+ });
+
+ ipcMain.on(`browserView-zoomOut-${id}`, (e, args) => {
+ views[id].filter(function (view, i) {
+ if (view.view.webContents.id == args.id) {
+ let webContents = views[id][i].view.webContents;
+ console.log(webContents.getZoomFactor());
+ webContents.setZoomFactor(webContents.getZoomFactor() - 0.1);
+ }
+ });
+ });
+
ipcMain.on(`data-bookmark-add-${id}`, (e, args) => {
views[id].filter((view, i) => {
if (view.view.webContents.id == args.id) {
db.bookmarks.find({ url: view.webContents.getURL(), isPrivate: (String(id).startsWith('private')) }, (err, docs) => {
const url = view.webContents.getURL();
- window.webContents.send(`browserview-load-${id}`, { id: view.webContents.id, title: view.webContents.getTitle(), url: url, icon: this.getFavicon(url), color: '#0a84ff', isAudioPlaying: !view.webContents.isCurrentlyAudible(), isBookmarked: (docs.length > 0 ? true : false) });
+ window.webContents.send(`browserView-load-${id}`, { id: view.webContents.id, title: view.webContents.getTitle(), url: url, icon: this.getFavicon(url), color: '#0a84ff', isAudioPlaying: !view.webContents.isCurrentlyAudible(), isBookmarked: (docs.length > 0 ? true : false) });
});
}
this.updateNavigationState(windowId, item.view);
this.updateViewState(windowId, item.view);
- window.webContents.send(`browserview-set-${windowId}`, { id: id });
+ window.webContents.send(`browserView-set-${windowId}`, { id: id });
this.fixBounds(windowId, (floatingWindows.indexOf(windowId) != -1));
}
});
window.setBrowserView(item.view);
window.setTitle(`${item.view.webContents.getTitle()} - ${pkg.name}`);
- window.webContents.send(`browserview-set-${windowId}`, { id: item.id });
+ window.webContents.send(`browserView-set-${windowId}`, { id: item.id });
this.fixBounds(windowId, (floatingWindows.indexOf(windowId) != -1));
}
datas.push({ id: views[windowId][i].view.webContents.id, title: views[windowId][i].view.webContents.getTitle(), url: url, icon: this.getFavicon(url) });
}
const window = this.windows.get(windowId);
- window.webContents.send(`browserview-get-${windowId}`, { views: datas });
+ window.webContents.send(`browserView-get-${windowId}`, { views: datas });
}
addTab = (windowId, url = config.get('homePage.defaultPage'), isActive = true) => {
}
});
+ view.webContents.setVisualZoomLevelLimits(1, 3);
+
const window = this.windows.get(windowId);
const id = view.webContents.id;
view.webContents.on('did-start-loading', () => {
if (view.isDestroyed()) return;
- window.webContents.send(`browserview-start-loading-${windowId}`, { id: id });
+ window.webContents.send(`browserView-start-loading-${windowId}`, { id: id });
});
view.webContents.on('did-stop-loading', () => {
if (view.isDestroyed()) return;
- window.webContents.send(`browserview-stop-loading-${windowId}`, { id: id });
+ window.webContents.send(`browserView-stop-loading-${windowId}`, { id: id });
});
view.webContents.on('did-start-navigation', (e) => {
viewId = this.getRandString(12);
this.getCertificate(view.webContents.getURL()).then((certificate) => {
- window.webContents.send(`browserview-certificate-${windowId}`, { id, certificate });
+ window.webContents.send(`browserView-certificate-${windowId}`, { id, certificate });
});
window.setTitle(`${view.webContents.getTitle()} - ${pkg.name}`);
this.updateViewState(windowId, view);
this.updateNavigationState(windowId, view);
- window.webContents.send(`browserview-theme-color-${windowId}`, { id: view.webContents.id, color });
+ window.webContents.send(`browserView-theme-color-${windowId}`, { id: view.webContents.id, color });
});
view.webContents.on('update-target-url', (e, url) => {
views[windowId].push({ id, view, isNotificationBar: false });
if (isActive) {
- window.webContents.send(`browserview-set-${windowId}`, { id: id });
+ window.webContents.send(`browserView-set-${windowId}`, { id: id });
window.setBrowserView(view);
}
newTab: 'New tab',
newWindow: 'New window',
openPrivateWindow: 'Open Private window',
+ zoom: {
+ name: 'Zoom',
+ zoomIn: 'Zoom in',
+ zoomOut: 'Zoom out',
+ fullScreen: 'Full Screen'
+ },
history: 'History',
downloads: 'Downloads',
bookmarks: 'Bookmarks',
app: {
- app: 'Application',
+ name: 'Application',
list: 'App list',
store: 'Flast Store',
install: 'Install {title}',
newTab: '新しいタブ',
newWindow: '新しいウィンドウ',
openPrivateWindow: 'プライベート ウィンドウを開く',
+ zoom: {
+ name: 'ズーム',
+ zoomIn: '拡大',
+ zoomOut: '縮小',
+ fullScreen: '全画面表示'
+ },
history: '履歴',
downloads: 'ダウンロード',
bookmarks: 'ブックマーク',
{
"name": "Flast",
"description": "Cross-platform browser based on Chromium.",
- "version": "2.7.4",
+ "version": "2.8.1",
"flast_channel": "Stable",
"flast_package_id": "org.aoichaan0513.Flast",
"private": true,
});
*/
- ipcRenderer.on(`browserview-start-loading-${this.props.windowId}`, (e, args) => {
+ ipcRenderer.on(`browserView-start-loading-${this.props.windowId}`, (e, args) => {
if (args.id === this.props.index) {
this.setState({ isLoading: true });
this.blockCount = 0;
}
});
- ipcRenderer.on(`browserview-stop-loading-${this.props.windowId}`, (e, args) => {
+ ipcRenderer.on(`browserView-stop-loading-${this.props.windowId}`, (e, args) => {
if (args.id === this.props.index) {
this.setState({ isLoading: false });
}
});
- ipcRenderer.on(`browserview-load-${this.props.windowId}`, (e, args) => {
+ ipcRenderer.on(`browserView-load-${this.props.windowId}`, (e, args) => {
if (args.id === this.props.index) {
this.props.updateTab();
this.setState({ viewUrl: args.url, isBookmarked: args.isBookmarked });
}
});
- ipcRenderer.on(`browserview-certificate-${this.props.windowId}`, (e, args) => {
+ ipcRenderer.on(`browserView-certificate-${this.props.windowId}`, (e, args) => {
if (args.id === this.props.index) {
this.setState({ certificate: args.certificate });
}
}
});
- ipcRenderer.on(`browserview-permission-${this.props.windowId}`, (e, args) => {
+ ipcRenderer.on(`browserView-permission-${this.props.windowId}`, (e, args) => {
if (args.id === this.props.index) {
const toolTip = findDOMNode(this.infomationTooltip)._tippy;
toolTip.setContent(args.content);
if (this.state.barText.length > 0 || this.state.barText !== '') {
this.setState({ isInputed: false });
if (isURL(this.state.barText) && !this.state.barText.includes('://')) {
- ipcRenderer.send(`browserview-loadURL-${this.props.windowId}`, { id: this.props.index, url: `http://${this.state.barText}` });
+ ipcRenderer.send(`browserView-loadURL-${this.props.windowId}`, { id: this.props.index, url: `http://${this.state.barText}` });
} else if (!this.state.barText.includes('://')) {
- ipcRenderer.send(`browserview-loadURL-${this.props.windowId}`, { id: this.props.index, url: this.getSearchEngine().url.replace('%s', this.state.barText) });
+ ipcRenderer.send(`browserView-loadURL-${this.props.windowId}`, { id: this.props.index, url: this.getSearchEngine().url.replace('%s', this.state.barText) });
} else {
const pattern = /^(file:\/\/\S.*)\S*$/;
if (pattern.test(this.state.barText)) {
- ipcRenderer.send(`browserview-loadFile-${this.props.windowId}`, { id: this.props.index, url: this.state.barText.replace('file:///', '') });
+ ipcRenderer.send(`browserView-loadFile-${this.props.windowId}`, { id: this.props.index, url: this.state.barText.replace('file:///', '') });
} else {
- ipcRenderer.send(`browserview-loadURL-${this.props.windowId}`, { id: this.props.index, url: this.state.barText });
+ ipcRenderer.send(`browserView-loadURL-${this.props.windowId}`, { id: this.props.index, url: this.state.barText });
}
}
} else {
}
goBack = () => {
- ipcRenderer.send(`browserview-goBack-${this.props.windowId}`, { id: this.props.index });
+ ipcRenderer.send(`browserView-goBack-${this.props.windowId}`, { id: this.props.index });
}
goForward = () => {
- ipcRenderer.send(`browserview-goForward-${this.props.windowId}`, { id: this.props.index });
+ ipcRenderer.send(`browserView-goForward-${this.props.windowId}`, { id: this.props.index });
}
reload = () => {
if (!this.state.isLoading) {
- ipcRenderer.send(`browserview-reload-${this.props.windowId}`, { id: this.props.index });
+ ipcRenderer.send(`browserView-reload-${this.props.windowId}`, { id: this.props.index });
} else {
- ipcRenderer.send(`browserview-stop-${this.props.windowId}`, { id: this.props.index });
+ ipcRenderer.send(`browserView-stop-${this.props.windowId}`, { id: this.props.index });
}
}
goHome = () => {
- ipcRenderer.send(`browserview-goHome-${this.props.windowId}`, { id: this.props.index });
+ ipcRenderer.send(`browserView-goHome-${this.props.windowId}`, { id: this.props.index });
}
certificate = () => {
]);
menu.popup({
x: remote.getCurrentWindow().getSize()[0] - 57,
- y: 65
+ y: 67
});
}
},
{ type: 'separator' },
{
+ label: lang.window.toolBar.menu.menus.zoom.name,
+ type: 'submenu',
+ submenu: [
+ {
+ label: lang.window.toolBar.menu.menus.zoom.zoomIn,
+ icon: `${app.getAppPath()}/static/zoom_in.png`,
+ click: () => { ipcRenderer.send(`browserView-zoomIn-${this.props.windowId}`, { id: this.props.index }); }
+ },
+ {
+ label: lang.window.toolBar.menu.menus.zoom.zoomOut,
+ icon: `${app.getAppPath()}/static/zoom_out.png`,
+ click: () => { ipcRenderer.send(`browserView-zoomOut-${this.props.windowId}`, { id: this.props.index }); }
+ },
+ { type: 'separator' },
+ {
+ label: lang.window.toolBar.menu.menus.zoom.fullScreen,
+ icon: `${app.getAppPath()}/static/fullscreen.png`,
+ click: () => { ipcRenderer.send(`window-fullScreen-${this.props.windowId}`, {}); }
+ }
+ ]
+ },
+ { type: 'separator' },
+ {
label: lang.window.toolBar.menu.menus.history,
icon: `${app.getAppPath()}/static/history.png`,
click: () => { this.props.addTab(`${protocolStr}://history/`); }
]);
menu.popup({
x: remote.getCurrentWindow().getSize()[0] - 24,
- y: 65
+ y: 67
});
}
this.addTab(args.url);
});
- ipcRenderer.on(`browserview-get-${this.props.match.params.windowId}`, (e, args) => {
+ ipcRenderer.on(`browserView-get-${this.props.match.params.windowId}`, (e, args) => {
this.setState({ tabs: args.views });
});
- ipcRenderer.on(`browserview-set-${this.props.match.params.windowId}`, (e, args) => {
+ ipcRenderer.on(`browserView-set-${this.props.match.params.windowId}`, (e, args) => {
this.setState({ current: args.id });
});
}
}
getTabs = () => {
- ipcRenderer.send(`browserview-get-${this.props.match.params.windowId}`, {});
+ ipcRenderer.send(`browserView-get-${this.props.match.params.windowId}`, {});
}
addTab = (url = (config.get('homePage.isDefaultHomePage') ? `${protocolStr}://home/` : config.get('homePage.defaultPage'))) => {
- ipcRenderer.send(`browserview-add-${this.props.match.params.windowId}`, { url, isActive: true });
- ipcRenderer.send(`browserview-get-${this.props.match.params.windowId}`, {});
+ ipcRenderer.send(`browserView-add-${this.props.match.params.windowId}`, { url, isActive: true });
+ ipcRenderer.send(`browserView-get-${this.props.match.params.windowId}`, {});
this.setState({ current: this.state.tabs.length });
}
removeTab = (i) => {
- ipcRenderer.send(`browserview-remove-${this.props.match.params.windowId}`, { id: i });
- ipcRenderer.send(`browserview-get-${this.props.match.params.windowId}`, {});
+ ipcRenderer.send(`browserView-remove-${this.props.match.params.windowId}`, { id: i });
+ ipcRenderer.send(`browserView-get-${this.props.match.params.windowId}`, {});
this.forceUpdate();
if ((this.state.tabs.length - 1) < 1) {
}
updateTab = () => {
- ipcRenderer.send(`browserview-get-${this.props.match.params.windowId}`, {});
+ ipcRenderer.send(`browserView-get-${this.props.match.params.windowId}`, {});
}
getForegroundColor = (hexColor) => {
<TabContainer ref={ref => { this.tabContainer = ref; }}>
{this.state.tabs.map((tab, i) => {
return (
- <Tab isDarkModeOrPrivateMode={config.get('design.isDarkTheme') || String(this.props.match.params.windowId).startsWith('private')} isActive={tab.id === this.state.current} isFixed={tab.fixed} accentColor={tab.color} onClick={() => { ipcRenderer.send(`browserview-select-${this.props.match.params.windowId}`, { id: tab.id }); this.forceUpdate(); }} onContextMenu={this.handleContextMenu.bind(this, tab.id)}>
+ <Tab isDarkModeOrPrivateMode={config.get('design.isDarkTheme') || String(this.props.match.params.windowId).startsWith('private')} isActive={tab.id === this.state.current} isFixed={tab.fixed} accentColor={tab.color} onClick={() => { ipcRenderer.send(`browserView-select-${this.props.match.params.windowId}`, { id: tab.id }); this.forceUpdate(); }} onContextMenu={this.handleContextMenu.bind(this, tab.id)}>
<TabIcon src={tab.icon !== undefined ? tab.icon : (config.get('design.isDarkTheme') || String(this.props.match.params.windowId).startsWith('private') ? DarkPublicIcon : LightPublicIcon)} width={18} height={18} />
<TabTitle color={this.getForegroundColor(!config.get('design.isDarkTheme') || !String(this.props.match.params.windowId).startsWith('private') ? (platform.isWin32 || platform.isDarwin ? `#${systemPreferences.getAccentColor()}` : '#353535') : '#353535')} isAudioPlaying={tab.isAudioPlaying} isFixed={tab.fixed} title={tab.title}>{tab.title}</TabTitle>
<TabCloseButton isActive={tab.id === this.state.current} isFixed={tab.fixed} isRight={true} src={this.isDarkModeOrPrivateMode.bind(this, LightCloseIcon, DarkCloseIcon)} size={14} title={lang.window.titleBar.tab.close} onClick={() => { this.removeTab(tab.id); this.forceUpdate(); }} />
{
"name": "Flast",
"description": "Cross-platform browser based on Chromium.",
- "version": "2.7.4",
+ "version": "2.8.1",
"flast_channel": "Stable",
"flast_package_id": "org.aoichaan0513.Flast",
"private": true,