| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "apps/shell/shell_extensions_client.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "chrome/common/extensions/features/base_feature_provider.h" | |
| 9 #include "extensions/common/common_manifest_handlers.h" | |
| 10 #include "extensions/common/manifest_handler.h" | |
| 11 #include "extensions/common/permissions/permission_message_provider.h" | |
| 12 #include "extensions/common/permissions/permissions_provider.h" | |
| 13 #include "extensions/common/url_pattern_set.h" | |
| 14 | |
| 15 using extensions::APIPermissionInfo; | |
| 16 using extensions::APIPermissionSet; | |
| 17 using extensions::Extension; | |
| 18 using extensions::Manifest; | |
| 19 using extensions::PermissionMessage; | |
| 20 using extensions::PermissionMessages; | |
| 21 using extensions::PermissionSet; | |
| 22 using extensions::URLPatternSet; | |
| 23 | |
| 24 namespace apps { | |
| 25 | |
| 26 namespace { | |
| 27 | |
| 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 | |
| 48 // code. | |
| 49 class ShellPermissionMessageProvider | |
| 50 : public extensions::PermissionMessageProvider { | |
| 51 public: | |
| 52 ShellPermissionMessageProvider() {} | |
| 53 virtual ~ShellPermissionMessageProvider() {} | |
| 54 | |
| 55 // PermissionMessageProvider implementation. | |
| 56 virtual PermissionMessages GetPermissionMessages( | |
| 57 const PermissionSet* permissions, | |
| 58 Manifest::Type extension_type) const OVERRIDE { | |
| 59 return PermissionMessages(); | |
| 60 } | |
| 61 | |
| 62 virtual std::vector<base::string16> GetWarningMessages( | |
| 63 const PermissionSet* permissions, | |
| 64 Manifest::Type extension_type) const OVERRIDE { | |
| 65 return std::vector<base::string16>(); | |
| 66 } | |
| 67 | |
| 68 virtual std::vector<base::string16> GetWarningMessagesDetails( | |
| 69 const PermissionSet* permissions, | |
| 70 Manifest::Type extension_type) const OVERRIDE { | |
| 71 return std::vector<base::string16>(); | |
| 72 } | |
| 73 | |
| 74 virtual bool IsPrivilegeIncrease( | |
| 75 const PermissionSet* old_permissions, | |
| 76 const PermissionSet* new_permissions, | |
| 77 Manifest::Type extension_type) const OVERRIDE { | |
| 78 // Ensure we implement this before shipping. | |
| 79 CHECK(false); | |
| 80 return false; | |
| 81 } | |
| 82 | |
| 83 private: | |
| 84 DISALLOW_COPY_AND_ASSIGN(ShellPermissionMessageProvider); | |
| 85 }; | |
| 86 | |
| 87 } // namespace | |
| 88 | |
| 89 ShellExtensionsClient::ShellExtensionsClient() { | |
| 90 } | |
| 91 | |
| 92 ShellExtensionsClient::~ShellExtensionsClient() { | |
| 93 } | |
| 94 | |
| 95 void ShellExtensionsClient::Initialize() { | |
| 96 extensions::RegisterCommonManifestHandlers(); | |
| 97 extensions::ManifestHandler::FinalizeRegistration(); | |
| 98 | |
| 99 // TODO(jamescook): Do we need to whitelist any extensions? | |
| 100 } | |
| 101 | |
| 102 const extensions::PermissionsProvider& | |
| 103 ShellExtensionsClient::GetPermissionsProvider() const { | |
| 104 NOTIMPLEMENTED(); | |
| 105 static ShellPermissionsProvider provider; | |
| 106 return provider; | |
| 107 } | |
| 108 | |
| 109 const extensions::PermissionMessageProvider& | |
| 110 ShellExtensionsClient::GetPermissionMessageProvider() const { | |
| 111 NOTIMPLEMENTED(); | |
| 112 static ShellPermissionMessageProvider provider; | |
| 113 return provider; | |
| 114 } | |
| 115 | |
| 116 extensions::FeatureProvider* ShellExtensionsClient::GetFeatureProviderByName( | |
| 117 const std::string& name) const { | |
| 118 // TODO(jamescook): Factor out an extensions module feature provider. | |
| 119 return extensions::BaseFeatureProvider::GetByName(name); | |
| 120 } | |
| 121 | |
| 122 void ShellExtensionsClient::FilterHostPermissions( | |
| 123 const URLPatternSet& hosts, | |
| 124 URLPatternSet* new_hosts, | |
| 125 std::set<PermissionMessage>* messages) const { | |
| 126 NOTIMPLEMENTED(); | |
| 127 } | |
| 128 | |
| 129 void ShellExtensionsClient::SetScriptingWhitelist( | |
| 130 const ScriptingWhitelist& whitelist) { | |
| 131 scripting_whitelist_ = whitelist; | |
| 132 } | |
| 133 | |
| 134 const extensions::ExtensionsClient::ScriptingWhitelist& | |
| 135 ShellExtensionsClient::GetScriptingWhitelist() const { | |
| 136 // TODO(jamescook): Real whitelist. | |
| 137 return scripting_whitelist_; | |
| 138 } | |
| 139 | |
| 140 URLPatternSet ShellExtensionsClient::GetPermittedChromeSchemeHosts( | |
| 141 const Extension* extension, | |
| 142 const APIPermissionSet& api_permissions) const { | |
| 143 NOTIMPLEMENTED(); | |
| 144 return URLPatternSet(); | |
| 145 } | |
| 146 | |
| 147 bool ShellExtensionsClient::IsScriptableURL(const GURL& url, | |
| 148 std::string* error) const { | |
| 149 NOTIMPLEMENTED(); | |
| 150 return true; | |
| 151 } | |
| 152 | |
| 153 } // namespace apps | |
| OLD | NEW |