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

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

Issue 12025010: Move default_locale out of Extension class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch updated Created 7 years, 11 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
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_file_util.h" 5 #include "chrome/common/extensions/extension_file_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/json/json_file_value_serializer.h" 13 #include "base/json/json_file_value_serializer.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/stringprintf.h" 17 #include "base/stringprintf.h"
18 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
19 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
20 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/extensions/api/extension_action/action_info.h" 22 #include "chrome/common/extensions/api/extension_action/action_info.h"
23 #include "chrome/common/extensions/api/i18n/default_locale_handler.h"
23 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
24 #include "chrome/common/extensions/extension_l10n_util.h" 25 #include "chrome/common/extensions/extension_l10n_util.h"
25 #include "chrome/common/extensions/extension_manifest_constants.h" 26 #include "chrome/common/extensions/extension_manifest_constants.h"
26 #include "chrome/common/extensions/extension_messages.h" 27 #include "chrome/common/extensions/extension_messages.h"
27 #include "chrome/common/extensions/extension_resource.h" 28 #include "chrome/common/extensions/extension_resource.h"
28 #include "chrome/common/extensions/manifest_url_handler.h" 29 #include "chrome/common/extensions/manifest_url_handler.h"
29 #include "chrome/common/extensions/message_bundle.h" 30 #include "chrome/common/extensions/message_bundle.h"
30 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
31 #include "net/base/escape.h" 32 #include "net/base/escape.h"
32 #include "net/base/file_stream.h" 33 #include "net/base/file_stream.h"
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 556
556 return returnValue; 557 return returnValue;
557 } 558 }
558 559
559 static bool ValidateLocaleInfo(const Extension& extension, 560 static bool ValidateLocaleInfo(const Extension& extension,
560 std::string* error) { 561 std::string* error) {
561 // default_locale and _locales have to be both present or both missing. 562 // default_locale and _locales have to be both present or both missing.
562 const FilePath path = extension.path().Append( 563 const FilePath path = extension.path().Append(
563 Extension::kLocaleFolder); 564 Extension::kLocaleFolder);
564 bool path_exists = file_util::PathExists(path); 565 bool path_exists = file_util::PathExists(path);
565 std::string default_locale = extension.default_locale(); 566 std::string default_locale =
567 extensions::LocaleInfo::GetDefaultLocale(&extension);
Yoyo Zhou 2013/01/22 20:15:56 This validation is done in the utility process so
Joe Thomas 2013/01/23 20:01:08 Done.
566 568
567 // If both default locale and _locales folder are empty, skip verification. 569 // If both default locale and _locales folder are empty, skip verification.
568 if (default_locale.empty() && !path_exists) 570 if (default_locale.empty() && !path_exists)
569 return true; 571 return true;
570 572
571 if (default_locale.empty() && path_exists) { 573 if (default_locale.empty() && path_exists) {
572 *error = l10n_util::GetStringUTF8( 574 *error = l10n_util::GetStringUTF8(
573 IDS_EXTENSION_LOCALES_NO_DEFAULT_LOCALE_SPECIFIED); 575 IDS_EXTENSION_LOCALES_NO_DEFAULT_LOCALE_SPECIFIED);
574 return false; 576 return false;
575 } else if (!default_locale.empty() && !path_exists) { 577 } else if (!default_locale.empty() && !path_exists) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 return FilePath(); 758 return FilePath();
757 } 759 }
758 return temp_path; 760 return temp_path;
759 } 761 }
760 762
761 void DeleteFile(const FilePath& path, bool recursive) { 763 void DeleteFile(const FilePath& path, bool recursive) {
762 file_util::Delete(path, recursive); 764 file_util::Delete(path, recursive);
763 } 765 }
764 766
765 } // namespace extension_file_util 767 } // namespace extension_file_util
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/extensions/extension_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698