| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_COMMON_MANIFEST_HANDLERS_WEBVIEW_INFO_H_ | 5 #ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_WEBVIEW_INFO_H_ |
| 6 #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_WEBVIEW_INFO_H_ | 6 #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_WEBVIEW_INFO_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 #include "extensions/common/manifest_handler.h" | 12 #include "extensions/common/manifest_handler.h" |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 | 15 |
| 16 class PartitionItem; | 16 class PartitionItem; |
| 17 | 17 |
| 18 // A class to hold the <webview> accessible extension resources | 18 // A class to hold the <webview> accessible extension resources |
| 19 // that may be specified in the manifest of an extension using the | 19 // that may be specified in the manifest of an extension using the |
| 20 // "webview" key. | 20 // "webview" key. |
| 21 class WebviewInfo : public Extension::ManifestData { | 21 class WebviewInfo : public Extension::ManifestData { |
| 22 public: | 22 public: |
| 23 // Returns true if |extension|'s resource at |relative_path| is accessible |
| 24 // from the WebView partition with ID |partition_id|. |
| 25 static bool IsResourceWebviewAccessible(const Extension* extension, |
| 26 const std::string& partition_id, |
| 27 const std::string& relative_path); |
| 28 |
| 23 // Define out of line constructor/destructor to please Clang. | 29 // Define out of line constructor/destructor to please Clang. |
| 24 WebviewInfo(const std::string& extension_id); | 30 WebviewInfo(const std::string& extension_id); |
| 25 ~WebviewInfo() override; | 31 ~WebviewInfo() override; |
| 26 | 32 |
| 27 // Returns true if the specified resource is web accessible and the extension | |
| 28 // matches the manifest's extension. | |
| 29 bool IsResourceWebviewAccessible(const Extension* extension, | |
| 30 const std::string& partition_id, | |
| 31 const std::string& relative_path) const; | |
| 32 | |
| 33 void AddPartitionItem(scoped_ptr<PartitionItem> item); | 33 void AddPartitionItem(scoped_ptr<PartitionItem> item); |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 std::string extension_id_; | 36 std::string extension_id_; |
| 37 ScopedVector<PartitionItem> partition_items_; | 37 ScopedVector<PartitionItem> partition_items_; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Parses the "webview" manifest key. | 40 // Parses the "webview" manifest key. |
| 41 class WebviewHandler : public ManifestHandler { | 41 class WebviewHandler : public ManifestHandler { |
| 42 public: | 42 public: |
| 43 WebviewHandler(); | 43 WebviewHandler(); |
| 44 ~WebviewHandler() override; | 44 ~WebviewHandler() override; |
| 45 | 45 |
| 46 bool Parse(Extension* extension, base::string16* error) override; | 46 bool Parse(Extension* extension, base::string16* error) override; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 const std::vector<std::string> Keys() const override; | 49 const std::vector<std::string> Keys() const override; |
| 50 | 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(WebviewHandler); | 51 DISALLOW_COPY_AND_ASSIGN(WebviewHandler); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 } // namespace extensions | 54 } // namespace extensions |
| 55 | 55 |
| 56 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_WEBVIEW_INFO_H_ | 56 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_WEBVIEW_INFO_H_ |
| OLD | NEW |