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_COMMON_EXTENSIONS_EXTENSION_SET_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ |
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ |
7 | 7 |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
17 | 17 |
| 18 namespace extensions { |
| 19 struct UrlHandlerInfo; |
| 20 }; |
| 21 |
18 class ExtensionURLInfo { | 22 class ExtensionURLInfo { |
19 public: | 23 public: |
20 // The extension system uses both a document's origin and its URL to | 24 // The extension system uses both a document's origin and its URL to |
21 // grant permissions. Ideally, we would use only the origin, but because | 25 // grant permissions. Ideally, we would use only the origin, but because |
22 // the web extent of a hosted app can be less than an entire origin, we | 26 // the web extent of a hosted app can be less than an entire origin, we |
23 // take the URL into account as well | 27 // take the URL into account as well |
24 ExtensionURLInfo(WebKit::WebSecurityOrigin origin, const GURL& url); | 28 ExtensionURLInfo(WebKit::WebSecurityOrigin origin, const GURL& url); |
25 | 29 |
26 // WARNING! Using this constructor can miss important security checks if | 30 // WARNING! Using this constructor can miss important security checks if |
27 // you're trying to find a running extension. For example, if the | 31 // you're trying to find a running extension. For example, if the |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 114 |
111 // Returns the hosted app whose web extent contains the URL. | 115 // Returns the hosted app whose web extent contains the URL. |
112 const extensions::Extension* GetHostedAppByURL( | 116 const extensions::Extension* GetHostedAppByURL( |
113 const ExtensionURLInfo& info) const; | 117 const ExtensionURLInfo& info) const; |
114 | 118 |
115 // Returns a hosted app that contains any URL that overlaps with the given | 119 // Returns a hosted app that contains any URL that overlaps with the given |
116 // extent, if one exists. | 120 // extent, if one exists. |
117 const extensions::Extension* GetHostedAppByOverlappingWebExtent( | 121 const extensions::Extension* GetHostedAppByOverlappingWebExtent( |
118 const extensions::URLPatternSet& extent) const; | 122 const extensions::URLPatternSet& extent) const; |
119 | 123 |
| 124 // Returns a platform app that's registered itself for handling of a URL |
| 125 // pattern that matches |url|. If none, returns NULL. |
| 126 const extensions::UrlHandlerInfo* |
| 127 GetHandlingAppForURL(const GURL& url) const; |
| 128 |
120 // Returns true if |new_url| is in the extent of the same extension as | 129 // Returns true if |new_url| is in the extent of the same extension as |
121 // |old_url|. Also returns true if neither URL is in an app. | 130 // |old_url|. Also returns true if neither URL is in an app. |
122 bool InSameExtent(const GURL& old_url, const GURL& new_url) const; | 131 bool InSameExtent(const GURL& old_url, const GURL& new_url) const; |
123 | 132 |
124 // Look up an Extension object by id. | 133 // Look up an Extension object by id. |
125 const extensions::Extension* GetByID(const std::string& id) const; | 134 const extensions::Extension* GetByID(const std::string& id) const; |
126 | 135 |
127 // Gets the IDs of all extensions in the set. | 136 // Gets the IDs of all extensions in the set. |
128 std::set<std::string> GetIDs() const; | 137 std::set<std::string> GetIDs() const; |
129 | 138 |
130 // Returns true if |info| should get extension api bindings and be permitted | 139 // Returns true if |info| should get extension api bindings and be permitted |
131 // to make api calls. Note that this is independent of what extension | 140 // to make api calls. Note that this is independent of what extension |
132 // permissions the given extension has been granted. | 141 // permissions the given extension has been granted. |
133 bool ExtensionBindingsAllowed(const ExtensionURLInfo& info) const; | 142 bool ExtensionBindingsAllowed(const ExtensionURLInfo& info) const; |
134 | 143 |
135 // Returns true if |info| is an extension page that is to be served in a | 144 // Returns true if |info| is an extension page that is to be served in a |
136 // unique sandboxed origin. | 145 // unique sandboxed origin. |
137 bool IsSandboxedPage(const ExtensionURLInfo& info) const; | 146 bool IsSandboxedPage(const ExtensionURLInfo& info) const; |
138 | 147 |
139 private: | 148 private: |
140 FRIEND_TEST_ALL_PREFIXES(ExtensionSetTest, ExtensionSet); | 149 FRIEND_TEST_ALL_PREFIXES(ExtensionSetTest, ExtensionSet); |
141 | 150 |
142 ExtensionMap extensions_; | 151 ExtensionMap extensions_; |
143 | 152 |
144 DISALLOW_COPY_AND_ASSIGN(ExtensionSet); | 153 DISALLOW_COPY_AND_ASSIGN(ExtensionSet); |
145 }; | 154 }; |
146 | 155 |
147 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ | 156 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_SET_H_ |
OLD | NEW |