1 // Copyright 2015 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_PUBLIC_BROWSER_URL_REWRITER_H_
6 #define IOS_WEB_PUBLIC_BROWSER_URL_REWRITER_H_
14 // Some special browser-level URLs (like "about:version") are handled before
15 // actually being loaded by the web view, allowing the embedder to optionally
16 // convert them to app-specific URLs that to be handled using
17 // CRWNativeContentProviders.
18 class BrowserURLRewriter
{
20 // The type of functions that can process a URL. URLRewriters return true if
21 // |url| is ready to be loaded and added to the NavigationManager. They can
22 // optionally modify |url| regardless of whether they return true or false.
23 typedef bool (*URLRewriter
)(GURL
* url
, BrowserState
* browser_state
);
25 // Returns the singleton instance.
26 static BrowserURLRewriter
* GetInstance();
28 // RewriteURLIfNecessary gives all registered URLRewriters a shot at
29 // processing the given URL, and modifies it in place.
30 virtual void RewriteURLIfNecessary(GURL
* url
,
31 BrowserState
* browser_state
) = 0;
33 // Adds |rewriter| to the list of URL rewriters. |rewriter| must not be null.
34 virtual void AddURLRewriter(URLRewriter rewriter
) = 0;
37 virtual ~BrowserURLRewriter() {}
42 #endif // IOS_WEB_PUBLIC_BROWSER_URL_REWRITER_H_