Make crazy linker work in gn build
[chromium-blink-merge.git] / content / browser / browser_url_handler_impl.h
blob95dab97457335c1adc7f5228a32f71a3d4ff80c5
1 // Copyright (c) 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 CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_
6 #define CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_
8 #include <vector>
9 #include <utility>
11 #include "base/gtest_prod_util.h"
12 #include "base/memory/singleton.h"
13 #include "content/public/browser/browser_url_handler.h"
15 class GURL;
17 namespace content {
18 class BrowserContext;
20 class CONTENT_EXPORT BrowserURLHandlerImpl : public BrowserURLHandler {
21 public:
22 // Returns the singleton instance.
23 static BrowserURLHandlerImpl* GetInstance();
25 // BrowserURLHandler implementation:
26 virtual void RewriteURLIfNecessary(GURL* url,
27 BrowserContext* browser_context,
28 bool* reverse_on_redirect) override;
29 // Add the specified handler pair to the list of URL handlers.
30 virtual void AddHandlerPair(URLHandler handler,
31 URLHandler reverse_handler) override;
33 // Reverses the rewriting that was done for |original| using the new |url|.
34 bool ReverseURLRewrite(GURL* url, const GURL& original,
35 BrowserContext* browser_context);
37 private:
38 // This object is a singleton:
39 BrowserURLHandlerImpl();
40 virtual ~BrowserURLHandlerImpl();
41 friend struct DefaultSingletonTraits<BrowserURLHandlerImpl>;
43 // The list of known URLHandlers, optionally with reverse-rewriters.
44 typedef std::pair<URLHandler, URLHandler> HandlerPair;
45 std::vector<HandlerPair> url_handlers_;
47 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, BasicRewriteAndReverse);
48 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, NullHandlerReverse);
50 DISALLOW_COPY_AND_ASSIGN(BrowserURLHandlerImpl);
53 } // namespace content
55 #endif // CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_