Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ios / web / public / browser_url_rewriter.h
blob4d38ad953ba0bfef0cd91b77dfa0c91cb4f9d9a1
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_
8 class GURL;
10 namespace web {
12 class BrowserState;
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 {
19 public:
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 // Gives every URLRewriter in |rewriters| a chance to process |url|, modifying
29 // it in place. Returns whether or not a URLRewriter returned |true|.
30 static bool RewriteURLWithWriters(
31 GURL* url,
32 BrowserState* browser_state,
33 const std::vector<BrowserURLRewriter::URLRewriter>& rewriters);
35 // Gives every URLRewriter added via |AddURLRewriter()| a chance to process
36 // |url|, modifying it in place. Returns whether or not a URLRewriter
37 // returned |true|.
38 virtual bool RewriteURLIfNecessary(GURL* url,
39 BrowserState* browser_state) = 0;
41 // Adds |rewriter| to the list of URL rewriters. |rewriter| must not be null.
42 virtual void AddURLRewriter(URLRewriter rewriter) = 0;
44 protected:
45 virtual ~BrowserURLRewriter() {}
48 } // namespace web
50 #endif // IOS_WEB_PUBLIC_BROWSER_URL_REWRITER_H_