Add a hack to prevent Chrome from hard-crashing when opening links from inner

pull/1/head
yflory 4 years ago
parent 8874f2fdb1
commit ff8c811227

@ -1598,9 +1598,9 @@ define([
content: h('span', Messages.profileButton), content: h('span', Messages.profileButton),
action: function () { action: function () {
if (padType) { if (padType) {
window.open(origin+'/profile/'); Common.openURL(origin+'/profile/');
} else { } else {
window.parent.location = origin+'/profile/'; Common.gotoURL(origin+'/profile/');
} }
}, },
}); });
@ -1645,9 +1645,9 @@ define([
content: h('span', Messages.settingsButton), content: h('span', Messages.settingsButton),
action: function () { action: function () {
if (padType) { if (padType) {
window.open(origin+'/settings/'); Common.openURL(origin+'/settings/');
} else { } else {
window.parent.location = origin+'/settings/'; Common.gotoURL(origin+'/settings/');
} }
}, },
}); });
@ -1662,9 +1662,9 @@ define([
content: h('span', Messages.adminPage || 'Admin'), content: h('span', Messages.adminPage || 'Admin'),
action: function () { action: function () {
if (padType) { if (padType) {
window.open(origin+'/admin/'); Common.openURL(origin+'/admin/');
} else { } else {
window.parent.location = origin+'/admin/'; Common.gotoURL(origin+'/admin/');
} }
}, },
}); });
@ -1676,9 +1676,9 @@ define([
content: h('span', Messages.supportPage || 'Support'), content: h('span', Messages.supportPage || 'Support'),
action: function () { action: function () {
if (padType) { if (padType) {
window.open(origin+'/support/'); Common.openURL(origin+'/support/');
} else { } else {
window.parent.location = origin+'/support/'; Common.gotoURL(origin+'/support/');
} }
}, },
}); });
@ -1763,7 +1763,7 @@ define([
content: h('span', Messages.logoutEverywhere), content: h('span', Messages.logoutEverywhere),
action: function () { action: function () {
Common.getSframeChannel().query('Q_LOGOUT_EVERYWHERE', null, function () { Common.getSframeChannel().query('Q_LOGOUT_EVERYWHERE', null, function () {
window.parent.location = origin + '/'; Common.gotoURL(origin + '/');
}); });
}, },
}); });
@ -1773,7 +1773,7 @@ define([
content: h('span', Messages.logoutButton), content: h('span', Messages.logoutButton),
action: function () { action: function () {
Common.logout(function () { Common.logout(function () {
window.parent.location = origin+'/'; Common.gotoURL(origin+'/');
}); });
}, },
}); });

@ -1355,6 +1355,10 @@ define([
}); });
}; };
APP.openURL = function (url) {
common.openUnsafeURL(url);
};
APP.loadingImage = 0; APP.loadingImage = 0;
APP.getImageURL = function(name, callback) { APP.getImageURL = function(name, callback) {
var mediasSources = getMediasSources(); var mediasSources = getMediasSources();

File diff suppressed because one or more lines are too long

@ -136,13 +136,11 @@ define([
file.uid = Util.uid(); file.uid = Util.uid();
response.expect(file.uid, function (href) { response.expect(file.uid, function (href) {
var mdMgr = common.getMetadataMgr();
var origin = mdMgr.getPrivateData().origin;
$link.prepend($('<span>', {'class': 'fa fa-external-link'})); $link.prepend($('<span>', {'class': 'fa fa-external-link'}));
$link.attr('href', href) $link.attr('href', href)
.click(function (e) { .click(function (e) {
e.preventDefault(); e.preventDefault();
window.open(origin + $link.attr('href'), '_blank'); common.openURL($link.attr('href'));
}); });
var title = metadata.name; var title = metadata.name;
if (!config.noStore) { if (!config.noStore) {

@ -722,7 +722,16 @@ define([
sframeChan.on('EV_OPEN_URL', function (url) { sframeChan.on('EV_OPEN_URL', function (url) {
if (url) { if (url) {
window.open(url); var a = window.open(url);
if (!a) {
sframeChan.event('EV_POPUP_BLOCKED');
}
}
});
sframeChan.on('EV_OPEN_UNSAFE_URL', function (url) {
if (url) {
window.open(ApiConfig.httpSafeOrigin + '/bounce/#' + encodeURIComponent(url));
} }
}); });

@ -552,6 +552,10 @@ define([
funcs.gotoURL = function (url) { ctx.sframeChan.event('EV_GOTO_URL', url); }; funcs.gotoURL = function (url) { ctx.sframeChan.event('EV_GOTO_URL', url); };
funcs.openURL = function (url) { ctx.sframeChan.event('EV_OPEN_URL', url); }; funcs.openURL = function (url) { ctx.sframeChan.event('EV_OPEN_URL', url); };
funcs.openUnsafeURL = function (url) { funcs.openUnsafeURL = function (url) {
var app = ctx.metadataMgr.getPrivateData().app;
if (app === "sheet") {
return void ctx.sframeChan.event('EV_OPEN_UNSAFE_URL', url);
}
var bounceHref = window.location.origin + '/bounce/#' + encodeURIComponent(url); var bounceHref = window.location.origin + '/bounce/#' + encodeURIComponent(url);
window.open(bounceHref); window.open(bounceHref);
}; };
@ -682,6 +686,10 @@ define([
UI.errorLoadingScreen(Messages.password_error_seed); UI.errorLoadingScreen(Messages.password_error_seed);
}); });
ctx.sframeChan.on("EV_POPUP_BLOCKED", function () {
UI.alert(Messages.errorPopupBlocked);
});
ctx.sframeChan.on("EV_EXPIRED_ERROR", function () { ctx.sframeChan.on("EV_EXPIRED_ERROR", function () {
funcs.onServerError({ funcs.onServerError({
type: 'EEXPIRED' type: 'EEXPIRED'

@ -338,7 +338,7 @@ MessengerUI, Messages) {
if (data.profile) { if (data.profile) {
$span.addClass('cp-userlist-clickable'); $span.addClass('cp-userlist-clickable');
$span.click(function () { $span.click(function () {
window.open(origin+'/profile/#' + data.profile); Common.openURL(origin+'/profile/#' + data.profile);
}); });
} }
Common.displayAvatar($span, data.avatar, name, function () { Common.displayAvatar($span, data.avatar, name, function () {
@ -838,10 +838,10 @@ MessengerUI, Messages) {
var onClick = function (e) { var onClick = function (e) {
e.preventDefault(); e.preventDefault();
if (e.ctrlKey) { if (e.ctrlKey) {
window.open(href); Common.openURL(href);
return; return;
} }
window.parent.location = href; Common.gotoURL(href);
}; };
var onContext = function (e) { e.stopPropagation(); }; var onContext = function (e) { e.stopPropagation(); };

Loading…
Cancel
Save