Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2669303004: Removed externalRequest code from CRWWebController. (Closed)
Patch Set: Merged Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index 7222d3dfc1cb51ceeef36b4df87f125ea28076dd..4ff41805a13fac82fb932b34223740306419660b 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -121,31 +121,6 @@ NSString* const kUserIsInteractingKey = @"userIsInteracting";
NSString* const kOriginURLKey = @"originURL";
NSString* const kLogJavaScript = @"LogJavascript";
-struct NewWindowInfo {
- GURL url;
- base::scoped_nsobject<NSString> window_name;
- web::ReferrerPolicy referrer_policy;
- bool user_is_interacting;
- NewWindowInfo(GURL url,
- NSString* window_name,
- web::ReferrerPolicy referrer_policy,
- bool user_is_interacting);
- ~NewWindowInfo();
-};
-
-NewWindowInfo::NewWindowInfo(GURL target_url,
- NSString* target_window_name,
- web::ReferrerPolicy target_referrer_policy,
- bool target_user_is_interacting)
- : url(target_url),
- window_name([target_window_name copy]),
- referrer_policy(target_referrer_policy),
- user_is_interacting(target_user_is_interacting) {
-}
-
-NewWindowInfo::~NewWindowInfo() {
-}
-
// Struct to capture data about a user interaction. Records the time of the
// interaction and the main document URL at that time.
struct UserInteractionEvent {
@@ -389,7 +364,6 @@ NSError* WKWebViewErrorWithSource(NSError* error, WKWebViewErrorSource source) {
// YES if the web process backing _wkWebView is believed to currently be dead.
BOOL _webProcessIsDead;
- std::unique_ptr<web::NewWindowInfo> _externalRequest;
// Object for loading POST requests with body.
base::scoped_nsobject<CRWJSPOSTRequestLoader> _POSTRequestLoader;
@@ -809,8 +783,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
// Returns YES if the popup should be blocked, NO otherwise.
- (BOOL)shouldBlockPopupWithURL:(const GURL&)popupURL
sourceURL:(const GURL&)sourceURL;
-// Tries to open a popup with the given new window information.
-- (void)openPopupWithInfo:(const web::NewWindowInfo&)windowInfo;
// Used in webView:didReceiveAuthenticationChallenge:completionHandler: to
// reply with NSURLSessionAuthChallengeDisposition and credentials.
@@ -890,9 +862,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
// Handles 'document.submit' message.
- (BOOL)handleDocumentSubmitMessage:(base::DictionaryValue*)message
context:(NSDictionary*)context;
-// Handles 'externalRequest' message.
-- (BOOL)handleExternalRequestMessage:(base::DictionaryValue*)message
- context:(NSDictionary*)context;
// Handles 'form.activity' message.
- (BOOL)handleFormActivityMessage:(base::DictionaryValue*)message
context:(NSDictionary*)context;
@@ -908,9 +877,6 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
// Handles 'navigator.credentials.notifyFailedSignIn' message.
- (BOOL)handleSignInFailedMessage:(base::DictionaryValue*)message
context:(NSDictionary*)context;
-// Handles 'resetExternalRequest' message.
-- (BOOL)handleResetExternalRequestMessage:(base::DictionaryValue*)message
- context:(NSDictionary*)context;
// Handles 'window.error' message.
- (BOOL)handleWindowErrorMessage:(base::DictionaryValue*)message
context:(NSDictionary*)context;
@@ -2533,8 +2499,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
@selector(handleDocumentFaviconsMessage:context:);
(*handlers)["document.submit"] =
@selector(handleDocumentSubmitMessage:context:);
- (*handlers)["externalRequest"] =
- @selector(handleExternalRequestMessage:context:);
(*handlers)["form.activity"] =
@selector(handleFormActivityMessage:context:);
(*handlers)["navigator.credentials.request"] =
@@ -2545,8 +2509,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
@selector(handleSignedOutMessage:context:);
(*handlers)["navigator.credentials.notifyFailedSignIn"] =
@selector(handleSignInFailedMessage:context:);
- (*handlers)["resetExternalRequest"] =
- @selector(handleResetExternalRequestMessage:context:);
(*handlers)["window.error"] = @selector(handleWindowErrorMessage:context:);
(*handlers)["window.hashchange"] =
@selector(handleWindowHashChangeMessage:context:);
@@ -2754,39 +2716,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
return YES;
}
-- (BOOL)handleExternalRequestMessage:(base::DictionaryValue*)message
- context:(NSDictionary*)context {
- std::string href;
- std::string target;
- std::string referrerPolicy;
- if (!message->GetString("href", &href)) {
- DLOG(WARNING) << "JS message parameter not found: href";
- return NO;
- }
- if (!message->GetString("target", &target)) {
- DLOG(WARNING) << "JS message parameter not found: target";
- return NO;
- }
- if (!message->GetString("referrerPolicy", &referrerPolicy)) {
- DLOG(WARNING) << "JS message parameter not found: referrerPolicy";
- return NO;
- }
- // Round-trip the href through NSURL; this URL will be compared as a
- // string against a UIWebView-provided NSURL later, and must match exactly
- // for the new window to trigger, so the escaping needs to be NSURL-style.
- // TODO(stuartmorgan): Comparing against a URL whose exact formatting we
- // don't control is fundamentally fragile; try to find another
- // way of handling this.
- DCHECK(context[web::kUserIsInteractingKey]);
- NSString* windowName =
- base::SysUTF8ToNSString(href + web::kWindowNameSeparator + target);
michaeldo 2017/02/07 17:55:30 It looks like web::kWindowNameSeparator can be del
Eugene But (OOO till 7-30) 2017/02/07 19:14:11 Good catch! Compiler did not catch this because co
- _externalRequest.reset(new web::NewWindowInfo(
- net::GURLWithNSURL(net::NSURLWithGURL(GURL(href))), windowName,
- web::ReferrerPolicyFromString(referrerPolicy),
- [context[web::kUserIsInteractingKey] boolValue]));
- return YES;
-}
-
- (BOOL)handleFormActivityMessage:(base::DictionaryValue*)message
context:(NSDictionary*)context {
std::string formName;
@@ -2901,12 +2830,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
return YES;
}
-- (BOOL)handleResetExternalRequestMessage:(base::DictionaryValue*)message
- context:(NSDictionary*)context {
- _externalRequest.reset();
- return YES;
-}
-
- (BOOL)handleWindowErrorMessage:(base::DictionaryValue*)message
context:(NSDictionary*)context {
std::string errorMessage;
@@ -3244,26 +3167,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
BOOL isNavigationTypeLinkActivated =
action.navigationType == WKNavigationTypeLinkActivated;
- // Check if the request should be delayed.
- if (_externalRequest && _externalRequest->url == requestURL) {
- // Links that can't be shown in a tab by Chrome but can be handled by
- // external apps (e.g. tel:, mailto:) are opened directly despite the target
- // attribute on the link. We don't open a new tab for them because Mobile
- // Safari doesn't do that (and sites are expecting us to do the same) and
- // also because there would be nothing shown in that new tab; it would
- // remain on about:blank (see crbug.com/240178)
- if ([CRWWebController webControllerCanShow:requestURL] ||
- ![_delegate openExternalURL:requestURL
- linkClicked:isNavigationTypeLinkActivated]) {
- web::NewWindowInfo windowInfo = *_externalRequest;
- dispatch_async(dispatch_get_main_queue(), ^{
- [self openPopupWithInfo:windowInfo];
- });
- }
- _externalRequest.reset();
- return NO;
- }
-
// Check if the link navigation leads to a launch of an external app.
// TODO(crbug.com/607780): Revise the logic of allowing external app launch
// and move it to externalAppLauncher.
@@ -3509,33 +3412,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
sourceURL:sourceURL];
}
-- (void)openPopupWithInfo:(const web::NewWindowInfo&)windowInfo {
- const GURL url(windowInfo.url);
- web::NavigationItem* item = [self currentNavItem];
- const GURL currentURL = item ? item->GetVirtualURL() : GURL::EmptyGURL();
- NSString* windowName = windowInfo.window_name.get();
- web::Referrer referrer(currentURL, windowInfo.referrer_policy);
- base::WeakNSObject<CRWWebController> weakSelf(self);
- void (^showPopupHandler)() = ^{
- CRWWebController* child = [[weakSelf delegate] webPageOrderedOpen:url
- referrer:referrer
- windowName:windowName
- inBackground:NO];
- DCHECK(!child || child.sessionController.openedByDOM);
- };
-
- BOOL showPopup = windowInfo.user_is_interacting ||
- (![self shouldBlockPopupWithURL:url sourceURL:currentURL]);
- if (showPopup) {
- showPopupHandler();
- } else if ([_delegate
- respondsToSelector:@selector(webController:didBlockPopup:)]) {
- web::BlockedPopupInfo blockedPopupInfo(url, referrer, windowName,
- showPopupHandler);
- [_delegate webController:self didBlockPopup:blockedPopupInfo];
- }
-}
-
#pragma mark -
#pragma mark Auth Challenge
@@ -5434,12 +5310,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
_loadPhase = web::LOAD_REQUESTED;
}
-- (NSString*)externalRequestWindowName {
- if (!_externalRequest || !_externalRequest->window_name)
- return @"";
- return _externalRequest->window_name;
-}
-
- (web::WebViewDocumentType)documentTypeFromMIMEType:(NSString*)MIMEType {
if (!MIMEType.length) {
return web::WEB_VIEW_DOCUMENT_TYPE_UNKNOWN;
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698