Skip to content

Commit

Permalink
Merge branch 'main' into update/1579-phishing-controller-v6
Browse files Browse the repository at this point in the history
  • Loading branch information
tommasini authored Mar 5, 2024
2 parents 1138163 + e9f3351 commit 9c0de9f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .js.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ export MM_BLOCKAID_UI_ENABLED=""
export WATCHER_PORT=8081

# Environment: "production", "pre-release" or "local"
export METAMASK_ENVIRONMENT=""
export METAMASK_ENVIRONMENT="local"

# Build type: "main" or "flask"
export METAMASK_BUILD_TYPE=""
export METAMASK_BUILD_TYPE="main"

# Segment SDK proxy endpoint and write key
export SEGMENT_WRITE_KEY=""
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To learn how to develop MetaMask-compatible applications, visit our [Developer D

### Environment setup

Before running the app, make sure your development environment has all the required tools.
Before running the app, make sure your development environment has all the required tools. Several of these tools (ie Node and Ruby) may require specific versions in order to successfully build the app.

[Setup your development environment](./docs/readme/environment.md)

Expand Down Expand Up @@ -65,4 +65,4 @@ yarn start:ios
**Run on an Android device**
```bash
yarn start:android
```
```
56 changes: 40 additions & 16 deletions patches/react-native-webview+11.13.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ index 0000000..f4a6af9
+ }
+}
diff --git a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
index f743bbc..06d172f 100644
index f743bbc..b520532 100644
--- a/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
+++ b/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java
@@ -5,6 +5,7 @@ import android.annotation.TargetApi;
Expand Down Expand Up @@ -1022,7 +1022,31 @@ index f743bbc..06d172f 100644

@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
@@ -1402,6 +1756,15 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
@@ -1266,7 +1620,22 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
requestPermissions(Collections.singletonList(Manifest.permission.ACCESS_FINE_LOCATION));

} else {
- callback.invoke(origin, true, false);
+ String alertMessage = String.format("Allow this app to use your location?");
+ AlertDialog.Builder builder = new AlertDialog.Builder(this.mWebView.getContext());
+ builder.setMessage(alertMessage);
+ builder.setCancelable(false);
+ builder.setPositiveButton("Allow", (dialog, which) -> {
+ callback.invoke(origin, true, false);
+ });
+ builder.setNegativeButton("Don't allow", (dialog, which) -> {
+ callback.invoke(origin, false, false);
+ });
+ AlertDialog alertDialog = builder.create();
+ alertDialog.show();
+ //Delay making `allow` clickable for 500ms to avoid unwanted presses.
+ Button posButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
+ posButton.setEnabled(false);
+ this.runDelayed(() -> posButton.setEnabled(true), 500);
}
}

@@ -1402,6 +1771,15 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
}
}

Expand All @@ -1038,7 +1062,7 @@ index f743bbc..06d172f 100644
@Override
public void onHostPause() { }

@@ -1447,6 +1810,13 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
@@ -1447,6 +1825,13 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
protected boolean nestedScrollEnabled = false;
protected ProgressChangedFilter progressChangedFilter;

Expand All @@ -1052,7 +1076,7 @@ index f743bbc..06d172f 100644
/**
* WebView must be created with an context of the current activity
* <p>
@@ -1475,6 +1845,42 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
@@ -1475,6 +1860,42 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
this.nestedScrollEnabled = nestedScrollEnabled;
}

Expand Down Expand Up @@ -1095,7 +1119,7 @@ index f743bbc..06d172f 100644
@Override
public void onHostResume() {
// do nothing
@@ -1533,6 +1939,8 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
@@ -1533,6 +1954,8 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
}
}

Expand All @@ -1104,7 +1128,7 @@ index f743bbc..06d172f 100644
public @Nullable
RNCWebViewClient getRNCWebViewClient() {
return mRNCWebViewClient;
@@ -1609,8 +2017,8 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
@@ -1609,8 +2032,8 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {

public void callInjectedJavaScriptBeforeContentLoaded() {
if (getSettings().getJavaScriptEnabled() &&
Expand All @@ -1115,7 +1139,7 @@ index f743bbc..06d172f 100644
evaluateJavascriptWithFallback("(function() {\n" + injectedJSBeforeContentLoaded + ";\n})();");
}
}
@@ -1672,16 +2080,16 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
@@ -1672,16 +2095,16 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {

if (mOnScrollDispatchHelper.onScrollChanged(x, y)) {
ScrollEvent event = ScrollEvent.obtain(
Expand Down Expand Up @@ -1174,39 +1198,39 @@ diff --git a/node_modules/react-native-webview/apple/RNCWebView.m b/node_modules
index 28c078a..9bb5368 100644
--- a/node_modules/react-native-webview/apple/RNCWebView.m
+++ b/node_modules/react-native-webview/apple/RNCWebView.m
@@ -105,6 +105,7 @@ @implementation RNCWebView
@@ -105,6 +105,7 @@ static NSDictionary* customCertificatesForHost;
UIStatusBarStyle _savedStatusBarStyle;
#endif // !TARGET_OS_OSX
BOOL _savedStatusBarHidden;
+ BOOL _disablePromptDuringLoading; //Disables the display of prompts during site navigation/loading

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
UIScrollViewContentInsetAdjustmentBehavior _savedContentInsetAdjustmentBehavior;
@@ -139,6 +140,7 @@ - (instancetype)initWithFrame:(CGRect)frame
@@ -139,6 +140,7 @@ static NSDictionary* customCertificatesForHost;
_injectedJavaScriptForMainFrameOnly = YES;
_injectedJavaScriptBeforeContentLoaded = nil;
_injectedJavaScriptBeforeContentLoadedForMainFrameOnly = YES;
+ _disablePromptDuringLoading = YES;

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
_savedContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
@@ -417,6 +419,7 @@ -(void)keyboardDisplacementFix
@@ -417,6 +419,7 @@ static NSDictionary* customCertificatesForHost;
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
if ([keyPath isEqual:@"estimatedProgress"] && object == self.webView) {
if(_onLoadingProgress){
+ _disablePromptDuringLoading = YES;
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
[event addEntriesFromDictionary:@{@"progress":[NSNumber numberWithDouble:self.webView.estimatedProgress]}];
_onLoadingProgress(event);
@@ -492,6 +495,7 @@ - (void)userContentController:(WKUserContentController *)userContentController
@@ -492,6 +495,7 @@ static NSDictionary* customCertificatesForHost;
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
[event addEntriesFromDictionary: @{@"navigationType": message.body}];
_onLoadingFinish(event);
+ _disablePromptDuringLoading = NO;
}
} else if ([message.name isEqualToString:MessageHandlerName]) {
if (_onMessage) {
@@ -851,11 +855,13 @@ - (void) webView:(WKWebView *)webView
@@ -851,11 +855,13 @@ static NSDictionary* customCertificatesForHost;
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
{
#if !TARGET_OS_OSX
Expand All @@ -1225,7 +1249,7 @@ index 28c078a..9bb5368 100644
#else
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:message];
@@ -868,6 +874,51 @@ - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSStrin
@@ -868,6 +874,51 @@ static NSDictionary* customCertificatesForHost;
/**
* confirm
*/
Expand Down Expand Up @@ -1277,7 +1301,7 @@ index 28c078a..9bb5368 100644
- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL))completionHandler{
#if !TARGET_OS_OSX
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:message preferredStyle:UIAlertControllerStyleAlert];
@@ -894,44 +945,49 @@ - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSStr
@@ -894,44 +945,49 @@ static NSDictionary* customCertificatesForHost;
* prompt
*/
- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString *))completionHandler{
Expand Down Expand Up @@ -1362,15 +1386,15 @@ index 28c078a..9bb5368 100644
}

#if !TARGET_OS_OSX
@@ -1157,6 +1213,7 @@ - (void)webView:(WKWebView *)webView
@@ -1157,6 +1213,7 @@ static NSDictionary* customCertificatesForHost;
}

if (_onLoadingFinish) {
+ _disablePromptDuringLoading = NO;
_onLoadingFinish([self baseEvent]);
}
}
@@ -1446,3 +1503,4 @@ - (void)userContentController:(WKUserContentController *)userContentController d
@@ -1446,3 +1503,4 @@ static NSDictionary* customCertificatesForHost;
}

@end
Expand Down

0 comments on commit 9c0de9f

Please sign in to comment.