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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 2953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2964 origin_only_pattern.SetHost(origin.host()); | 2964 origin_only_pattern.SetHost(origin.host()); |
2965 origin_only_pattern.SetPath("/*"); | 2965 origin_only_pattern.SetPath("/*"); |
2966 | 2966 |
2967 URLPatternSet origin_only_pattern_list; | 2967 URLPatternSet origin_only_pattern_list; |
2968 origin_only_pattern_list.AddPattern(origin_only_pattern); | 2968 origin_only_pattern_list.AddPattern(origin_only_pattern); |
2969 | 2969 |
2970 return web_extent().OverlapsWith(origin_only_pattern_list); | 2970 return web_extent().OverlapsWith(origin_only_pattern_list); |
2971 } | 2971 } |
2972 | 2972 |
2973 Extension::SyncType Extension::GetSyncType() const { | 2973 Extension::SyncType Extension::GetSyncType() const { |
2974 // TODO(akalin): Figure out if we need to allow some other types. | 2974 if (!IsSyncable()) { |
2975 if (location() != Extension::INTERNAL) { | |
2976 // We have a non-standard location. | 2975 // We have a non-standard location. |
2977 return SYNC_TYPE_NONE; | 2976 return SYNC_TYPE_NONE; |
2978 } | 2977 } |
2979 | 2978 |
2980 // Disallow extensions with non-gallery auto-update URLs for now. | 2979 // Disallow extensions with non-gallery auto-update URLs for now. |
2981 // | 2980 // |
2982 // TODO(akalin): Relax this restriction once we've put in UI to | 2981 // TODO(akalin): Relax this restriction once we've put in UI to |
2983 // approve synced extensions. | 2982 // approve synced extensions. |
2984 if (!update_url().is_empty() && !UpdatesFromGallery()) | 2983 if (!update_url().is_empty() && !UpdatesFromGallery()) |
2985 return SYNC_TYPE_NONE; | 2984 return SYNC_TYPE_NONE; |
(...skipping 19 matching lines...) Expand all Loading... |
3005 | 3004 |
3006 case Extension::TYPE_HOSTED_APP: | 3005 case Extension::TYPE_HOSTED_APP: |
3007 case Extension::TYPE_PACKAGED_APP: | 3006 case Extension::TYPE_PACKAGED_APP: |
3008 return SYNC_TYPE_APP; | 3007 return SYNC_TYPE_APP; |
3009 | 3008 |
3010 default: | 3009 default: |
3011 return SYNC_TYPE_NONE; | 3010 return SYNC_TYPE_NONE; |
3012 } | 3011 } |
3013 } | 3012 } |
3014 | 3013 |
| 3014 bool Extension::IsSyncable() const { |
| 3015 // TODO(akalin): Figure out if we need to allow some other types. |
| 3016 |
| 3017 // We want to sync any extensions that are shown in the luancher because |
| 3018 // their positions should sync. |
| 3019 return location_ == Extension::INTERNAL || |
| 3020 ShouldDisplayInLauncher(); |
| 3021 |
| 3022 } |
| 3023 |
| 3024 bool Extension::ShouldDisplayInLauncher() const { |
| 3025 // The CWS needs to be treated as syncable app because it appears on the NTP |
| 3026 // and we need to make sure its position values are synced. |
| 3027 // If another case arises where we need to have a special case like the CWS, |
| 3028 // something more systematic should be done. |
| 3029 return location_ == Extension::INTERNAL || |
| 3030 id() == extension_misc::kWebStoreAppId; |
| 3031 } |
| 3032 |
3015 ExtensionInfo::ExtensionInfo(const DictionaryValue* manifest, | 3033 ExtensionInfo::ExtensionInfo(const DictionaryValue* manifest, |
3016 const std::string& id, | 3034 const std::string& id, |
3017 const FilePath& path, | 3035 const FilePath& path, |
3018 Extension::Location location) | 3036 Extension::Location location) |
3019 : extension_id(id), | 3037 : extension_id(id), |
3020 extension_path(path), | 3038 extension_path(path), |
3021 extension_location(location) { | 3039 extension_location(location) { |
3022 if (manifest) | 3040 if (manifest) |
3023 extension_manifest.reset(manifest->DeepCopy()); | 3041 extension_manifest.reset(manifest->DeepCopy()); |
3024 } | 3042 } |
(...skipping 22 matching lines...) Expand all Loading... |
3047 already_disabled(false), | 3065 already_disabled(false), |
3048 extension(extension) {} | 3066 extension(extension) {} |
3049 | 3067 |
3050 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3068 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
3051 const Extension* extension, | 3069 const Extension* extension, |
3052 const ExtensionPermissionSet* permissions, | 3070 const ExtensionPermissionSet* permissions, |
3053 Reason reason) | 3071 Reason reason) |
3054 : reason(reason), | 3072 : reason(reason), |
3055 extension(extension), | 3073 extension(extension), |
3056 permissions(permissions) {} | 3074 permissions(permissions) {} |
OLD | NEW |