 Chromium Code Reviews
 Chromium Code Reviews Issue 337041:
  Fix bug where many extensions don't install due to sandbox.  (Closed)
    
  
    Issue 337041:
  Fix bug where many extensions don't install due to sandbox.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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/browser/extensions/extension_l10n_util.h" | 5 #include "chrome/common/extensions/extension_l10n_util.h" | 
| 6 | 6 | 
| 7 #include <set> | 7 #include <set> | 
| 8 #include <string> | 8 #include <string> | 
| 9 #include <vector> | 9 #include <vector> | 
| 10 | 10 | 
| 11 #include "app/l10n_util.h" | 11 #include "app/l10n_util.h" | 
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" | 
| 13 #include "base/linked_ptr.h" | 13 #include "base/linked_ptr.h" | 
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" | 
| 15 #include "base/values.h" | 15 #include "base/values.h" | 
| 16 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" | 
| 17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" | 
| 18 #include "chrome/common/extensions/extension_message_bundle.h" | 18 #include "chrome/common/extensions/extension_message_bundle.h" | 
| 19 #include "chrome/common/json_value_serializer.h" | 19 #include "chrome/common/json_value_serializer.h" | 
| 20 | 20 | 
| 21 namespace errors = extension_manifest_errors; | 21 namespace errors = extension_manifest_errors; | 
| 22 namespace keys = extension_manifest_keys; | 22 namespace keys = extension_manifest_keys; | 
| 23 | 23 | 
| 24 static std::string* GetProcessLocale() { | |
| 25 static std::string locale; | |
| 26 return &locale; | |
| 27 } | |
| 28 | |
| 24 namespace extension_l10n_util { | 29 namespace extension_l10n_util { | 
| 25 | 30 | 
| 31 void SetProcessLocale(const std::string& locale) { | |
| 32 *(GetProcessLocale()) = locale; | |
| 33 } | |
| 34 | |
| 26 std::string GetDefaultLocaleFromManifest(const DictionaryValue& manifest, | 35 std::string GetDefaultLocaleFromManifest(const DictionaryValue& manifest, | 
| 27 std::string* error) { | 36 std::string* error) { | 
| 28 std::string default_locale; | 37 std::string default_locale; | 
| 29 if (!manifest.GetString(keys::kDefaultLocale, &default_locale)) { | 38 if (!manifest.GetString(keys::kDefaultLocale, &default_locale)) { | 
| 30 *error = errors::kInvalidDefaultLocale; | 39 *error = errors::kInvalidDefaultLocale; | 
| 31 return ""; | 40 return ""; | 
| 32 } | 41 } | 
| 33 | 42 | 
| 34 return default_locale; | 43 return default_locale; | 
| 35 } | 44 } | 
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 } | 189 } | 
| 181 } | 190 } | 
| 182 | 191 | 
| 183 return ExtensionMessageBundle::Create(catalogs, error); | 192 return ExtensionMessageBundle::Create(catalogs, error); | 
| 184 } | 193 } | 
| 185 | 194 | 
| 186 void GetL10nRelativePaths(const FilePath& relative_resource_path, | 195 void GetL10nRelativePaths(const FilePath& relative_resource_path, | 
| 187 std::vector<FilePath>* l10n_paths) { | 196 std::vector<FilePath>* l10n_paths) { | 
| 188 DCHECK(NULL != l10n_paths); | 197 DCHECK(NULL != l10n_paths); | 
| 189 | 198 | 
| 199 std::string* current_locale = GetProcessLocale(); | |
| 200 if (current_locale->empty()) | |
| 201 *current_locale = l10n_util::GetApplicationLocale(L""); | |
| 
Nebojša Ćirić
2009/10/27 22:04:35
No big deal, but you could use
SetProcessLocale(l
 | |
| 202 | |
| 190 std::vector<std::string> locales; | 203 std::vector<std::string> locales; | 
| 191 static const std::string current_locale = | 204 GetParentLocales(*current_locale, &locales); | 
| 192 l10n_util::GetApplicationLocale(L""); | |
| 193 GetParentLocales(current_locale, &locales); | |
| 194 | 205 | 
| 195 FilePath locale_relative_path; | 206 FilePath locale_relative_path; | 
| 196 for (size_t i = 0; i < locales.size(); ++i) { | 207 for (size_t i = 0; i < locales.size(); ++i) { | 
| 197 l10n_paths->push_back(locale_relative_path | 208 l10n_paths->push_back(locale_relative_path | 
| 198 .AppendASCII(Extension::kLocaleFolder) | 209 .AppendASCII(Extension::kLocaleFolder) | 
| 199 .AppendASCII(locales[i]) | 210 .AppendASCII(locales[i]) | 
| 200 .Append(relative_resource_path)); | 211 .Append(relative_resource_path)); | 
| 201 } | 212 } | 
| 202 } | 213 } | 
| 203 | 214 | 
| 204 } // namespace extension_l10n_util | 215 } // namespace extension_l10n_util | 
| OLD | NEW |