| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
| 20 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 21 #include "base/values.h" | 21 #include "base/values.h" |
| 22 #include "base/version.h" | 22 #include "base/version.h" |
| 23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/common/chrome_version_info.h" | 25 #include "chrome/common/chrome_version_info.h" |
| 26 // TODO(rdevlin.cronin): Remove these once all references have been removed as | 26 // TODO(rdevlin.cronin): Remove these once all references have been removed as |
| 27 // part of crbug.com/159265. | 27 // part of crbug.com/159265. |
| 28 #include "chrome/common/extensions/api/extension_action/action_info.h" | |
| 29 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 28 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
| 30 #include "chrome/common/extensions/background_info.h" | 29 #include "chrome/common/extensions/background_info.h" |
| 31 #include "chrome/common/extensions/extension_manifest_constants.h" | 30 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 32 #include "chrome/common/extensions/incognito_handler.h" | 31 #include "chrome/common/extensions/incognito_handler.h" |
| 33 #include "chrome/common/extensions/manifest.h" | 32 #include "chrome/common/extensions/manifest.h" |
| 34 #include "chrome/common/extensions/manifest_handler.h" | 33 #include "chrome/common/extensions/manifest_handler.h" |
| 35 #include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h" | 34 #include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h" |
| 36 #include "chrome/common/extensions/manifest_handlers/offline_enabled_info.h" | 35 #include "chrome/common/extensions/manifest_handlers/offline_enabled_info.h" |
| 37 #include "chrome/common/extensions/manifest_url_handler.h" | 36 #include "chrome/common/extensions/manifest_url_handler.h" |
| 38 #include "chrome/common/extensions/permissions/api_permission_set.h" | 37 #include "chrome/common/extensions/permissions/api_permission_set.h" |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 return false; | 718 return false; |
| 720 | 719 |
| 721 if (manifest_->HasKey(keys::kConvertedFromUserScript)) { | 720 if (manifest_->HasKey(keys::kConvertedFromUserScript)) { |
| 722 manifest_->GetBoolean(keys::kConvertedFromUserScript, | 721 manifest_->GetBoolean(keys::kConvertedFromUserScript, |
| 723 &converted_from_user_script_); | 722 &converted_from_user_script_); |
| 724 } | 723 } |
| 725 | 724 |
| 726 if (!LoadSharedFeatures(error)) | 725 if (!LoadSharedFeatures(error)) |
| 727 return false; | 726 return false; |
| 728 | 727 |
| 729 if (HasMultipleUISurfaces()) { | |
| 730 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); | |
| 731 return false; | |
| 732 } | |
| 733 | |
| 734 finished_parsing_manifest_ = true; | 728 finished_parsing_manifest_ = true; |
| 735 | 729 |
| 736 permissions_data_->FinalizePermissions(this); | 730 permissions_data_->FinalizePermissions(this); |
| 737 | 731 |
| 738 return true; | 732 return true; |
| 739 } | 733 } |
| 740 | 734 |
| 741 bool Extension::LoadRequiredFeatures(string16* error) { | 735 bool Extension::LoadRequiredFeatures(string16* error) { |
| 742 if (!LoadName(error) || | 736 if (!LoadName(error) || |
| 743 !LoadVersion(error)) | 737 !LoadVersion(error)) |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 switches::kAllowLegacyExtensionManifests)) { | 1057 switches::kAllowLegacyExtensionManifests)) { |
| 1064 *error = ErrorUtils::FormatErrorMessageUTF16( | 1058 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 1065 errors::kInvalidManifestVersionOld, | 1059 errors::kInvalidManifestVersionOld, |
| 1066 base::IntToString(kModernManifestVersion)); | 1060 base::IntToString(kModernManifestVersion)); |
| 1067 return false; | 1061 return false; |
| 1068 } | 1062 } |
| 1069 | 1063 |
| 1070 return true; | 1064 return true; |
| 1071 } | 1065 } |
| 1072 | 1066 |
| 1073 bool Extension::HasMultipleUISurfaces() const { | |
| 1074 int num_surfaces = 0; | |
| 1075 | |
| 1076 if (ActionInfo::GetPageActionInfo(this)) | |
| 1077 ++num_surfaces; | |
| 1078 | |
| 1079 if (ActionInfo::GetBrowserActionInfo(this)) | |
| 1080 ++num_surfaces; | |
| 1081 | |
| 1082 if (is_app()) | |
| 1083 ++num_surfaces; | |
| 1084 | |
| 1085 return num_surfaces > 1; | |
| 1086 } | |
| 1087 | |
| 1088 void Extension::OverrideLaunchUrl(const GURL& override_url) { | 1067 void Extension::OverrideLaunchUrl(const GURL& override_url) { |
| 1089 GURL new_url(override_url); | 1068 GURL new_url(override_url); |
| 1090 if (!new_url.is_valid()) { | 1069 if (!new_url.is_valid()) { |
| 1091 DLOG(WARNING) << "Invalid override url given for " << name(); | 1070 DLOG(WARNING) << "Invalid override url given for " << name(); |
| 1092 } else { | 1071 } else { |
| 1093 if (new_url.has_port()) { | 1072 if (new_url.has_port()) { |
| 1094 DLOG(WARNING) << "Override URL passed for " << name() | 1073 DLOG(WARNING) << "Override URL passed for " << name() |
| 1095 << " should not contain a port. Removing it."; | 1074 << " should not contain a port. Removing it."; |
| 1096 | 1075 |
| 1097 GURL::Replacements remove_port; | 1076 GURL::Replacements remove_port; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 | 1183 |
| 1205 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 1184 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 1206 const Extension* extension, | 1185 const Extension* extension, |
| 1207 const PermissionSet* permissions, | 1186 const PermissionSet* permissions, |
| 1208 Reason reason) | 1187 Reason reason) |
| 1209 : reason(reason), | 1188 : reason(reason), |
| 1210 extension(extension), | 1189 extension(extension), |
| 1211 permissions(permissions) {} | 1190 permissions(permissions) {} |
| 1212 | 1191 |
| 1213 } // namespace extensions | 1192 } // namespace extensions |
| OLD | NEW |