blob: d0a150452ba6047b69c7f705793fde42bc2b73b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright (c) 2012 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_
#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 BrowserURLHandler {
public:
// Returns the singleton instance.
static BrowserURLHandlerImpl* GetInstance();
// BrowserURLHandler implementation:
virtual void RewriteURLIfNecessary(GURL* url,
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,
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);
};
} // namespace content
#endif // CONTENT_BROWSER_BROWSER_URL_HANDLER_IMPL_H_
|