| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_ | 6 #define CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 13 #include "content/public/browser/browser_url_handler.h" | 13 #include "content/public/browser/browser_url_handler.h" |
| 14 | 14 |
| 15 class GURL; | 15 class GURL; |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 class BrowserContext; | 18 class BrowserContext; |
| 19 } | |
| 20 | 19 |
| 21 class CONTENT_EXPORT BrowserURLHandlerImpl : public content::BrowserURLHandler { | 20 class CONTENT_EXPORT BrowserURLHandlerImpl : public BrowserURLHandler { |
| 22 public: | 21 public: |
| 23 // Returns the singleton instance. | 22 // Returns the singleton instance. |
| 24 static BrowserURLHandlerImpl* GetInstance(); | 23 static BrowserURLHandlerImpl* GetInstance(); |
| 25 | 24 |
| 26 // BrowserURLHandler implementation: | 25 // BrowserURLHandler implementation: |
| 27 virtual void RewriteURLIfNecessary(GURL* url, | 26 virtual void RewriteURLIfNecessary(GURL* url, |
| 28 content::BrowserContext* browser_context, | 27 BrowserContext* browser_context, |
| 29 bool* reverse_on_redirect) OVERRIDE; | 28 bool* reverse_on_redirect) OVERRIDE; |
| 30 // Add the specified handler pair to the list of URL handlers. | 29 // Add the specified handler pair to the list of URL handlers. |
| 31 virtual void AddHandlerPair(URLHandler handler, | 30 virtual void AddHandlerPair(URLHandler handler, |
| 32 URLHandler reverse_handler) OVERRIDE; | 31 URLHandler reverse_handler) OVERRIDE; |
| 33 | 32 |
| 34 // Reverses the rewriting that was done for |original| using the new |url|. | 33 // Reverses the rewriting that was done for |original| using the new |url|. |
| 35 bool ReverseURLRewrite(GURL* url, const GURL& original, | 34 bool ReverseURLRewrite(GURL* url, const GURL& original, |
| 36 content::BrowserContext* browser_context); | 35 BrowserContext* browser_context); |
| 37 | 36 |
| 38 private: | 37 private: |
| 39 // This object is a singleton: | 38 // This object is a singleton: |
| 40 BrowserURLHandlerImpl(); | 39 BrowserURLHandlerImpl(); |
| 41 virtual ~BrowserURLHandlerImpl(); | 40 virtual ~BrowserURLHandlerImpl(); |
| 42 friend struct DefaultSingletonTraits<BrowserURLHandlerImpl>; | 41 friend struct DefaultSingletonTraits<BrowserURLHandlerImpl>; |
| 43 | 42 |
| 44 // The list of known URLHandlers, optionally with reverse-rewriters. | 43 // The list of known URLHandlers, optionally with reverse-rewriters. |
| 45 typedef std::pair<URLHandler, URLHandler> HandlerPair; | 44 typedef std::pair<URLHandler, URLHandler> HandlerPair; |
| 46 std::vector<HandlerPair> url_handlers_; | 45 std::vector<HandlerPair> url_handlers_; |
| 47 | 46 |
| 48 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, BasicRewriteAndReverse); | 47 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, BasicRewriteAndReverse); |
| 49 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, NullHandlerReverse); | 48 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, NullHandlerReverse); |
| 50 | 49 |
| 51 DISALLOW_COPY_AND_ASSIGN(BrowserURLHandlerImpl); | 50 DISALLOW_COPY_AND_ASSIGN(BrowserURLHandlerImpl); |
| 52 }; | 51 }; |
| 53 | 52 |
| 53 } // namespace content |
| 54 |
| 54 #endif // CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_ | 55 #endif // CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_ |
| OLD | NEW |