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 "apps/shell/shell_extensions_client.h" | 5 #include "apps/shell/shell_extensions_client.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/common/extensions/features/base_feature_provider.h" | 8 #include "chrome/common/extensions/features/base_feature_provider.h" |
| 9 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" |
9 #include "extensions/common/common_manifest_handlers.h" | 10 #include "extensions/common/common_manifest_handlers.h" |
10 #include "extensions/common/manifest_handler.h" | 11 #include "extensions/common/manifest_handler.h" |
11 #include "extensions/common/permissions/permission_message_provider.h" | 12 #include "extensions/common/permissions/permission_message_provider.h" |
12 #include "extensions/common/permissions/permissions_provider.h" | 13 #include "extensions/common/permissions/permissions_provider.h" |
13 #include "extensions/common/url_pattern_set.h" | 14 #include "extensions/common/url_pattern_set.h" |
14 | 15 |
15 using extensions::APIPermissionInfo; | 16 using extensions::APIPermissionInfo; |
16 using extensions::APIPermissionSet; | 17 using extensions::APIPermissionSet; |
17 using extensions::Extension; | 18 using extensions::Extension; |
18 using extensions::Manifest; | 19 using extensions::Manifest; |
19 using extensions::PermissionMessage; | 20 using extensions::PermissionMessage; |
20 using extensions::PermissionMessages; | 21 using extensions::PermissionMessages; |
21 using extensions::PermissionSet; | 22 using extensions::PermissionSet; |
22 using extensions::URLPatternSet; | 23 using extensions::URLPatternSet; |
23 | 24 |
24 namespace apps { | 25 namespace apps { |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // TODO(jamescook): Refactor ChromeAPIPermissions to share some of the | |
29 // permissions registration for app_shell. For now, allow no permissions. | |
30 class ShellPermissionsProvider : public extensions::PermissionsProvider { | |
31 public: | |
32 ShellPermissionsProvider() {} | |
33 virtual ~ShellPermissionsProvider() {} | |
34 | |
35 virtual std::vector<APIPermissionInfo*> GetAllPermissions() const OVERRIDE { | |
36 return std::vector<APIPermissionInfo*>(); | |
37 } | |
38 | |
39 virtual std::vector<AliasInfo> GetAllAliases() const OVERRIDE { | |
40 return std::vector<AliasInfo>(); | |
41 } | |
42 | |
43 private: | |
44 DISALLOW_COPY_AND_ASSIGN(ShellPermissionsProvider); | |
45 }; | |
46 | |
47 // TODO(jamescook): Refactor ChromePermissionsMessageProvider so we can share | 29 // TODO(jamescook): Refactor ChromePermissionsMessageProvider so we can share |
48 // code. | 30 // code. |
49 class ShellPermissionMessageProvider | 31 class ShellPermissionMessageProvider |
50 : public extensions::PermissionMessageProvider { | 32 : public extensions::PermissionMessageProvider { |
51 public: | 33 public: |
52 ShellPermissionMessageProvider() {} | 34 ShellPermissionMessageProvider() {} |
53 virtual ~ShellPermissionMessageProvider() {} | 35 virtual ~ShellPermissionMessageProvider() {} |
54 | 36 |
55 // PermissionMessageProvider implementation. | 37 // PermissionMessageProvider implementation. |
56 virtual PermissionMessages GetPermissionMessages( | 38 virtual PermissionMessages GetPermissionMessages( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 76 |
95 void ShellExtensionsClient::Initialize() { | 77 void ShellExtensionsClient::Initialize() { |
96 extensions::RegisterCommonManifestHandlers(); | 78 extensions::RegisterCommonManifestHandlers(); |
97 extensions::ManifestHandler::FinalizeRegistration(); | 79 extensions::ManifestHandler::FinalizeRegistration(); |
98 | 80 |
99 // TODO(jamescook): Do we need to whitelist any extensions? | 81 // TODO(jamescook): Do we need to whitelist any extensions? |
100 } | 82 } |
101 | 83 |
102 const extensions::PermissionsProvider& | 84 const extensions::PermissionsProvider& |
103 ShellExtensionsClient::GetPermissionsProvider() const { | 85 ShellExtensionsClient::GetPermissionsProvider() const { |
104 NOTIMPLEMENTED(); | 86 // TODO(jamescook): app_shell needs a way to use a subset of the Chrome |
105 static ShellPermissionsProvider provider; | 87 // extension Features and Permissions. In particular, the lists of Features |
| 88 // (including API features, manifest features and permission features) are |
| 89 // listed in JSON files from c/c/e/api that are included into Chrome's |
| 90 // resources.pak (_api_features.json and _permission_features.json). The |
| 91 // PermissionsProvider must match the set of permissions used by the features |
| 92 // in those files. We either need to make app_shell (and hence the extensions |
| 93 // module) know about all possible permissions, or create a mechanism whereby |
| 94 // we can build our own JSON files with only a subset of the data. For now, |
| 95 // just provide all permissions Chrome knows about. Fixing this issue is |
| 96 // http://crbug.com/339301 |
| 97 static extensions::ChromeAPIPermissions provider; |
106 return provider; | 98 return provider; |
107 } | 99 } |
108 | 100 |
109 const extensions::PermissionMessageProvider& | 101 const extensions::PermissionMessageProvider& |
110 ShellExtensionsClient::GetPermissionMessageProvider() const { | 102 ShellExtensionsClient::GetPermissionMessageProvider() const { |
111 NOTIMPLEMENTED(); | 103 NOTIMPLEMENTED(); |
112 static ShellPermissionMessageProvider provider; | 104 static ShellPermissionMessageProvider provider; |
113 return provider; | 105 return provider; |
114 } | 106 } |
115 | 107 |
(...skipping 28 matching lines...) Expand all Loading... |
144 return URLPatternSet(); | 136 return URLPatternSet(); |
145 } | 137 } |
146 | 138 |
147 bool ShellExtensionsClient::IsScriptableURL(const GURL& url, | 139 bool ShellExtensionsClient::IsScriptableURL(const GURL& url, |
148 std::string* error) const { | 140 std::string* error) const { |
149 NOTIMPLEMENTED(); | 141 NOTIMPLEMENTED(); |
150 return true; | 142 return true; |
151 } | 143 } |
152 | 144 |
153 } // namespace apps | 145 } // namespace apps |
OLD | NEW |