Upstream version 11.39.250.0
[platform/framework/web/crosswalk.git] / src / extensions / browser / computed_hashes.cc
index 19c8337..473ee3c 100644 (file)
@@ -5,8 +5,8 @@
 #include "extensions/browser/computed_hashes.h"
 
 #include "base/base64.h"
-#include "base/file_util.h"
 #include "base/files/file_path.h"
+#include "base/files/file_util.h"
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
 #include "base/stl_util.h"
@@ -101,8 +101,23 @@ bool ComputedHashes::Reader::GetHashes(const base::FilePath& relative_path,
                                        std::vector<std::string>* hashes) {
   base::FilePath path = relative_path.NormalizePathSeparatorsTo('/');
   std::map<base::FilePath, HashInfo>::iterator i = data_.find(path);
-  if (i == data_.end())
-    return false;
+  if (i == data_.end()) {
+    // If we didn't find the entry using exact match, it's possible the
+    // developer is using a path with some letters in the incorrect case, which
+    // happens to work on windows/osx. So try doing a linear scan to look for a
+    // case-insensitive match. In practice most extensions don't have that big
+    // a list of files so the performance penalty is probably not too big
+    // here. Also for crbug.com/29941 we plan to start warning developers when
+    // they are making this mistake, since their extension will be broken on
+    // linux/chromeos.
+    for (i = data_.begin(); i != data_.end(); ++i) {
+      const base::FilePath& entry = i->first;
+      if (base::FilePath::CompareEqualIgnoreCase(entry.value(), path.value()))
+        break;
+    }
+    if (i == data_.end())
+      return false;
+  }
   HashInfo& info = i->second;
   *block_size = info.first;
   *hashes = info.second;