Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome_elf / blacklist / blacklist.cc
index 4026a0a..824a9e9 100644 (file)
@@ -29,6 +29,8 @@ namespace blacklist{
 // For more information about how this list is generated, and how to get off
 // of it, see:
 // https://sites.google.com/a/chromium.org/dev/Home/third-party-developers
+// NOTE: Please remember to update the DllHash enum in histograms.xml when
+//       adding a new value to the blacklist.
 const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount] = {
   L"activedetect32.dll",                // Lenovo One Key Theater.
                                         // See crbug.com/379218.
@@ -228,6 +230,14 @@ bool IsBlacklistInitialized() {
   return g_blacklist_initialized;
 }
 
+int GetBlacklistIndex(const wchar_t* dll_name) {
+  for (int i = 0; i < kTroublesomeDllsMaxCount, g_troublesome_dlls[i]; ++i) {
+    if (_wcsicmp(dll_name, g_troublesome_dlls[i]) == 0)
+      return i;
+  }
+  return -1;
+}
+
 bool AddDllToBlacklist(const wchar_t* dll_name) {
   int blacklist_size = BlacklistSize();
   // We need to leave one space at the end for the null pointer.
@@ -392,7 +402,7 @@ bool Initialize(bool force) {
   return NT_SUCCESS(ret) && page_executable;
 }
 
-bool AddDllsFromRegistryToBlacklist() {
+void AddDllsFromRegistryToBlacklist() {
   HKEY key = NULL;
   LONG result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
                                kRegistryFinchListPath,
@@ -401,9 +411,9 @@ bool AddDllsFromRegistryToBlacklist() {
                                &key);
 
   if (result != ERROR_SUCCESS)
-    return false;
+    return;
 
-  // We add dlls from the registry to the blacklist, and then clear registry.
+  // We add dlls from the registry to the blacklist.
   DWORD value_len;
   DWORD name_len = MAX_PATH;
   std::vector<wchar_t> name_buffer(name_len);
@@ -412,24 +422,23 @@ bool AddDllsFromRegistryToBlacklist() {
     value_len = 0;
     result = ::RegEnumValue(
         key, i, &name_buffer[0], &name_len, NULL, NULL, NULL, &value_len);
+    if (result != ERROR_SUCCESS)
+      break;
+
     name_len = name_len + 1;
     value_len = value_len + 1;
     std::vector<wchar_t> value_buffer(value_len);
     result = ::RegEnumValue(key, i, &name_buffer[0], &name_len, NULL, NULL,
                             reinterpret_cast<BYTE*>(&value_buffer[0]),
                             &value_len);
+    if (result != ERROR_SUCCESS)
+      break;
     value_buffer[value_len - 1] = L'\0';
-
-    if (result == ERROR_SUCCESS) {
-      AddDllToBlacklist(&value_buffer[0]);
-    }
+    AddDllToBlacklist(&value_buffer[0]);
   }
 
-  // Delete the finch registry key to clear the values.
-  result = ::RegDeleteKey(key, L"");
-
   ::RegCloseKey(key);
-  return result == ERROR_SUCCESS;
+  return;
 }
 
 }  // namespace blacklist