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 CHROME_RENDERER_EXTENSIONS_RESOURCE_REQUEST_POLICY_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_RESOURCE_REQUEST_POLICY_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_RESOURCE_REQUEST_POLICY_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_RESOURCE_REQUEST_POLICY_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "ui/base/page_transition_types.h" | 9 #include "ui/base/page_transition_types.h" |
10 | 10 |
11 class GURL; | 11 class GURL; |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 class WebFrame; | 14 class WebFrame; |
15 class WebURL; | |
16 } | 15 } |
17 | 16 |
18 namespace extensions { | 17 namespace extensions { |
19 | 18 |
20 class Dispatcher; | 19 class Dispatcher; |
21 | 20 |
22 // Encapsulates the policy for when chrome-extension:// and | 21 // Encapsulates the policy for when chrome-extension:// URLs can be requested. |
23 // chrome-extension-resource:// URLs can be requested. | |
24 class ResourceRequestPolicy { | 22 class ResourceRequestPolicy { |
25 public: | 23 public: |
26 explicit ResourceRequestPolicy(Dispatcher* dispatcher); | 24 explicit ResourceRequestPolicy(Dispatcher* dispatcher); |
27 | 25 |
28 // Returns true if the chrome-extension:// |resource_url| can be requested | 26 // Returns true if the chrome-extension:// |resource_url| can be requested |
29 // from |frame_url|. In some cases this decision is made based upon how | 27 // from |frame_url|. In some cases this decision is made based upon how |
30 // this request was generated. Web triggered transitions are more restrictive | 28 // this request was generated. Web triggered transitions are more restrictive |
31 // than those triggered through UI. | 29 // than those triggered through UI. |
32 bool CanRequestResource(const GURL& resource_url, | 30 bool CanRequestResource(const GURL& resource_url, |
33 blink::WebFrame* frame, | 31 blink::WebFrame* frame, |
34 ui::PageTransition transition_type); | 32 ui::PageTransition transition_type); |
35 | 33 |
36 // Returns true if the chrome-extension-resource:// |resource_url| can be | |
37 // requested from |frame_url|. | |
38 bool CanRequestExtensionResourceScheme(const blink::WebURL& resource_url, | |
39 blink::WebFrame* frame); | |
40 | |
41 private: | 34 private: |
42 Dispatcher* dispatcher_; | 35 Dispatcher* dispatcher_; |
43 | 36 |
44 DISALLOW_COPY_AND_ASSIGN(ResourceRequestPolicy); | 37 DISALLOW_COPY_AND_ASSIGN(ResourceRequestPolicy); |
45 }; | 38 }; |
46 | 39 |
47 } // namespace extensions | 40 } // namespace extensions |
48 | 41 |
49 #endif // CHROME_RENDERER_EXTENSIONS_RESOURCE_REQUEST_POLICY_H_ | 42 #endif // CHROME_RENDERER_EXTENSIONS_RESOURCE_REQUEST_POLICY_H_ |
OLD | NEW |