forked from crosswalk-project/crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Update shouldInterceptLoadRequest to Android L style
As current API misses lots of context, The older API:shouldInterceptRequest(WebView view, String url) was deprecated in Android API level 21, and was replaced by shouldInterceptRequest(WebView view, WebResourceRequest request), so update XWalk's corresponding API. However, this new API can be used in all Android version. BUG=XWALK-3934
- Loading branch information
Showing
31 changed files
with
764 additions
and
369 deletions.
There are no files selected for viewing
42 changes: 0 additions & 42 deletions
42
runtime/android/core_internal/src/org/xwalk/core/internal/InterceptedRequestData.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
.../android/core_internal/src/org/xwalk/core/internal/WebResourceRequestHandlerInternal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package org.xwalk.core.internal; | ||
|
||
import android.net.Uri; | ||
|
||
import java.util.Map; | ||
|
||
@XWalkAPI(impl = WebResourceRequestInternal.class, createInternally = true) | ||
public class WebResourceRequestHandlerInternal implements WebResourceRequestInternal { | ||
private final XWalkContentsClientBridge.XWalkWebResourceRequest mRequest; | ||
|
||
WebResourceRequestHandlerInternal(XWalkContentsClientBridge.XWalkWebResourceRequest request) { | ||
mRequest = request; | ||
} | ||
|
||
// Never use this constructor. | ||
// It is only used in WebResourceRequestHandlerBridge. | ||
WebResourceRequestHandlerInternal() { | ||
mRequest = null; | ||
} | ||
|
||
@XWalkAPI | ||
public Uri getUrl() { | ||
return Uri.parse(mRequest.url); | ||
} | ||
|
||
@XWalkAPI | ||
public boolean isForMainFrame() { | ||
return mRequest.isMainFrame; | ||
} | ||
|
||
@XWalkAPI | ||
public boolean hasGesture() { | ||
return mRequest.hasUserGesture; | ||
} | ||
|
||
@XWalkAPI | ||
public String getMethod() { | ||
return mRequest.method; | ||
} | ||
|
||
@XWalkAPI | ||
public Map<String, String> getRequestHeaders() { | ||
return mRequest.requestHeaders; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
runtime/android/core_internal/src/org/xwalk/core/internal/WebResourceRequestInternal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2014 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.xwalk.core.internal; | ||
|
||
import android.net.Uri; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Encompasses parameters to the {@link XWalkResourceClient#shouldInterceptLoadRequest} method. | ||
*/ | ||
@XWalkAPI(instance = WebResourceRequestHandlerInternal.class) | ||
public interface WebResourceRequestInternal { | ||
/** | ||
* Gets the URL for which the resource request was made. | ||
* | ||
* @return the URL for which the resource request was made. | ||
* @since 6.0 | ||
*/ | ||
@XWalkAPI | ||
public Uri getUrl(); | ||
|
||
/** | ||
* Gets whether the request was made for the main frame. | ||
* | ||
* @return whether the request was made for the main frame. Will be false for iframes, | ||
* for example. | ||
* @since 6.0 | ||
*/ | ||
@XWalkAPI | ||
public boolean isForMainFrame(); | ||
|
||
/** | ||
* Gets whether a gesture (such as a click) was associated with the request. | ||
* For security reasons in certain situations this method may return false even though the | ||
* sequence of events which caused the request to be created was initiated by a user gesture. | ||
* | ||
* @return whether a gesture was associated with the request. | ||
* @since 6.0 | ||
*/ | ||
@XWalkAPI | ||
public boolean hasGesture(); | ||
|
||
/** | ||
* Gets the method associated with the request, for example "GET". | ||
* | ||
* @return the method associated with the request. | ||
* @since 6.0 | ||
*/ | ||
@XWalkAPI | ||
public String getMethod(); | ||
|
||
/** | ||
* Gets the headers associated with the request. These are represented as a mapping of header | ||
* name to header value. | ||
* | ||
* @return the headers associated with the request. | ||
* @since 6.0 | ||
*/ | ||
@XWalkAPI | ||
public Map<String, String> getRequestHeaders(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.