Chromium Code Reviews| 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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 | 60 |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 // static | 66 // static |
| 67 int Extension::id_counter_ = 0; | 67 int Extension::id_counter_ = 0; |
| 68 | 68 |
| 69 const char Extension::kManifestFilename[] = "manifest.json"; | 69 const char Extension::kManifestFilename[] = "manifest.json"; |
| 70 const char Extension::kLocaleFolder[] = "_locales"; | |
| 71 const char Extension::kMessagesFilename[] = "messages"; | |
|
Aaron Boodman
2009/08/19 03:00:49
I asked this in a previous review, but it looks to
| |
| 70 | 72 |
| 71 // A list of all the keys allowed by themes. | 73 // A list of all the keys allowed by themes. |
| 72 static const wchar_t* kValidThemeKeys[] = { | 74 static const wchar_t* kValidThemeKeys[] = { |
| 73 keys::kDescription, | 75 keys::kDescription, |
| 74 keys::kName, | 76 keys::kName, |
| 75 keys::kPublicKey, | 77 keys::kPublicKey, |
| 76 keys::kSignature, | 78 keys::kSignature, |
| 77 keys::kTheme, | 79 keys::kTheme, |
| 78 keys::kVersion, | 80 keys::kVersion, |
| 79 keys::kUpdateURL | 81 keys::kUpdateURL |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 908 (pattern.scheme() != chrome::kHttpsScheme)) { | 910 (pattern.scheme() != chrome::kHttpsScheme)) { |
| 909 *error = ExtensionErrorUtils::FormatErrorMessage( | 911 *error = ExtensionErrorUtils::FormatErrorMessage( |
| 910 errors::kInvalidPermissionScheme, IntToString(i)); | 912 errors::kInvalidPermissionScheme, IntToString(i)); |
| 911 return false; | 913 return false; |
| 912 } | 914 } |
| 913 | 915 |
| 914 host_permissions_.push_back(pattern); | 916 host_permissions_.push_back(pattern); |
| 915 } | 917 } |
| 916 } | 918 } |
| 917 | 919 |
| 920 // Initialize default locale (if present). | |
| 921 if (source.HasKey(keys::kDefaultLocale)) { | |
| 922 std::string default_locale; | |
| 923 if (!source.GetString(keys::kDefaultLocale, &default_locale)) { | |
| 924 *error = errors::kInvalidDefaultLocale; | |
| 925 return false; | |
| 926 } | |
| 927 // Normalize underscores to hyphens. | |
| 928 std::replace(default_locale.begin(), default_locale.end(), '_', '-'); | |
| 929 set_default_locale(default_locale); | |
| 930 } | |
| 931 | |
| 918 return true; | 932 return true; |
| 919 } | 933 } |
| 920 | 934 |
| 921 std::set<FilePath> Extension::GetBrowserImages() { | 935 std::set<FilePath> Extension::GetBrowserImages() { |
| 922 std::set<FilePath> image_paths; | 936 std::set<FilePath> image_paths; |
| 923 | 937 |
| 924 // extension icons | 938 // extension icons |
| 925 for (std::map<int, std::string>::iterator iter = icons_.begin(); | 939 for (std::map<int, std::string>::iterator iter = icons_.begin(); |
| 926 iter != icons_.end(); ++iter) { | 940 iter != icons_.end(); ++iter) { |
| 927 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second))); | 941 image_paths.insert(FilePath::FromWStringHack(UTF8ToWide(iter->second))); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 } | 990 } |
| 977 | 991 |
| 978 void Extension::SetBackgroundPageReady() { | 992 void Extension::SetBackgroundPageReady() { |
| 979 DCHECK(!background_url().is_empty()); | 993 DCHECK(!background_url().is_empty()); |
| 980 background_page_ready_ = true; | 994 background_page_ready_ = true; |
| 981 NotificationService::current()->Notify( | 995 NotificationService::current()->Notify( |
| 982 NotificationType::EXTENSION_BACKGROUND_PAGE_READY, | 996 NotificationType::EXTENSION_BACKGROUND_PAGE_READY, |
| 983 Source<Extension>(this), | 997 Source<Extension>(this), |
| 984 NotificationService::NoDetails()); | 998 NotificationService::NoDetails()); |
| 985 } | 999 } |
| OLD | NEW |