1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IOS_WEB_NET_CRW_URL_VERIFYING_PROTOCOL_HANDLER_H_
6 #define IOS_WEB_NET_CRW_URL_VERIFYING_PROTOCOL_HANDLER_H_
8 #import <UIKit/UIKit.h>
10 #include "ios/web/public/web_state/url_verification_constants.h"
16 // The URL used for verification. Requests to this URL must not be blocked (by
17 // Content Security Policy for example).
18 extern const char kURLForVerification
[];
22 // Protocol handler used to verify that a site is not trying to spoof its URL.
23 // This handler will handle a specific URL, and use [NSURLRequest
24 // mainDocumentURL] on this request to check that the url returned by
25 // window.location.href has the same origin as the URL that webkit knows about.
26 @interface CRWURLVerifyingProtocolHandler
: NSURLProtocol
28 // Returns the URL of the given UIWebView. Moreover, this method will set the
29 // trustLevel enum to the appropriate level from a security point of view. This
30 // method will execute JavaScript on the UIWebView and must not be called from
31 // inside a javascript execution context.
32 + (GURL
)currentURLForWebView
:(UIWebView
*)webView
33 trustLevel
:(web::URLVerificationTrustLevel
*)trustLevel
;
35 // Class initialization function that should be called as early as possible to
36 // initialize and thus reduce overhead when this class is first called.
37 // Returns YES if initialization completed.
38 + (BOOL
)preInitialize
;
42 #endif // IOS_WEB_NET_CRW_URL_VERIFYING_PROTOCOL_HANDLER_H_