| OLD | NEW |
| 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.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 } | 497 } |
| 498 | 498 |
| 499 bool Extension::is_packaged_app() const { | 499 bool Extension::is_packaged_app() const { |
| 500 return manifest()->is_packaged_app(); | 500 return manifest()->is_packaged_app(); |
| 501 } | 501 } |
| 502 | 502 |
| 503 bool Extension::is_theme() const { | 503 bool Extension::is_theme() const { |
| 504 return manifest()->is_theme(); | 504 return manifest()->is_theme(); |
| 505 } | 505 } |
| 506 | 506 |
| 507 bool Extension::is_content_pack() const { |
| 508 return manifest()->is_content_pack(); |
| 509 } |
| 510 |
| 511 FilePath Extension::GetContentPackSiteList() const { |
| 512 if (content_pack_site_list_.empty()) |
| 513 return FilePath(); |
| 514 |
| 515 // TODO(bauerb): Use ExtensionResource? |
| 516 return path().Append(content_pack_site_list_); |
| 517 } |
| 518 |
| 507 GURL Extension::GetBackgroundURL() const { | 519 GURL Extension::GetBackgroundURL() const { |
| 508 if (!background_scripts_.empty()) { | 520 if (!background_scripts_.empty()) { |
| 509 return GetResourceURL( | 521 return GetResourceURL( |
| 510 extension_filenames::kGeneratedBackgroundPageFilename); | 522 extension_filenames::kGeneratedBackgroundPageFilename); |
| 511 } else { | 523 } else { |
| 512 return background_url_; | 524 return background_url_; |
| 513 } | 525 } |
| 514 } | 526 } |
| 515 | 527 |
| 516 bool Extension::ResourceMatches(const URLPatternSet& pattern_set, | 528 bool Extension::ResourceMatches(const URLPatternSet& pattern_set, |
| (...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 string16* error) { | 2891 string16* error) { |
| 2880 const DictionaryValue* display_properties_value = NULL; | 2892 const DictionaryValue* display_properties_value = NULL; |
| 2881 if (theme_value->GetDictionary(keys::kThemeDisplayProperties, | 2893 if (theme_value->GetDictionary(keys::kThemeDisplayProperties, |
| 2882 &display_properties_value)) { | 2894 &display_properties_value)) { |
| 2883 theme_display_properties_.reset( | 2895 theme_display_properties_.reset( |
| 2884 display_properties_value->DeepCopy()); | 2896 display_properties_value->DeepCopy()); |
| 2885 } | 2897 } |
| 2886 return true; | 2898 return true; |
| 2887 } | 2899 } |
| 2888 | 2900 |
| 2901 bool Extension::LoadManagedModeFeatures(string16* error) { |
| 2902 if (!manifest_->HasKey(keys::kContentPack)) |
| 2903 return true; |
| 2904 DictionaryValue* content_pack_value = NULL; |
| 2905 if (!manifest_->GetDictionary(keys::kContentPack, &content_pack_value)) { |
| 2906 *error = ASCIIToUTF16(errors::kInvalidContentPack); |
| 2907 return false; |
| 2908 } |
| 2909 if (!LoadManagedModeSites(content_pack_value, error)) |
| 2910 return false; |
| 2911 |
| 2912 return true; |
| 2913 } |
| 2914 |
| 2915 bool Extension::LoadManagedModeSites( |
| 2916 const DictionaryValue* content_pack_value, |
| 2917 string16* error) { |
| 2918 if (!content_pack_value->HasKey(keys::kContentPackSites)) |
| 2919 return true; |
| 2920 |
| 2921 if (!content_pack_value->GetString(keys::kContentPackSites, |
| 2922 &content_pack_site_list_)) { |
| 2923 *error = ASCIIToUTF16(errors::kInvalidContentPackSites); |
| 2924 return false; |
| 2925 } |
| 2926 |
| 2927 return true; |
| 2928 } |
| 2929 |
| 2889 // static | 2930 // static |
| 2890 bool Extension::IsTrustedId(const std::string& id) { | 2931 bool Extension::IsTrustedId(const std::string& id) { |
| 2891 // See http://b/4946060 for more details. | 2932 // See http://b/4946060 for more details. |
| 2892 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); | 2933 return id == std::string("nckgahadagoaajjgafhacjanaoiihapd"); |
| 2893 } | 2934 } |
| 2894 | 2935 |
| 2895 Extension::Extension(const FilePath& path, | 2936 Extension::Extension(const FilePath& path, |
| 2896 scoped_ptr<extensions::Manifest> manifest) | 2937 scoped_ptr<extensions::Manifest> manifest) |
| 2897 : manifest_version_(0), | 2938 : manifest_version_(0), |
| 2898 incognito_split_mode_(false), | 2939 incognito_split_mode_(false), |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3147 | 3188 |
| 3148 if (!LoadSharedFeatures(api_permissions, error)) | 3189 if (!LoadSharedFeatures(api_permissions, error)) |
| 3149 return false; | 3190 return false; |
| 3150 | 3191 |
| 3151 if (!LoadExtensionFeatures(api_permissions, error)) | 3192 if (!LoadExtensionFeatures(api_permissions, error)) |
| 3152 return false; | 3193 return false; |
| 3153 | 3194 |
| 3154 if (!LoadThemeFeatures(error)) | 3195 if (!LoadThemeFeatures(error)) |
| 3155 return false; | 3196 return false; |
| 3156 | 3197 |
| 3198 if (!LoadManagedModeFeatures(error)) |
| 3199 return false; |
| 3200 |
| 3157 if (HasMultipleUISurfaces()) { | 3201 if (HasMultipleUISurfaces()) { |
| 3158 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); | 3202 *error = ASCIIToUTF16(errors::kOneUISurfaceOnly); |
| 3159 return false; | 3203 return false; |
| 3160 } | 3204 } |
| 3161 | 3205 |
| 3162 runtime_data_.SetActivePermissions(new PermissionSet( | 3206 runtime_data_.SetActivePermissions(new PermissionSet( |
| 3163 this, api_permissions, host_permissions)); | 3207 this, api_permissions, host_permissions)); |
| 3164 required_permission_set_ = new PermissionSet( | 3208 required_permission_set_ = new PermissionSet( |
| 3165 this, api_permissions, host_permissions); | 3209 this, api_permissions, host_permissions); |
| 3166 optional_permission_set_ = new PermissionSet( | 3210 optional_permission_set_ = new PermissionSet( |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3901 | 3945 |
| 3902 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3946 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3903 const Extension* extension, | 3947 const Extension* extension, |
| 3904 const PermissionSet* permissions, | 3948 const PermissionSet* permissions, |
| 3905 Reason reason) | 3949 Reason reason) |
| 3906 : reason(reason), | 3950 : reason(reason), |
| 3907 extension(extension), | 3951 extension(extension), |
| 3908 permissions(permissions) {} | 3952 permissions(permissions) {} |
| 3909 | 3953 |
| 3910 } // namespace extensions | 3954 } // namespace extensions |
| OLD | NEW |