Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/common/extensions/extension_l10n_util.cc

Issue 19547009: Move ".crx"/".pem" constants and extension_filenames constants into extensions/common/constants.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_l10n_util.h" 5 #include "chrome/common/extensions/extension_l10n_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return true; 205 return true;
206 if (chrome_locales.find(locale_name) == chrome_locales.end()) { 206 if (chrome_locales.find(locale_name) == chrome_locales.end()) {
207 // Warn if there is an extension locale that's not in the Chrome list, 207 // Warn if there is an extension locale that's not in the Chrome list,
208 // but don't fail. 208 // but don't fail.
209 DLOG(WARNING) << base::StringPrintf("Supplied locale %s is not supported.", 209 DLOG(WARNING) << base::StringPrintf("Supplied locale %s is not supported.",
210 locale_name.c_str()); 210 locale_name.c_str());
211 return true; 211 return true;
212 } 212 }
213 // Check if messages file is actually present (but don't check content). 213 // Check if messages file is actually present (but don't check content).
214 if (base::PathExists( 214 if (base::PathExists(
215 locale_folder.Append(extensions::kMessagesFilename))) { 215 locale_folder.Append(extensions::filenames::kMessagesFilename))) {
216 valid_locales->insert(locale_name); 216 valid_locales->insert(locale_name);
217 } else { 217 } else {
218 *error = base::StringPrintf("Catalog file is missing for locale %s.", 218 *error = base::StringPrintf("Catalog file is missing for locale %s.",
219 locale_name.c_str()); 219 locale_name.c_str());
220 return false; 220 return false;
221 } 221 }
222 222
223 return true; 223 return true;
224 } 224 }
225 225
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 288
289 // Loads contents of the messages file for given locale. If file is not found, 289 // Loads contents of the messages file for given locale. If file is not found,
290 // or there was parsing error we return NULL and set |error|. 290 // or there was parsing error we return NULL and set |error|.
291 // Caller owns the returned object. 291 // Caller owns the returned object.
292 static base::DictionaryValue* LoadMessageFile( 292 static base::DictionaryValue* LoadMessageFile(
293 const base::FilePath& locale_path, 293 const base::FilePath& locale_path,
294 const std::string& locale, 294 const std::string& locale,
295 std::string* error) { 295 std::string* error) {
296 std::string extension_locale = locale; 296 std::string extension_locale = locale;
297 base::FilePath file = locale_path.AppendASCII(extension_locale) 297 base::FilePath file = locale_path.AppendASCII(extension_locale)
298 .Append(extensions::kMessagesFilename); 298 .Append(extensions::filenames::kMessagesFilename);
299 JSONFileValueSerializer messages_serializer(file); 299 JSONFileValueSerializer messages_serializer(file);
300 base::Value *dictionary = messages_serializer.Deserialize(NULL, error); 300 base::Value *dictionary = messages_serializer.Deserialize(NULL, error);
301 if (!dictionary && error->empty()) { 301 if (!dictionary && error->empty()) {
302 // JSONFileValueSerializer just returns NULL if file cannot be found. It 302 // JSONFileValueSerializer just returns NULL if file cannot be found. It
303 // doesn't set the error, so we have to do it. 303 // doesn't set the error, so we have to do it.
304 *error = base::StringPrintf("Catalog file is missing for locale %s.", 304 *error = base::StringPrintf("Catalog file is missing for locale %s.",
305 extension_locale.c_str()); 305 extension_locale.c_str());
306 } 306 }
307 307
308 return static_cast<base::DictionaryValue*>(dictionary); 308 return static_cast<base::DictionaryValue*>(dictionary);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale) 367 ScopedLocaleForTest::ScopedLocaleForTest(const std::string& locale)
368 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) { 368 : locale_(extension_l10n_util::CurrentLocaleOrDefault()) {
369 extension_l10n_util::SetProcessLocale(locale); 369 extension_l10n_util::SetProcessLocale(locale);
370 } 370 }
371 371
372 ScopedLocaleForTest::~ScopedLocaleForTest() { 372 ScopedLocaleForTest::~ScopedLocaleForTest() {
373 extension_l10n_util::SetProcessLocale(locale_); 373 extension_l10n_util::SetProcessLocale(locale_);
374 } 374 }
375 375
376 } // namespace extension_l10n_util 376 } // namespace extension_l10n_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698