Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #171 #239

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added basic support for #171 feature to the button
  • Loading branch information
jtprichett committed Jul 6, 2017
commit 99e48e6945184898a09b38680555c4668389686e
5 changes: 4 additions & 1 deletion src/Platform_Core/org/lobobrowser/gui/FramePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,10 @@ public boolean isRequestPermitted(final Request request) {
public void manageRequests(final Object initiator) {
requestManager.manageRequests((JComponent) initiator);
}


public int[] getAcceptRejectData() {
return requestManager.getAcceptRejectData();
}
public void allowAllFirstPartyRequests() {
requestManager.allowAllFirstPartyRequests();
}
Expand Down
42 changes: 28 additions & 14 deletions src/Platform_Core/org/lobobrowser/security/RequestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public final class RequestManager {
/**
* Constructor for the RequestManager class
*
* @param frame navigation frame that the user will interact with
* @param frame
* navigation frame that the user will interact with
*/
public RequestManager(final NavigatorFrame frame) {
this.frame = frame;
Expand Down Expand Up @@ -83,7 +84,8 @@ public String toString() {
* updateCounter: helper function to update the counter for a given request
* within the hostToCounterMap
*
* @param request that has been made by the user
* @param request
* that has been made by the user
*/
private synchronized void updateCounter(final Request request) {
final String host = request.url.getHost().toLowerCase();
Expand All @@ -94,8 +96,10 @@ private synchronized void updateCounter(final Request request) {
* updateCounter: updates the counter for a given host based on the kind of
* request that was queried
*
* @param String specified host from URL bar
* @param {@link org.lobobrowser.ua.UserAgentContext.RequestKind}
* @param String
* specified host from URL bar
* @param {@link
* org.lobobrowser.ua.UserAgentContext.RequestKind}
*/
private synchronized void updateCounter(final String host, final RequestKind kind) {
ensureHostInCounter(host);
Expand All @@ -106,7 +110,8 @@ private synchronized void updateCounter(final String host, final RequestKind kin
* ensureHostInCounter: ensures that the given URL has been stored with it's
* given request counters for it's returned types
*
* @param String host from the URL bar
* @param String
* host from the URL bar
*/
private void ensureHostInCounter(final String host) {
if (!hostToCounterMap.containsKey(host)) {
Expand All @@ -128,7 +133,8 @@ private Optional<NavigationEntry> getFrameNavigationEntry() {
/**
* getFrameHost: returns a specified hostname
*
* @return String the requested hostname
* @return String
* the requested hostname
*/
private Optional<String> getFrameHost() {
return getFrameNavigationEntry().map(e -> {
Expand All @@ -149,7 +155,9 @@ private Optional<URL> getFrameURL() {
/**
* rewriteRequest: will rewrite any request that has been made by a user
*
* @param request {@link org.lobobrowser.ua.UserAgentContext.Request} Request object that was originally intended to be made
* @param request
* {@link org.lobobrowser.ua.UserAgentContext.Request} Request object
* that was originally intended to be made
* @return newly created request object
*/
private Request rewriteRequest(final Request request) {
Expand All @@ -171,7 +179,8 @@ private Request rewriteRequest(final Request request) {
* permitted 2) If request is permitted update associated fields with request
* parameters 3) Else update request has been rejected
*
* @param request that has been made by the user
* @param request
* that has been made by the user
* @return boolean request has either been permitted or rejected
*/
public boolean isRequestPermitted(final Request request) {
Expand Down Expand Up @@ -236,7 +245,8 @@ private synchronized void dumpCounters() {
* getRequestKindNames: returns a list of the types of requests that can be
* made {@link org.lobobrowser.ua.UserAgentContext.RequestKind}
*
* @return Stream<String> stream of shortened name for the given request
* @return Stream<String>
* stream of shortened name for the given request
*/
private static Stream<String> getRequestKindNames() {
return Arrays.stream(RequestKind.values()).map(kind -> kind.shortName);
Expand All @@ -245,7 +255,8 @@ private static Stream<String> getRequestKindNames() {
/**
* reset: Resets all request information each time a new URL name is entered.
*
* @param URL current URL entered by the user
* @param URL
* current URL entered by the user
*/
public synchronized void reset(final URL frameUrl) {
hostToCounterMap = new HashMap<>();
Expand All @@ -261,7 +272,8 @@ public synchronized void reset(final URL frameUrl) {
* manageRequests: sets up the RequestManager component this is called from
* {@link org.lobobrowser.gui.FramePanel}
*
* @param initiatorComponent the top-level swing container
* @param initiatorComponent
* the top-level swing container
*/
public void manageRequests(final JComponent initiatorComponent) {
// permissionSystemOpt.ifPresent(r -> r.dump());
Expand All @@ -274,7 +286,8 @@ public void manageRequests(final JComponent initiatorComponent) {
* getRequestData: called by {@link org.lobobrowser.security.RequestManager}
* and populates the RequestManager GUI with a requests return counter values.
*
* @return String[][] a two dimensional array of a requests counter values
* @return String[][]
* a two dimensional array of a requests counter values
*/
private synchronized String[][] getRequestData() {
// hostToCounterMap.keySet().stream().forEach(System.out::println);
Expand All @@ -294,7 +307,7 @@ private synchronized String[][] getRequestData() {
*
* @return int[] an integer array sub two values 0 for accept 1 for reject
*/
private synchronized int[] getAcceptRejectData() {
public synchronized int[] getAcceptRejectData() {
int[] temp = new int[2];
temp[0] = acceptedRequests;
temp[1] = rejectedRequests;
Expand All @@ -306,7 +319,8 @@ private synchronized int[] getAcceptRejectData() {
* types such as: img CSS Cookie JS Frame XHR Referrer Unsecured HTTP
* {@link org.lobobrowser.ua.UserAgentContext.RequestKind}
*
* @return String[] list of request type names
* @return String[]
* list of request type names
*/
private static String[] getColumnNames() {
final List<String> kindNames = getRequestKindNames().collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,5 +411,8 @@ public void navigate(@NonNull URL url, String method, ParameterInfo paramInfo, T

public void manageRequests(Object initiator);


public int[] getAcceptRejectData();

public void allowAllFirstPartyRequests();
}
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ public void documentRendering(final NavigatorWindowEvent event) {
if (this.window.getTopFrame() == event.getNavigatorFrame()) {
this.clearState();
this.actionPool.updateEnabling();

}
}

Expand All @@ -431,6 +432,8 @@ private void clearState() {
this.statusMessage = null;
this.defaultStatusMessage = null;
this.statusMessageComponent.setText("");
/** Emplace here until finding a better solution **/
processAcceptedRejected();
}

public void progressUpdated(final NavigatorProgressEvent event) {
Expand All @@ -443,8 +446,15 @@ public void progressUpdated(final NavigatorProgressEvent event) {
}
}
this.statusMessageComponent.setText(ClientletRequestHandler.getProgressMessage(event.getProgressType(), event.getUrl()));

}

public void processAcceptedRejected() {
int[] acceptRejectData = window.getTopFrame().getAcceptRejectData();
if (reqManagerButton instanceof JButton) {
reqManagerButton.setText("Req Mgr" + " " + "A: " + acceptRejectData[0] + " D: " + acceptRejectData[1]);
}
}
private String statusMessage;

public void statusUpdated(final NavigatorWindowEvent event) {
Expand Down