Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ios
/
YH_Explorer
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
孟顺
6 years ago
Commit
e370ccf0ea9cdd7e255e9a4268529efbaee63518
1 parent
08ba2c3b
移除IntentAndNavigationFilter无用插件 解决 scheme 跳转问题
review by 枪兵
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 additions
and
194 deletions
YHExplorer/CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.h
YHExplorer/CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m
YHExplorer/CordovaLib/config.xml
YHExplorer/YHPlugins/CDVYHInterface.m
YHExplorer/CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.h
deleted
100755 → 0
View file @
08ba2c3
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
*/
#import <CDVPlugin.h>
#import <CDVWhitelist.h>
typedef
NS_ENUM
(
NSInteger
,
CDVIntentAndNavigationFilterValue
)
{
CDVIntentAndNavigationFilterValueIntentAllowed
,
CDVIntentAndNavigationFilterValueNavigationAllowed
,
CDVIntentAndNavigationFilterValueNoneAllowed
};
@interface
CDVIntentAndNavigationFilter
:
CDVPlugin
<
NSXMLParserDelegate
>
+
(
CDVIntentAndNavigationFilterValue
)
filterUrl
:
(
NSURL
*
)
url
intentsWhitelist
:
(
CDVWhitelist
*
)
intentsWhitelist
navigationsWhitelist
:
(
CDVWhitelist
*
)
navigationsWhitelist
;
+
(
BOOL
)
shouldOverrideLoadWithRequest
:(
NSURLRequest
*
)
request
navigationType
:(
UIWebViewNavigationType
)
navigationType
filterValue
:(
CDVIntentAndNavigationFilterValue
)
filterValue
;
+
(
BOOL
)
shouldOpenURLRequest
:(
NSURLRequest
*
)
request
navigationType
:(
UIWebViewNavigationType
)
navigationType
;
@end
YHExplorer/CordovaLib/Classes/Private/Plugins/CDVIntentAndNavigationFilter/CDVIntentAndNavigationFilter.m
deleted
100755 → 0
View file @
08ba2c3
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
*/
#import "CDVIntentAndNavigationFilter.h"
#import <CDV.h>
@interface
CDVIntentAndNavigationFilter
()
@property
(
nonatomic
,
readwrite
)
NSMutableArray
*
allowIntents
;
@property
(
nonatomic
,
readwrite
)
NSMutableArray
*
allowNavigations
;
@property
(
nonatomic
,
readwrite
)
CDVWhitelist
*
allowIntentsWhitelist
;
@property
(
nonatomic
,
readwrite
)
CDVWhitelist
*
allowNavigationsWhitelist
;
@end
@implementation
CDVIntentAndNavigationFilter
#pragma mark NSXMLParserDelegate
-
(
void
)
parser
:(
NSXMLParser
*
)
parser
didStartElement
:(
NSString
*
)
elementName
namespaceURI
:(
NSString
*
)
namespaceURI
qualifiedName
:(
NSString
*
)
qualifiedName
attributes
:(
NSDictionary
*
)
attributeDict
{
if
([
elementName
isEqualToString
:
@"allow-navigation"
])
{
[
self
.
allowNavigations
addObject
:
attributeDict
[
@"href"
]];
}
if
([
elementName
isEqualToString
:
@"allow-intent"
])
{
[
self
.
allowIntents
addObject
:
attributeDict
[
@"href"
]];
}
}
-
(
void
)
parserDidStartDocument
:(
NSXMLParser
*
)
parser
{
// file: url <allow-navigations> are added by default
self
.
allowNavigations
=
[[
NSMutableArray
alloc
]
initWithArray
:@[
@"file://"
]];
// no intents are added by default
self
.
allowIntents
=
[[
NSMutableArray
alloc
]
init
];
}
-
(
void
)
parserDidEndDocument
:(
NSXMLParser
*
)
parser
{
self
.
allowIntentsWhitelist
=
[[
CDVWhitelist
alloc
]
initWithArray
:
self
.
allowIntents
];
self
.
allowNavigationsWhitelist
=
[[
CDVWhitelist
alloc
]
initWithArray
:
self
.
allowNavigations
];
}
-
(
void
)
parser
:(
NSXMLParser
*
)
parser
parseErrorOccurred
:(
NSError
*
)
parseError
{
NSAssert
(
NO
,
@"config.xml parse error line %ld col %ld"
,
(
long
)[
parser
lineNumber
],
(
long
)[
parser
columnNumber
]);
}
#pragma mark CDVPlugin
-
(
void
)
pluginInitialize
{
if
([
self
.
viewController
isKindOfClass
:[
CDVViewController
class
]])
{
[(
CDVViewController
*
)
self
.
viewController
parseSettingsWithParser
:
self
];
}
}
+
(
CDVIntentAndNavigationFilterValue
)
filterUrl
:
(
NSURL
*
)
url
intentsWhitelist
:
(
CDVWhitelist
*
)
intentsWhitelist
navigationsWhitelist
:
(
CDVWhitelist
*
)
navigationsWhitelist
{
// a URL can only allow-intent OR allow-navigation, if both are specified,
// only allow-navigation is allowed
BOOL
allowNavigationsPass
=
[
navigationsWhitelist
URLIsAllowed
:
url
logFailure
:
NO
];
BOOL
allowIntentPass
=
[
intentsWhitelist
URLIsAllowed
:
url
logFailure
:
NO
];
if
(
allowNavigationsPass
&&
allowIntentPass
)
{
return
CDVIntentAndNavigationFilterValueNavigationAllowed
;
}
else
if
(
allowNavigationsPass
)
{
return
CDVIntentAndNavigationFilterValueNavigationAllowed
;
}
else
if
(
allowIntentPass
)
{
return
CDVIntentAndNavigationFilterValueIntentAllowed
;
}
return
CDVIntentAndNavigationFilterValueNoneAllowed
;
}
-
(
CDVIntentAndNavigationFilterValue
)
filterUrl
:
(
NSURL
*
)
url
{
return
[[
self
class
]
filterUrl
:
url
intentsWhitelist
:
self
.
allowIntentsWhitelist
navigationsWhitelist
:
self
.
allowNavigationsWhitelist
];
}
+
(
BOOL
)
shouldOpenURLRequest
:
(
NSURLRequest
*
)
request
navigationType
:
(
UIWebViewNavigationType
)
navigationType
{
return
(
UIWebViewNavigationTypeLinkClicked
==
navigationType
||
(
UIWebViewNavigationTypeOther
==
navigationType
&&
[[
request
.
mainDocumentURL
absoluteString
]
isEqualToString
:[
request
.
URL
absoluteString
]]
)
);
}
+
(
BOOL
)
shouldOverrideLoadWithRequest
:
(
NSURLRequest
*
)
request
navigationType
:
(
UIWebViewNavigationType
)
navigationType
filterValue
:
(
CDVIntentAndNavigationFilterValue
)
filterValue
{
NSString
*
allowIntents_whitelistRejectionFormatString
=
@"ERROR External navigation rejected - <allow-intent> not set for url='%@'"
;
NSString
*
allowNavigations_whitelistRejectionFormatString
=
@"ERROR Internal navigation rejected - <allow-navigation> not set for url='%@'"
;
NSURL
*
url
=
[
request
URL
];
switch
(
filterValue
)
{
case
CDVIntentAndNavigationFilterValueNavigationAllowed
:
return
YES
;
case
CDVIntentAndNavigationFilterValueIntentAllowed
:
// only allow-intent if it's a UIWebViewNavigationTypeLinkClicked (anchor tag) OR
// it's a UIWebViewNavigationTypeOther, and it's an internal link
if
([[
self
class
]
shouldOpenURLRequest
:
request
navigationType
:
navigationType
]){
[[
UIApplication
sharedApplication
]
openURL
:
url
options
:
@
{}
completionHandler
:
nil
];
}
// consume the request (i.e. no error) if it wasn't handled above
return
NO
;
case
CDVIntentAndNavigationFilterValueNoneAllowed
:
// allow-navigation attempt failed for sure
NSLog
(
@"%@"
,
[
NSString
stringWithFormat
:
allowNavigations_whitelistRejectionFormatString
,
[
url
absoluteString
]]);
// anchor tag link means it was an allow-intent attempt that failed as well
if
(
UIWebViewNavigationTypeLinkClicked
==
navigationType
)
{
NSLog
(
@"%@"
,
[
NSString
stringWithFormat
:
allowIntents_whitelistRejectionFormatString
,
[
url
absoluteString
]]);
}
return
NO
;
}
}
-
(
BOOL
)
shouldOverrideLoadWithRequest
:
(
NSURLRequest
*
)
request
navigationType
:
(
UIWebViewNavigationType
)
navigationType
{
return
[[
self
class
]
shouldOverrideLoadWithRequest
:
request
navigationType
:
navigationType
filterValue
:[
self
filterUrl
:
request
.
URL
]];
}
@end
YHExplorer/CordovaLib/config.xml
View file @
e370ccf
...
...
@@ -32,19 +32,6 @@
<content
src=
"index.html"
/>
<!-- Whitelist docs: https://github.com/apache/cordova-plugin-whitelist -->
<access
origin=
"*"
/>
<allow-intent
href=
"tel:*"
/>
<allow-intent
href=
"sms:*"
/>
<allow-intent
href=
"mailto:*"
/>
<allow-intent
href=
"geo:*"
/>
<allow-intent
href=
"itms:*"
/>
<!-- <allow-intent href="itms-apps:*" />-->
<allow-navigation
href=
"http://*/*"
/>
<allow-navigation
href=
"https://*/*"
/>
<allow-navigation
href=
"yohobuy://*/*"
/>
<!-- Preferences for iOS -->
<preference
name=
"AllowInlineMediaPlayback"
value=
"false"
/>
<preference
name=
"BackupWebStorage"
value=
"local"
/>
...
...
@@ -71,10 +58,6 @@
<param
name=
"ios-package"
value=
"CDVHandleOpenURL"
/>
<param
name=
"onload"
value=
"true"
/>
</feature>
<feature
name=
"IntentAndNavigationFilter"
>
<param
name=
"ios-package"
value=
"CDVIntentAndNavigationFilter"
/>
<param
name=
"onload"
value=
"true"
/>
</feature>
<feature
name=
"GestureHandler"
>
<param
name=
"ios-package"
value=
"CDVGestureHandler"
/>
<param
name=
"onload"
value=
"true"
/>
...
...
YHExplorer/YHPlugins/CDVYHInterface.m
View file @
e370ccf
...
...
@@ -97,6 +97,7 @@
NSString
*
urlString
=
request
.
URL
.
absoluteString
;
switch
(
navigationType
)
{
case
UIWebViewNavigationTypeLinkClicked
:
case
UIWebViewNavigationTypeOther
:
{
// 先检查是否遵循CDVYHInterfaceDelegate
id
<
CDVYHInterfaceDelegate
>
yhif
=
nil
;
...
...
@@ -111,7 +112,6 @@
// case UIWebViewNavigationTypeBackForward:
// case UIWebViewNavigationTypeReload:
// case UIWebViewNavigationTypeFormResubmitted:
// case UIWebViewNavigationTypeOther:
default:
break
;
}
...
...
Please
register
or
login
to post a comment