OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_RESOURCE_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_RESOURCE_H_ |
| 7 |
| 8 #include "base/file_path.h" |
| 9 |
| 10 // Represents a resource inside an extension. For example, an image, or a |
| 11 // JavaScript file. This is more complicated than just a simple FilePath |
| 12 // because extension resources can come from multiple physical file locations |
| 13 // depending on locale. |
| 14 class ExtensionResource { |
| 15 public: |
| 16 ExtensionResource(); |
| 17 |
| 18 ExtensionResource(const FilePath& extension_root, |
| 19 const FilePath& relative_path); |
| 20 |
| 21 // Returns actual path to the resource (default or locale specific). |
| 22 // *** MIGHT HIT FILESYSTEM. Do not call on UI thread! *** |
| 23 const FilePath& GetFilePath() const; |
| 24 |
| 25 // Getters |
| 26 const FilePath& extension_root() const { return extension_root_; } |
| 27 const FilePath& relative_path() const { return relative_path_; } |
| 28 |
| 29 // Unittest helpers. |
| 30 FilePath::StringType NormalizeSeperators(FilePath::StringType path) const; |
| 31 bool ComparePathWithDefault(const FilePath& path) const; |
| 32 |
| 33 private: |
| 34 // Returns normalized full path to the resource. |
| 35 // Resource doesn't have to exist. |
| 36 FilePath CombinePathsSafely(const FilePath& extension_root, |
| 37 const FilePath& relative_path) const; |
| 38 |
| 39 // Extension root. |
| 40 FilePath extension_root_; |
| 41 |
| 42 // Relative path to resource. |
| 43 FilePath relative_path_; |
| 44 |
| 45 // Full path to extension resource. Starts empty. |
| 46 mutable FilePath full_resource_path_; |
| 47 }; |
| 48 |
| 49 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_RESOURCE_H_ |
OLD | NEW |