| 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 <set> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "extensions/common/extension_id.h" |
| 9 #include "ui/base/page_transition_types.h" | 12 #include "ui/base/page_transition_types.h" |
| 10 | 13 |
| 11 class GURL; | 14 class GURL; |
| 12 | 15 |
| 13 namespace blink { | 16 namespace blink { |
| 14 class WebLocalFrame; | 17 class WebLocalFrame; |
| 15 } | 18 } |
| 16 | 19 |
| 17 namespace extensions { | 20 namespace extensions { |
| 18 | |
| 19 class Dispatcher; | 21 class Dispatcher; |
| 22 class Extension; |
| 20 | 23 |
| 21 // Encapsulates the policy for when chrome-extension:// URLs can be requested. | 24 // Encapsulates the policy for when chrome-extension:// URLs can be requested. |
| 22 class ResourceRequestPolicy { | 25 class ResourceRequestPolicy { |
| 23 public: | 26 public: |
| 24 explicit ResourceRequestPolicy(Dispatcher* dispatcher); | 27 explicit ResourceRequestPolicy(Dispatcher* dispatcher); |
| 28 ~ResourceRequestPolicy(); |
| 29 |
| 30 void OnExtensionAdded(const Extension& extension); |
| 31 void OnExtensionRemoved(const ExtensionId& extension); |
| 25 | 32 |
| 26 // Returns true if the chrome-extension:// |resource_url| can be requested | 33 // Returns true if the chrome-extension:// |resource_url| can be requested |
| 27 // from |frame_url|. In some cases this decision is made based upon how | 34 // from |frame_url|. In some cases this decision is made based upon how |
| 28 // this request was generated. Web triggered transitions are more restrictive | 35 // this request was generated. Web triggered transitions are more restrictive |
| 29 // than those triggered through UI. | 36 // than those triggered through UI. |
| 30 bool CanRequestResource(const GURL& resource_url, | 37 bool CanRequestResource(const GURL& resource_url, |
| 31 blink::WebLocalFrame* frame, | 38 blink::WebLocalFrame* frame, |
| 32 ui::PageTransition transition_type); | 39 ui::PageTransition transition_type); |
| 33 | 40 |
| 34 private: | 41 private: |
| 35 Dispatcher* dispatcher_; | 42 Dispatcher* dispatcher_; |
| 36 | 43 |
| 44 // The set of extension IDs with any potentially web- or webview-accessible |
| 45 // resources. |
| 46 std::set<ExtensionId> web_accessible_ids_; |
| 47 |
| 37 DISALLOW_COPY_AND_ASSIGN(ResourceRequestPolicy); | 48 DISALLOW_COPY_AND_ASSIGN(ResourceRequestPolicy); |
| 38 }; | 49 }; |
| 39 | 50 |
| 40 } // namespace extensions | 51 } // namespace extensions |
| 41 | 52 |
| 42 #endif // CHROME_RENDERER_EXTENSIONS_RESOURCE_REQUEST_POLICY_H_ | 53 #endif // CHROME_RENDERER_EXTENSIONS_RESOURCE_REQUEST_POLICY_H_ |
| OLD | NEW |