OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/sync_helper.h" | 5 #include "chrome/common/extensions/sync_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 8 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
9 #include "chrome/common/extensions/extension_constants.h" | 9 #include "chrome/common/extensions/extension_constants.h" |
10 #include "chrome/common/extensions/manifest_url_handler.h" | 10 #include "chrome/common/extensions/manifest_url_handler.h" |
11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
12 #include "extensions/common/manifest.h" | 12 #include "extensions/common/manifest.h" |
| 13 #include "extensions/common/permissions/permissions_data.h" |
13 | 14 |
14 namespace extensions { | 15 namespace extensions { |
15 namespace sync_helper { | 16 namespace sync_helper { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 enum SyncType { | 20 enum SyncType { |
20 SYNC_TYPE_NONE = 0, | 21 SYNC_TYPE_NONE = 0, |
21 SYNC_TYPE_EXTENSION, | 22 SYNC_TYPE_EXTENSION, |
22 SYNC_TYPE_APP | 23 SYNC_TYPE_APP |
(...skipping 12 matching lines...) Expand all Loading... |
35 if (!ManifestURL::GetUpdateURL(extension).is_empty() && | 36 if (!ManifestURL::GetUpdateURL(extension).is_empty() && |
36 !ManifestURL::UpdatesFromGallery(extension)) { | 37 !ManifestURL::UpdatesFromGallery(extension)) { |
37 return SYNC_TYPE_NONE; | 38 return SYNC_TYPE_NONE; |
38 } | 39 } |
39 | 40 |
40 // Disallow extensions with native code plugins. | 41 // Disallow extensions with native code plugins. |
41 // | 42 // |
42 // TODO(akalin): Relax this restriction once we've put in UI to | 43 // TODO(akalin): Relax this restriction once we've put in UI to |
43 // approve synced extensions. | 44 // approve synced extensions. |
44 if (PluginInfo::HasPlugins(extension) || | 45 if (PluginInfo::HasPlugins(extension) || |
45 extension->HasAPIPermission(APIPermission::kPlugin)) { | 46 extension->permissions_data()->HasAPIPermission(APIPermission::kPlugin)) { |
46 return SYNC_TYPE_NONE; | 47 return SYNC_TYPE_NONE; |
47 } | 48 } |
48 | 49 |
49 switch (extension->GetType()) { | 50 switch (extension->GetType()) { |
50 case Manifest::TYPE_EXTENSION: | 51 case Manifest::TYPE_EXTENSION: |
51 return SYNC_TYPE_EXTENSION; | 52 return SYNC_TYPE_EXTENSION; |
52 | 53 |
53 case Manifest::TYPE_USER_SCRIPT: | 54 case Manifest::TYPE_USER_SCRIPT: |
54 // We only want to sync user scripts with gallery update URLs. | 55 // We only want to sync user scripts with gallery update URLs. |
55 if (ManifestURL::UpdatesFromGallery(extension)) | 56 if (ManifestURL::UpdatesFromGallery(extension)) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 bool IsSyncableExtension(const Extension* extension) { | 97 bool IsSyncableExtension(const Extension* extension) { |
97 return GetSyncType(extension) == SYNC_TYPE_EXTENSION; | 98 return GetSyncType(extension) == SYNC_TYPE_EXTENSION; |
98 } | 99 } |
99 | 100 |
100 bool IsSyncableApp(const Extension* extension) { | 101 bool IsSyncableApp(const Extension* extension) { |
101 return GetSyncType(extension) == SYNC_TYPE_APP; | 102 return GetSyncType(extension) == SYNC_TYPE_APP; |
102 } | 103 } |
103 | 104 |
104 } // namespace sync_helper | 105 } // namespace sync_helper |
105 } // namespace extensions | 106 } // namespace extensions |
OLD | NEW |