summaryrefslogtreecommitdiffstats
path: root/content/browser/browser_url_handler_impl.h
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-12 19:07:31 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-12 19:07:31 +0000
commit825b16687e0de3ef4ec3b7dd60fc1dfb237947c9 (patch)
tree8831f3f038a28b69c8dd976a7381aa66c1406ff4 /content/browser/browser_url_handler_impl.h
parenta60de956ec71ec185684f6d6167d5c8547f3639f (diff)
downloadchromium_src-825b16687e0de3ef4ec3b7dd60fc1dfb237947c9.zip
chromium_src-825b16687e0de3ef4ec3b7dd60fc1dfb237947c9.tar.gz
chromium_src-825b16687e0de3ef4ec3b7dd60fc1dfb237947c9.tar.bz2
Add a Content API around BrowserURLHandler.
BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9688019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/browser_url_handler_impl.h')
-rw-r--r--content/browser/browser_url_handler_impl.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/content/browser/browser_url_handler_impl.h b/content/browser/browser_url_handler_impl.h
new file mode 100644
index 0000000..d6136a6
--- /dev/null
+++ b/content/browser/browser_url_handler_impl.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_
+#define CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_
+#pragma once
+
+#include <vector>
+#include <utility>
+
+#include "base/gtest_prod_util.h"
+#include "base/memory/singleton.h"
+#include "content/public/browser/browser_url_handler.h"
+
+class GURL;
+
+namespace content {
+class BrowserContext;
+}
+
+class CONTENT_EXPORT BrowserURLHandlerImpl : public content::BrowserURLHandler {
+ public:
+ // Returns the singleton instance.
+ static BrowserURLHandlerImpl* GetInstance();
+
+ // BrowserURLHandler implementation:
+ virtual void RewriteURLIfNecessary(GURL* url,
+ content::BrowserContext* browser_context,
+ bool* reverse_on_redirect) OVERRIDE;
+ // Add the specified handler pair to the list of URL handlers.
+ virtual void AddHandlerPair(URLHandler handler,
+ URLHandler reverse_handler) OVERRIDE;
+
+ // Reverses the rewriting that was done for |original| using the new |url|.
+ bool ReverseURLRewrite(GURL* url, const GURL& original,
+ content::BrowserContext* browser_context);
+
+ private:
+ // This object is a singleton:
+ BrowserURLHandlerImpl();
+ virtual ~BrowserURLHandlerImpl();
+ friend struct DefaultSingletonTraits<BrowserURLHandlerImpl>;
+
+ // The list of known URLHandlers, optionally with reverse-rewriters.
+ typedef std::pair<URLHandler, URLHandler> HandlerPair;
+ std::vector<HandlerPair> url_handlers_;
+
+ FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, BasicRewriteAndReverse);
+ FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, NullHandlerReverse);
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserURLHandlerImpl);
+};
+
+#endif // CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_