| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/common/extensions/extension_resource.h" | 5 #include "chrome/common/extensions/extension_resource.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 ExtensionResource::ExtensionResource() { | 10 ExtensionResource::ExtensionResource() { |
| 11 } | 11 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // TODO(mad): Fix this once AbsolutePath is unified. | 50 // TODO(mad): Fix this once AbsolutePath is unified. |
| 51 if (file_util::AbsolutePath(&full_path) && | 51 if (file_util::AbsolutePath(&full_path) && |
| 52 file_util::PathExists(full_path) && | 52 file_util::PathExists(full_path) && |
| 53 clean_extension_root.IsParent(full_path)) { | 53 clean_extension_root.IsParent(full_path)) { |
| 54 return full_path; | 54 return full_path; |
| 55 } | 55 } |
| 56 | 56 |
| 57 return FilePath(); | 57 return FilePath(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Unittesting helpers. | 60 // Unit-testing helpers. |
| 61 FilePath::StringType ExtensionResource::NormalizeSeperators( | 61 FilePath::StringType ExtensionResource::NormalizeSeperators( |
| 62 FilePath::StringType path) const { | 62 FilePath::StringType path) const { |
| 63 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 63 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
| 64 FilePath::StringType ret_val; | 64 FilePath::StringType ret_val; |
| 65 for (size_t i = 0; i < path.length(); i++) { | 65 for (size_t i = 0; i < path.length(); i++) { |
| 66 if (FilePath::IsSeparator(path[i])) | 66 if (FilePath::IsSeparator(path[i])) |
| 67 path[i] = FilePath::kSeparators[0]; | 67 path[i] = FilePath::kSeparators[0]; |
| 68 } | 68 } |
| 69 #endif // FILE_PATH_USES_WIN_SEPARATORS | 69 #endif // FILE_PATH_USES_WIN_SEPARATORS |
| 70 return path; | 70 return path; |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool ExtensionResource::ComparePathWithDefault(const FilePath& path) const { | 73 bool ExtensionResource::ComparePathWithDefault(const FilePath& path) const { |
| 74 // Make sure we have a cached value to test against... | 74 // Make sure we have a cached value to test against... |
| 75 if (full_resource_path_.empty()) | 75 if (full_resource_path_.empty()) |
| 76 GetFilePath(); | 76 GetFilePath(); |
| 77 if (NormalizeSeperators(path.value()) == | 77 if (NormalizeSeperators(path.value()) == |
| 78 NormalizeSeperators(full_resource_path_.value())) { | 78 NormalizeSeperators(full_resource_path_.value())) { |
| 79 return true; | 79 return true; |
| 80 } else { | 80 } else { |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 } | 83 } |
| OLD | NEW |