Advertisement
Guest User

micah

a guest
Nov 9th, 2009
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. ---
  2. browser/components/dirprovider/DirectoryProvider.cpp | 54 ++++++++++---------
  3. 1 file changed, 31 insertions(+), 23 deletions(-)
  4.  
  5. Index: mozilla/browser/components/dirprovider/DirectoryProvider.cpp
  6. ===================================================================
  7. --- mozilla.orig/browser/components/dirprovider/DirectoryProvider.cpp
  8. +++ mozilla/browser/components/dirprovider/DirectoryProvider.cpp
  9. @@ -30,16 +30,17 @@
  10. * use your version of this file under the terms of the MPL, indicate your
  11. * decision by deleting the provisions above and replace them with the notice
  12. * and other provisions required by the GPL or the LGPL. If you do not delete
  13. * the provisions above, a recipient may use your version of this file under
  14. * the terms of any one of the MPL, the GPL or the LGPL.
  15. *
  16. * ***** END LICENSE BLOCK ***** */
  17.  
  18. +#include "nsIChromeRegistry.h"
  19. #include "nsIDirectoryService.h"
  20. #include "DirectoryProvider.h"
  21.  
  22. #include "nsIFile.h"
  23. #include "nsISimpleEnumerator.h"
  24. #include "nsIPrefService.h"
  25. #include "nsIPrefBranch.h"
  26.  
  27. @@ -198,47 +199,51 @@
  28. if (NS_FAILED(rv) || !exists)
  29. return;
  30.  
  31. nsCOMPtr<nsIFile> commonPlugins;
  32. rv = searchPlugins->Clone(getter_AddRefs(commonPlugins));
  33. if (NS_SUCCEEDED(rv)) {
  34. commonPlugins->AppendNative(NS_LITERAL_CSTRING("common"));
  35. rv = commonPlugins->Exists(&exists);
  36. - if (NS_SUCCEEDED(rv) && exists)
  37. - array.AppendObject(commonPlugins);
  38. + if (NS_FAILED(rv) || !exists)
  39. + commonPlugins = nsnull;
  40. }
  41. + if (NS_FAILED(rv))
  42. + return;
  43.  
  44. - nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
  45. - if (prefs) {
  46. -
  47. - nsCOMPtr<nsIFile> localePlugins;
  48. - rv = searchPlugins->Clone(getter_AddRefs(localePlugins));
  49. - if (NS_FAILED(rv))
  50. - return;
  51. + nsCAutoString locale;
  52. + nsCOMPtr<nsIFile> localePlugins;
  53. + rv = searchPlugins->Clone(getter_AddRefs(localePlugins));
  54. + if (NS_FAILED(rv))
  55. + return;
  56.  
  57. - localePlugins->AppendNative(NS_LITERAL_CSTRING("locale"));
  58. + nsCOMPtr<nsIXULChromeRegistry> chromeReg =
  59. + do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
  60. + if (!chromeReg)
  61. + return;
  62.  
  63. - nsCString locale;
  64. - rv = prefs->GetCharPref("general.useragent.locale", getter_Copies(locale));
  65. + chromeReg->GetSelectedLocale(NS_LITERAL_CSTRING("global"), locale);
  66. + if (NS_SUCCEEDED(rv)) {
  67. + nsCOMPtr<nsIFile> curLocalePlugins;
  68. + rv = localePlugins->Clone(getter_AddRefs(curLocalePlugins));
  69. if (NS_SUCCEEDED(rv)) {
  70. -
  71. - nsCOMPtr<nsIFile> curLocalePlugins;
  72. - rv = localePlugins->Clone(getter_AddRefs(curLocalePlugins));
  73. - if (NS_SUCCEEDED(rv)) {
  74. -
  75. - curLocalePlugins->AppendNative(locale);
  76. - rv = curLocalePlugins->Exists(&exists);
  77. - if (NS_SUCCEEDED(rv) && exists) {
  78. - array.AppendObject(curLocalePlugins);
  79. - return; // all done
  80. - }
  81. + curLocalePlugins->AppendNative(locale);
  82. + rv = curLocalePlugins->Exists(&exists);
  83. + if (NS_SUCCEEDED(rv) && exists) {
  84. + array.AppendObject(curLocalePlugins);
  85. + if (commonPlugins)
  86. + array.AppendObject(commonPlugins);
  87. + return; // all done
  88. }
  89. }
  90. + }
  91.  
  92. + nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
  93. + if (prefs) {
  94. // we didn't append the locale dir - try the default one
  95. nsCString defLocale;
  96. rv = prefs->GetCharPref("distribution.searchplugins.defaultLocale",
  97. getter_Copies(defLocale));
  98. if (NS_SUCCEEDED(rv)) {
  99.  
  100. nsCOMPtr<nsIFile> defLocalePlugins;
  101. rv = localePlugins->Clone(getter_AddRefs(defLocalePlugins));
  102. @@ -246,16 +251,19 @@
  103.  
  104. defLocalePlugins->AppendNative(defLocale);
  105. rv = defLocalePlugins->Exists(&exists);
  106. if (NS_SUCCEEDED(rv) && exists)
  107. array.AppendObject(defLocalePlugins);
  108. }
  109. }
  110. }
  111. +
  112. + if (commonPlugins)
  113. + array.AppendObject(commonPlugins);
  114. }
  115.  
  116. NS_IMETHODIMP
  117. DirectoryProvider::GetFiles(const char *aKey, nsISimpleEnumerator* *aResult)
  118. {
  119. nsresult rv;
  120.  
  121. if (!strcmp(aKey, NS_APP_SEARCH_DIR_LIST)) {
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement