OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 for (DictionaryValue::key_iterator key = source.begin_keys(); | 726 for (DictionaryValue::key_iterator key = source.begin_keys(); |
727 key != source.end_keys(); ++key) { | 727 key != source.end_keys(); ++key) { |
728 if (!IsBaseCrxKey(*key) && *key != keys::kTheme) | 728 if (!IsBaseCrxKey(*key) && *key != keys::kTheme) |
729 return true; | 729 return true; |
730 } | 730 } |
731 return false; | 731 return false; |
732 } | 732 } |
733 | 733 |
734 bool Extension::LoadIsApp(const DictionaryValue* manifest, | 734 bool Extension::LoadIsApp(const DictionaryValue* manifest, |
735 std::string* error) { | 735 std::string* error) { |
736 if (manifest->HasKey(keys::kApp)) { | 736 if (manifest->HasKey(keys::kApp)) |
737 if (!apps_enabled_) { | 737 is_app_ = true; |
738 *error = errors::kAppsNotEnabled; | |
739 return false; | |
740 } else { | |
741 is_app_ = true; | |
742 } | |
743 } | |
744 | 738 |
745 return true; | 739 return true; |
746 } | 740 } |
747 | 741 |
748 bool Extension::LoadExtent(const DictionaryValue* manifest, | 742 bool Extension::LoadExtent(const DictionaryValue* manifest, |
749 const char* key, | 743 const char* key, |
750 ExtensionExtent* extent, | 744 ExtensionExtent* extent, |
751 const char* list_error, | 745 const char* list_error, |
752 const char* value_error, | 746 const char* value_error, |
753 std::string* error) { | 747 std::string* error) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 is_theme_(false), | 946 is_theme_(false), |
953 is_app_(false), | 947 is_app_(false), |
954 launch_container_(extension_misc::LAUNCH_TAB), | 948 launch_container_(extension_misc::LAUNCH_TAB), |
955 launch_width_(0), | 949 launch_width_(0), |
956 launch_height_(0), | 950 launch_height_(0), |
957 background_page_ready_(false), | 951 background_page_ready_(false), |
958 being_upgraded_(false) { | 952 being_upgraded_(false) { |
959 DCHECK(path.IsAbsolute()); | 953 DCHECK(path.IsAbsolute()); |
960 | 954 |
961 static_data_ = mutable_static_data_; | 955 static_data_ = mutable_static_data_; |
962 apps_enabled_ = AppsAreEnabled(); | |
963 location_ = INVALID; | 956 location_ = INVALID; |
964 | 957 |
965 #if defined(OS_WIN) | 958 #if defined(OS_WIN) |
966 // Normalize any drive letter to upper-case. We do this for consistency with | 959 // Normalize any drive letter to upper-case. We do this for consistency with |
967 // net_utils::FilePathToFileURL(), which does the same thing, to make string | 960 // net_utils::FilePathToFileURL(), which does the same thing, to make string |
968 // comparisons simpler. | 961 // comparisons simpler. |
969 std::wstring path_str = path.value(); | 962 std::wstring path_str = path.value(); |
970 if (path_str.size() >= 2 && path_str[0] >= L'a' && path_str[0] <= L'z' && | 963 if (path_str.size() >= 2 && path_str[0] >= L'a' && path_str[0] <= L'z' && |
971 path_str[1] == ':') | 964 path_str[1] == ':') |
972 path_str[0] += ('A' - 'a'); | 965 path_str[0] += ('A' - 'a'); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 } | 1151 } |
1159 | 1152 |
1160 result->swap(decoded); | 1153 result->swap(decoded); |
1161 } | 1154 } |
1162 | 1155 |
1163 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { | 1156 GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { |
1164 return GURL(std::string(chrome::kExtensionScheme) + | 1157 return GURL(std::string(chrome::kExtensionScheme) + |
1165 chrome::kStandardSchemeSeparator + extension_id + "/"); | 1158 chrome::kStandardSchemeSeparator + extension_id + "/"); |
1166 } | 1159 } |
1167 | 1160 |
1168 // static | |
1169 bool Extension::AppsAreEnabled() { | |
1170 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableApps); | |
1171 } | |
1172 | |
1173 bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, | 1161 bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, |
1174 std::string* error) { | 1162 std::string* error) { |
1175 // Unit tests reuse Extension objects, so we need to reset mutable_static_data | 1163 // Unit tests reuse Extension objects, so we need to reset mutable_static_data |
1176 // when we re-initialize. | 1164 // when we re-initialize. |
1177 mutable_static_data_ = const_cast<StaticData*>(static_data_.get()); | 1165 mutable_static_data_ = const_cast<StaticData*>(static_data_.get()); |
1178 | 1166 |
1179 if (source.HasKey(keys::kPublicKey)) { | 1167 if (source.HasKey(keys::kPublicKey)) { |
1180 std::string public_key_bytes; | 1168 std::string public_key_bytes; |
1181 if (!source.GetString(keys::kPublicKey, &public_key_) || | 1169 if (!source.GetString(keys::kPublicKey, &public_key_) || |
1182 !ParsePEMKeyBytes(public_key_, &public_key_bytes) || | 1170 !ParsePEMKeyBytes(public_key_, &public_key_bytes) || |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 UninstalledExtensionInfo::UninstalledExtensionInfo( | 2162 UninstalledExtensionInfo::UninstalledExtensionInfo( |
2175 const Extension& extension) | 2163 const Extension& extension) |
2176 : extension_id(extension.id()), | 2164 : extension_id(extension.id()), |
2177 extension_api_permissions(extension.api_permissions()), | 2165 extension_api_permissions(extension.api_permissions()), |
2178 is_theme(extension.is_theme()), | 2166 is_theme(extension.is_theme()), |
2179 is_app(extension.is_app()), | 2167 is_app(extension.is_app()), |
2180 converted_from_user_script(extension.converted_from_user_script()), | 2168 converted_from_user_script(extension.converted_from_user_script()), |
2181 update_url(extension.update_url()) {} | 2169 update_url(extension.update_url()) {} |
2182 | 2170 |
2183 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} | 2171 UninstalledExtensionInfo::~UninstalledExtensionInfo() {} |
OLD | NEW |