blob: cad43f2ab325d7d76de4d63289b0870dba68d341 [file] [log] [blame]
stuartmorganf7cf3d02015-05-04 17:27:351// 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.
4
5#ifndef IOS_WEB_BROWSER_URL_REWRITER_IMPL_H_
6#define IOS_WEB_BROWSER_URL_REWRITER_IMPL_H_
7
8#include <vector>
9
avi571943672015-12-22 02:12:4910#include "base/macros.h"
stuartmorganf7cf3d02015-05-04 17:27:3511#include "base/memory/singleton.h"
12#include "ios/web/public/browser_url_rewriter.h"
13
14class GURL;
15
16namespace web {
17
18// Concrete subclass of web::BrowserURLRewriter. Stores added URLRewriters in a
19// vector and performs URL rewrites if necessary.
20class BrowserURLRewriterImpl : public BrowserURLRewriter {
21 public:
22 // Returns the singleton instance.
23 static BrowserURLRewriterImpl* GetInstance();
24
25 // BrowserURLRewriter implementation:
26 bool RewriteURLIfNecessary(GURL* url, BrowserState* browser_state) override;
27 void AddURLRewriter(URLRewriter rewriter) override;
28
29 private:
30 // This object is a singleton:
31 BrowserURLRewriterImpl();
32 ~BrowserURLRewriterImpl() override;
olli.raula36aa8be2015-09-10 11:14:2233 friend struct base::DefaultSingletonTraits<BrowserURLRewriterImpl>;
stuartmorganf7cf3d02015-05-04 17:27:3534
35 // The list of known URLRewriters.
36 std::vector<URLRewriter> url_rewriters_;
37
38 DISALLOW_COPY_AND_ASSIGN(BrowserURLRewriterImpl);
39};
40
41} // namespace web
42
43#endif // IOS_WEB_BROWSER_URL_REWRITER_IMPL_H_