OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 if (loc1 == loc2) | 275 if (loc1 == loc2) |
276 return loc1; | 276 return loc1; |
277 | 277 |
278 int loc1_rank = GetLocationRank(loc1); | 278 int loc1_rank = GetLocationRank(loc1); |
279 int loc2_rank = GetLocationRank(loc2); | 279 int loc2_rank = GetLocationRank(loc2); |
280 | 280 |
281 // If two different locations have the same rank, then we can not | 281 // If two different locations have the same rank, then we can not |
282 // deterministicly choose a location. | 282 // deterministicly choose a location. |
283 CHECK(loc1_rank != loc2_rank); | 283 CHECK(loc1_rank != loc2_rank); |
284 | 284 |
285 // Lowest rank has highest priority. | 285 // Highest rank has highest priority. |
286 return (loc1_rank > loc2_rank ? loc1 : loc2 ); | 286 return (loc1_rank > loc2_rank ? loc1 : loc2 ); |
287 } | 287 } |
288 | 288 |
289 void Extension::OverrideLaunchUrl(const GURL& override_url) { | 289 void Extension::OverrideLaunchUrl(const GURL& override_url) { |
290 GURL new_url(override_url); | 290 GURL new_url(override_url); |
291 if (!new_url.is_valid()) { | 291 if (!new_url.is_valid()) { |
292 LOG(WARNING) << "Invalid override url given for " << name(); | 292 LOG(WARNING) << "Invalid override url given for " << name(); |
293 } else { | 293 } else { |
294 if (new_url.has_port()) { | 294 if (new_url.has_port()) { |
295 LOG(WARNING) << "Override URL passed for " << name() | 295 LOG(WARNING) << "Override URL passed for " << name() |
(...skipping 2518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2814 return false; | 2814 return false; |
2815 origin_only_pattern.SetHost(origin.host()); | 2815 origin_only_pattern.SetHost(origin.host()); |
2816 origin_only_pattern.SetPath("/*"); | 2816 origin_only_pattern.SetPath("/*"); |
2817 | 2817 |
2818 URLPatternSet origin_only_pattern_list; | 2818 URLPatternSet origin_only_pattern_list; |
2819 origin_only_pattern_list.AddPattern(origin_only_pattern); | 2819 origin_only_pattern_list.AddPattern(origin_only_pattern); |
2820 | 2820 |
2821 return web_extent().OverlapsWith(origin_only_pattern_list); | 2821 return web_extent().OverlapsWith(origin_only_pattern_list); |
2822 } | 2822 } |
2823 | 2823 |
| 2824 Extension::SyncType Extension::GetSyncType() const { |
| 2825 // TODO(akalin): Figure out if we need to allow some other types. |
| 2826 if (location() != Extension::INTERNAL) { |
| 2827 // We have a non-standard location. |
| 2828 return SYNC_TYPE_NONE; |
| 2829 } |
| 2830 |
| 2831 // Disallow extensions with non-gallery auto-update URLs for now. |
| 2832 // |
| 2833 // TODO(akalin): Relax this restriction once we've put in UI to |
| 2834 // approve synced extensions. |
| 2835 if (!update_url().is_empty() && |
| 2836 (update_url() != GalleryUpdateUrl(false)) && |
| 2837 (update_url() != GalleryUpdateUrl(true))) { |
| 2838 return SYNC_TYPE_NONE; |
| 2839 } |
| 2840 |
| 2841 // Disallow extensions with native code plugins. |
| 2842 // |
| 2843 // TODO(akalin): Relax this restriction once we've put in UI to |
| 2844 // approve synced extensions. |
| 2845 if (!plugins().empty()) { |
| 2846 return SYNC_TYPE_NONE; |
| 2847 } |
| 2848 |
| 2849 switch (GetType()) { |
| 2850 case Extension::TYPE_EXTENSION: |
| 2851 return SYNC_TYPE_EXTENSION; |
| 2852 |
| 2853 case Extension::TYPE_USER_SCRIPT: |
| 2854 // We only want to sync user scripts with gallery update URLs. |
| 2855 if (update_url() == GalleryUpdateUrl(true) || |
| 2856 update_url() == GalleryUpdateUrl(false)) |
| 2857 return SYNC_TYPE_EXTENSION; |
| 2858 else |
| 2859 return SYNC_TYPE_NONE; |
| 2860 |
| 2861 case Extension::TYPE_HOSTED_APP: |
| 2862 case Extension::TYPE_PACKAGED_APP: |
| 2863 return SYNC_TYPE_APP; |
| 2864 |
| 2865 default: |
| 2866 return SYNC_TYPE_NONE; |
| 2867 } |
| 2868 } |
| 2869 |
2824 ExtensionInfo::ExtensionInfo(const DictionaryValue* manifest, | 2870 ExtensionInfo::ExtensionInfo(const DictionaryValue* manifest, |
2825 const std::string& id, | 2871 const std::string& id, |
2826 const FilePath& path, | 2872 const FilePath& path, |
2827 Extension::Location location) | 2873 Extension::Location location) |
2828 : extension_id(id), | 2874 : extension_id(id), |
2829 extension_path(path), | 2875 extension_path(path), |
2830 extension_location(location) { | 2876 extension_location(location) { |
2831 if (manifest) | 2877 if (manifest) |
2832 extension_manifest.reset(manifest->DeepCopy()); | 2878 extension_manifest.reset(manifest->DeepCopy()); |
2833 } | 2879 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2867 already_disabled(false), | 2913 already_disabled(false), |
2868 extension(extension) {} | 2914 extension(extension) {} |
2869 | 2915 |
2870 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 2916 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
2871 const Extension* extension, | 2917 const Extension* extension, |
2872 const ExtensionPermissionSet* permissions, | 2918 const ExtensionPermissionSet* permissions, |
2873 Reason reason) | 2919 Reason reason) |
2874 : reason(reason), | 2920 : reason(reason), |
2875 extension(extension), | 2921 extension(extension), |
2876 permissions(permissions) {} | 2922 permissions(permissions) {} |
OLD | NEW |