Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: content/browser/browser_url_handler.h

Issue 7464009: Removal of Profile from content part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: works now Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // We handle some special browser-level URLs (like "about:version") 5 // We handle some special browser-level URLs (like "about:version")
6 // before they're handed to a renderer. This lets us do the URL handling 6 // before they're handed to a renderer. This lets us do the URL handling
7 // on the browser side (which has access to more information than the 7 // on the browser side (which has access to more information than the
8 // renderers do) as well as sidestep the risk of exposing data to 8 // renderers do) as well as sidestep the risk of exposing data to
9 // random web pages (because from the resource loader's perspective, these 9 // random web pages (because from the resource loader's perspective, these
10 // URL schemes don't exist). 10 // URL schemes don't exist).
11 11
12 #ifndef CONTENT_BROWSER_BROWSER_URL_HANDLER_H_ 12 #ifndef CONTENT_BROWSER_BROWSER_URL_HANDLER_H_
13 #define CONTENT_BROWSER_BROWSER_URL_HANDLER_H_ 13 #define CONTENT_BROWSER_BROWSER_URL_HANDLER_H_
14 #pragma once 14 #pragma once
15 15
16 #include <vector> 16 #include <vector>
17 #include <utility> 17 #include <utility>
18 18
19 #include "base/gtest_prod_util.h" 19 #include "base/gtest_prod_util.h"
20 #include "base/memory/singleton.h" 20 #include "base/memory/singleton.h"
21 21
22 class GURL; 22 class GURL;
23 class Profile; 23
24 namespace content {
25 class BrowserContext;
26 }
24 27
25 // BrowserURLHandler manages the list of all special URLs and manages 28 // BrowserURLHandler manages the list of all special URLs and manages
26 // dispatching the URL handling to registered handlers. 29 // dispatching the URL handling to registered handlers.
27 class BrowserURLHandler { 30 class BrowserURLHandler {
28 public: 31 public:
29 // The type of functions that can process a URL. 32 // The type of functions that can process a URL.
30 // If a handler handles |url|, it should : 33 // If a handler handles |url|, it should :
31 // - optionally modify |url| to the URL that should be sent to the renderer 34 // - optionally modify |url| to the URL that should be sent to the renderer
32 // If the URL is not handled by a handler, it should return false. 35 // If the URL is not handled by a handler, it should return false.
33 typedef bool (*URLHandler)(GURL* url, Profile* profile); 36 typedef bool (*URLHandler)(GURL* url, content::BrowserContext* context);
jam 2011/07/21 16:41:54 nit: i think we should differentiate BrowserContex
34 37
35 // Returns the singleton instance. 38 // Returns the singleton instance.
36 static BrowserURLHandler* GetInstance(); 39 static BrowserURLHandler* GetInstance();
37 40
38 // RewriteURLIfNecessary gives all registered URLHandlers a shot at processing 41 // RewriteURLIfNecessary gives all registered URLHandlers a shot at processing
39 // the given URL, and modifies it in place. 42 // the given URL, and modifies it in place.
40 // If the original URL needs to be adjusted if the modified URL is redirected, 43 // If the original URL needs to be adjusted if the modified URL is redirected,
41 // this function sets |reverse_on_redirect| to true. 44 // this function sets |reverse_on_redirect| to true.
42 void RewriteURLIfNecessary(GURL* url, Profile* profile, 45 void RewriteURLIfNecessary(GURL* url, content::BrowserContext* context,
43 bool* reverse_on_redirect); 46 bool* reverse_on_redirect);
44 47
45 // Reverses the rewriting that was done for |original| using the new |url|. 48 // Reverses the rewriting that was done for |original| using the new |url|.
46 bool ReverseURLRewrite(GURL* url, const GURL& original, 49 bool ReverseURLRewrite(GURL* url, const GURL& original,
47 Profile* profile); 50 content::BrowserContext* context);
48 51
49 // Add the specified handler pair to the list of URL handlers. 52 // Add the specified handler pair to the list of URL handlers.
50 void AddHandlerPair(URLHandler handler, URLHandler reverse_handler); 53 void AddHandlerPair(URLHandler handler, URLHandler reverse_handler);
51 54
52 // Returns the null handler for use with |AddHandlerPair()|. 55 // Returns the null handler for use with |AddHandlerPair()|.
53 static URLHandler null_handler(); 56 static URLHandler null_handler();
54 57
55 private: 58 private:
56 // This object is a singleton: 59 // This object is a singleton:
57 BrowserURLHandler(); 60 BrowserURLHandler();
58 ~BrowserURLHandler(); 61 ~BrowserURLHandler();
59 friend struct DefaultSingletonTraits<BrowserURLHandler>; 62 friend struct DefaultSingletonTraits<BrowserURLHandler>;
60 63
61 // The list of known URLHandlers, optionally with reverse-rewriters. 64 // The list of known URLHandlers, optionally with reverse-rewriters.
62 typedef std::pair<URLHandler, URLHandler> HandlerPair; 65 typedef std::pair<URLHandler, URLHandler> HandlerPair;
63 std::vector<HandlerPair> url_handlers_; 66 std::vector<HandlerPair> url_handlers_;
64 67
65 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerTest, BasicRewriteAndReverse); 68 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerTest, BasicRewriteAndReverse);
66 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerTest, NullHandlerReverse); 69 FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerTest, NullHandlerReverse);
67 70
68 DISALLOW_COPY_AND_ASSIGN(BrowserURLHandler); 71 DISALLOW_COPY_AND_ASSIGN(BrowserURLHandler);
69 }; 72 };
70 73
71 #endif // CONTENT_BROWSER_BROWSER_URL_HANDLER_H_ 74 #endif // CONTENT_BROWSER_BROWSER_URL_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698