Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 7564037: Apps/Extensions Sync refactoring -- delete most of the old glue, implement new sync API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes for Review Comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 2521 matching lines...) Expand 10 before | Expand all | Expand 10 after
2817 return false; 2817 return false;
2818 origin_only_pattern.SetHost(origin.host()); 2818 origin_only_pattern.SetHost(origin.host());
2819 origin_only_pattern.SetPath("/*"); 2819 origin_only_pattern.SetPath("/*");
2820 2820
2821 URLPatternSet origin_only_pattern_list; 2821 URLPatternSet origin_only_pattern_list;
2822 origin_only_pattern_list.AddPattern(origin_only_pattern); 2822 origin_only_pattern_list.AddPattern(origin_only_pattern);
2823 2823
2824 return web_extent().OverlapsWith(origin_only_pattern_list); 2824 return web_extent().OverlapsWith(origin_only_pattern_list);
2825 } 2825 }
2826 2826
2827 Extension::SyncType Extension::GetSyncType() const {
2828 // TODO(akalin): Figure out if we need to allow some other types.
2829 if (location() != Extension::INTERNAL) {
2830 // We have a non-standard location.
2831 return SYNC_TYPE_NONE;
2832 }
2833
2834 // Disallow extensions with non-gallery auto-update URLs for now.
2835 //
2836 // TODO(akalin): Relax this restriction once we've put in UI to
2837 // approve synced extensions.
2838 if (!update_url().is_empty() &&
2839 (update_url() != GalleryUpdateUrl(false)) &&
2840 (update_url() != GalleryUpdateUrl(true))) {
2841 return SYNC_TYPE_NONE;
2842 }
2843
2844 // Disallow extensions with native code plugins.
2845 //
2846 // TODO(akalin): Relax this restriction once we've put in UI to
2847 // approve synced extensions.
2848 if (!plugins().empty()) {
2849 return SYNC_TYPE_NONE;
2850 }
2851
2852 switch (GetType()) {
2853 case Extension::TYPE_EXTENSION:
2854 return SYNC_TYPE_EXTENSION;
2855
2856 case Extension::TYPE_USER_SCRIPT:
2857 // We only want to sync user scripts with gallery update URLs.
2858 if (update_url() == GalleryUpdateUrl(true) ||
2859 update_url() == GalleryUpdateUrl(false))
2860 return SYNC_TYPE_EXTENSION;
2861 else
2862 return SYNC_TYPE_NONE;
2863
2864 case Extension::TYPE_HOSTED_APP:
2865 case Extension::TYPE_PACKAGED_APP:
2866 return SYNC_TYPE_APP;
2867
2868 default:
2869 return SYNC_TYPE_NONE;
2870 }
2871 }
2872
2827 ExtensionInfo::ExtensionInfo(const DictionaryValue* manifest, 2873 ExtensionInfo::ExtensionInfo(const DictionaryValue* manifest,
2828 const std::string& id, 2874 const std::string& id,
2829 const FilePath& path, 2875 const FilePath& path,
2830 Extension::Location location) 2876 Extension::Location location)
2831 : extension_id(id), 2877 : extension_id(id),
2832 extension_path(path), 2878 extension_path(path),
2833 extension_location(location) { 2879 extension_location(location) {
2834 if (manifest) 2880 if (manifest)
2835 extension_manifest.reset(manifest->DeepCopy()); 2881 extension_manifest.reset(manifest->DeepCopy());
2836 } 2882 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2870 already_disabled(false), 2916 already_disabled(false),
2871 extension(extension) {} 2917 extension(extension) {}
2872 2918
2873 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 2919 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
2874 const Extension* extension, 2920 const Extension* extension,
2875 const ExtensionPermissionSet* permissions, 2921 const ExtensionPermissionSet* permissions,
2876 Reason reason) 2922 Reason reason)
2877 : reason(reason), 2923 : reason(reason),
2878 extension(extension), 2924 extension(extension),
2879 permissions(permissions) {} 2925 permissions(permissions) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698