mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-20 23:36:18 +00:00
8205324: Part of java.awt.Desktop.browse(URI) spec is outdated after support of applets was removed
Reviewed-by: prr
This commit is contained in:
parent
38131ccda6
commit
47c7fc7a8a
@ -40,10 +40,9 @@ import java.awt.peer.DesktopPeer;
|
||||
import java.io.File;
|
||||
import java.io.FilePermission;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.swing.JMenuBar;
|
||||
|
||||
@ -505,13 +504,6 @@ public class Desktop {
|
||||
* {@code URIs} of the specified type is invoked. The application
|
||||
* is determined from the protocol and path of the {@code URI}, as
|
||||
* defined by the {@code URI} class.
|
||||
* <p>
|
||||
* If the calling thread does not have the necessary permissions,
|
||||
* and this is invoked from within an applet,
|
||||
* {@code AppletContext.showDocument()} is used. Similarly, if the calling
|
||||
* does not have the necessary permissions, and this is invoked from within
|
||||
* a Java Web Started application, {@code BasicService.showDocument()}
|
||||
* is used.
|
||||
*
|
||||
* @param uri the URI to be displayed in the user default browser
|
||||
* @throws NullPointerException if {@code uri} is {@code null}
|
||||
@ -524,46 +516,16 @@ public class Desktop {
|
||||
* denies the
|
||||
* {@code AWTPermission("showWindowWithoutWarningBanner")}
|
||||
* permission, or the calling thread is not allowed to create a
|
||||
* subprocess; and not invoked from within an applet or Java Web Started
|
||||
* application
|
||||
* @throws IllegalArgumentException if the necessary permissions
|
||||
* are not available and the URI can not be converted to a {@code URL}
|
||||
* subprocess
|
||||
* @see java.net.URI
|
||||
* @see java.awt.AWTPermission
|
||||
* @see java.applet.AppletContext
|
||||
*/
|
||||
public void browse(URI uri) throws IOException {
|
||||
SecurityException securityException = null;
|
||||
try {
|
||||
checkAWTPermission();
|
||||
checkExec();
|
||||
} catch (SecurityException e) {
|
||||
securityException = e;
|
||||
}
|
||||
checkAWTPermission();
|
||||
checkExec();
|
||||
checkActionSupport(Action.BROWSE);
|
||||
if (uri == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (securityException == null) {
|
||||
peer.browse(uri);
|
||||
return;
|
||||
}
|
||||
|
||||
// Calling thread doesn't have necessary privileges.
|
||||
// Delegate to DesktopBrowse so that it can work in
|
||||
// applet/webstart.
|
||||
URL url = null;
|
||||
try {
|
||||
url = uri.toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new IllegalArgumentException("Unable to convert URI to URL", e);
|
||||
}
|
||||
sun.awt.DesktopBrowse db = sun.awt.DesktopBrowse.getInstance();
|
||||
if (db == null) {
|
||||
// Not in webstart/applet, throw the exception.
|
||||
throw securityException;
|
||||
}
|
||||
db.browse(url);
|
||||
Objects.requireNonNull(uri);
|
||||
peer.browse(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.awt;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public abstract class DesktopBrowse {
|
||||
private static volatile DesktopBrowse mInstance;
|
||||
|
||||
public static void setInstance(DesktopBrowse instance) {
|
||||
if (mInstance != null) {
|
||||
throw new IllegalStateException("DesktopBrowse instance has already been set.");
|
||||
}
|
||||
mInstance = instance;
|
||||
}
|
||||
|
||||
public static DesktopBrowse getInstance() {
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
|
||||
public abstract void browse(URL url);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user