Commit 9cef9b75 authored by Yi Su's avatar Yi Su Committed by Commit Bot

Remove CRWWebController.referrerFromNavigationAction.

This CL removes CRWWebController.referrerFromNavigationAction which is
not a very helpful method. The HTTP header constant "Referer" is moved
into wk_navigation_util.h/mm for possible reuse.

Bug: 956511
Change-Id: I8036c773c2dabde04282e93b34d97e89940ca191
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1599588
Commit-Queue: Yi Su <mrsuyi@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658991}
parent 5da1ab0b
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#ifndef IOS_WEB_NAVIGATION_WK_NAVIGATION_UTIL_H_ #ifndef IOS_WEB_NAVIGATION_WK_NAVIGATION_UTIL_H_
#define IOS_WEB_NAVIGATION_WK_NAVIGATION_UTIL_H_ #define IOS_WEB_NAVIGATION_WK_NAVIGATION_UTIL_H_
#import <Foundation/Foundation.h>
#include <memory> #include <memory>
#include <vector> #include <vector>
...@@ -39,6 +40,9 @@ extern const char kRestoreSessionSessionHashPrefix[]; ...@@ -39,6 +40,9 @@ extern const char kRestoreSessionSessionHashPrefix[];
// URL fragment prefix used to encode target URL in a restore_session.html URL. // URL fragment prefix used to encode target URL in a restore_session.html URL.
extern const char kRestoreSessionTargetUrlHashPrefix[]; extern const char kRestoreSessionTargetUrlHashPrefix[];
// The "Referer" [sic] HTTP header.
extern NSString* const kReferrerHeaderName;
// Returns true if |url| is a placeholder URL or restore_session.html URL. // Returns true if |url| is a placeholder URL or restore_session.html URL.
bool IsWKInternalUrl(const GURL& url); bool IsWKInternalUrl(const GURL& url);
......
...@@ -32,6 +32,7 @@ const int kMaxSessionSize = 75; ...@@ -32,6 +32,7 @@ const int kMaxSessionSize = 75;
const char kRestoreSessionSessionHashPrefix[] = "session="; const char kRestoreSessionSessionHashPrefix[] = "session=";
const char kRestoreSessionTargetUrlHashPrefix[] = "targetUrl="; const char kRestoreSessionTargetUrlHashPrefix[] = "targetUrl=";
const char kOriginalUrlKey[] = "for"; const char kOriginalUrlKey[] = "for";
NSString* const kReferrerHeaderName = @"Referer";
namespace { namespace {
// Returns begin and end iterators and an updated last committed index for the // Returns begin and end iterators and an updated last committed index for the
......
...@@ -136,6 +136,8 @@ using web::wk_navigation_util::CreatePlaceholderUrlForUrl; ...@@ -136,6 +136,8 @@ using web::wk_navigation_util::CreatePlaceholderUrlForUrl;
using web::wk_navigation_util::ExtractUrlFromPlaceholderUrl; using web::wk_navigation_util::ExtractUrlFromPlaceholderUrl;
using web::wk_navigation_util::IsRestoreSessionUrl; using web::wk_navigation_util::IsRestoreSessionUrl;
using web::wk_navigation_util::IsWKInternalUrl; using web::wk_navigation_util::IsWKInternalUrl;
using web::wk_navigation_util::kReferrerHeaderName;
using web::wk_navigation_util::URLNeedsUserAgentType;
namespace { namespace {
...@@ -163,8 +165,6 @@ NSString* const kFrameBecameAvailableMessageName = @"FrameBecameAvailable"; ...@@ -163,8 +165,6 @@ NSString* const kFrameBecameAvailableMessageName = @"FrameBecameAvailable";
// Message command sent when a frame is unloading. // Message command sent when a frame is unloading.
NSString* const kFrameBecameUnavailableMessageName = @"FrameBecameUnavailable"; NSString* const kFrameBecameUnavailableMessageName = @"FrameBecameUnavailable";
NSString* const kReferrerHeaderName = @"Referer"; // [sic]
// The duration of the period following a screen touch during which the user is // The duration of the period following a screen touch during which the user is
// still considered to be interacting with the page. // still considered to be interacting with the page.
const NSTimeInterval kMaximumDelayForUserInteractionInSeconds = 2; const NSTimeInterval kMaximumDelayForUserInteractionInSeconds = 2;
...@@ -410,9 +410,6 @@ bool RequiresContentFilterBlockingWorkaround() { ...@@ -410,9 +410,6 @@ bool RequiresContentFilterBlockingWorkaround() {
// unless the request was a POST. // unless the request was a POST.
@property(weak, nonatomic, readonly) NSDictionary* currentHTTPHeaders; @property(weak, nonatomic, readonly) NSDictionary* currentHTTPHeaders;
// Extracts "Referer" [sic] value from WKNavigationAction request header.
- (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action;
// Returns the current URL of the web view, and sets |trustLevel| accordingly // Returns the current URL of the web view, and sets |trustLevel| accordingly
// based on the confidence in the verification. // based on the confidence in the verification.
- (GURL)webURLWithTrustLevel:(web::URLVerificationTrustLevel*)trustLevel; - (GURL)webURLWithTrustLevel:(web::URLVerificationTrustLevel*)trustLevel;
...@@ -1273,7 +1270,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -1273,7 +1270,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
item->SetURL(URL); item->SetURL(URL);
navigationContext->SetMimeType(MIMEType); navigationContext->SetMimeType(MIMEType);
if (item->GetUserAgentType() == web::UserAgentType::NONE && if (item->GetUserAgentType() == web::UserAgentType::NONE &&
web::wk_navigation_util::URLNeedsUserAgentType(URL)) { URLNeedsUserAgentType(URL)) {
item->SetUserAgentType(web::UserAgentType::MOBILE); item->SetUserAgentType(web::UserAgentType::MOBILE);
} }
...@@ -3862,7 +3859,8 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -3862,7 +3859,8 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
return nil; return nil;
} }
NSString* referrer = [self referrerFromNavigationAction:action]; NSString* referrer =
[action.request valueForHTTPHeaderField:kReferrerHeaderName];
GURL openerURL = GURL openerURL =
referrer.length ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL; referrer.length ? GURL(base::SysNSStringToUTF8(referrer)) : _documentURL;
...@@ -4432,7 +4430,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -4432,7 +4430,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
// performing characters escaping). // performing characters escaping).
web::NavigationItem* item = web::NavigationItem* item =
web::GetItemWithUniqueID(self.navigationManagerImpl, context); web::GetItemWithUniqueID(self.navigationManagerImpl, context);
if (!web::wk_navigation_util::IsWKInternalUrl(webViewURL)) { if (!IsWKInternalUrl(webViewURL)) {
if (item) { if (item) {
item->SetURL(webViewURL); item->SetURL(webViewURL);
} }
...@@ -5453,7 +5451,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -5453,7 +5451,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
self.navigationHandler.pendingNavigationInfo = self.navigationHandler.pendingNavigationInfo =
[[CRWPendingNavigationInfo alloc] init]; [[CRWPendingNavigationInfo alloc] init];
self.navigationHandler.pendingNavigationInfo.referrer = self.navigationHandler.pendingNavigationInfo.referrer =
[self referrerFromNavigationAction:action]; [action.request valueForHTTPHeaderField:kReferrerHeaderName];
self.navigationHandler.pendingNavigationInfo.navigationType = self.navigationHandler.pendingNavigationInfo.navigationType =
action.navigationType; action.navigationType;
self.navigationHandler.pendingNavigationInfo.HTTPMethod = self.navigationHandler.pendingNavigationInfo.HTTPMethod =
...@@ -5556,7 +5554,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -5556,7 +5554,7 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
// navigation. WKWebView allows multiple provisional navigations, while // navigation. WKWebView allows multiple provisional navigations, while
// Navigation Manager has only one pending navigation. // Navigation Manager has only one pending navigation.
if (item) { if (item) {
if (!web::wk_navigation_util::IsWKInternalUrl(URL)) { if (!IsWKInternalUrl(URL)) {
item->SetVirtualURL(URL); item->SetVirtualURL(URL);
item->SetURL(URL); item->SetURL(URL);
} }
...@@ -6098,8 +6096,4 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*); ...@@ -6098,8 +6096,4 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
_containerView = nil; _containerView = nil;
} }
- (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
}
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment