| 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 #ifndef CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_ | 6 #define CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" | 11 #include "chrome/common/extensions/permissions/chrome_api_permissions.h" |
| 12 #include "chrome/common/extensions/permissions/chrome_permission_message_provide
r.h" | 12 #include "chrome/common/extensions/permissions/chrome_permission_message_provide
r.h" |
| 13 #include "extensions/common/extensions_client.h" | 13 #include "extensions/common/extensions_client.h" |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 | 16 |
| 17 // The implementation of ExtensionsClient for Chrome, which encapsulates the | 17 // The implementation of ExtensionsClient for Chrome, which encapsulates the |
| 18 // global knowledge of features, permissions, and manifest fields. | 18 // global knowledge of features, permissions, and manifest fields. |
| 19 class ChromeExtensionsClient : public ExtensionsClient { | 19 class ChromeExtensionsClient : public ExtensionsClient { |
| 20 public: | 20 public: |
| 21 ChromeExtensionsClient(); | 21 ChromeExtensionsClient(); |
| 22 virtual ~ChromeExtensionsClient(); | 22 virtual ~ChromeExtensionsClient(); |
| 23 | 23 |
| 24 virtual void Initialize() OVERRIDE; | 24 virtual void Initialize() OVERRIDE; |
| 25 | 25 |
| 26 virtual const PermissionsProvider& GetPermissionsProvider() const OVERRIDE; | 26 virtual const PermissionsProvider& GetPermissionsProvider() const OVERRIDE; |
| 27 virtual const PermissionMessageProvider& GetPermissionMessageProvider() const | 27 virtual const PermissionMessageProvider& GetPermissionMessageProvider() const |
| 28 OVERRIDE; | 28 OVERRIDE; |
| 29 virtual FeatureProvider* GetFeatureProviderByName(const std::string& name) | 29 virtual scoped_ptr<FeatureProvider> CreateFeatureProvider( |
| 30 const OVERRIDE; | 30 const std::string& name) const OVERRIDE; |
| 31 virtual void FilterHostPermissions( | 31 virtual void FilterHostPermissions( |
| 32 const URLPatternSet& hosts, | 32 const URLPatternSet& hosts, |
| 33 URLPatternSet* new_hosts, | 33 URLPatternSet* new_hosts, |
| 34 std::set<PermissionMessage>* messages) const OVERRIDE; | 34 std::set<PermissionMessage>* messages) const OVERRIDE; |
| 35 virtual void SetScriptingWhitelist(const ScriptingWhitelist& whitelist) | 35 virtual void SetScriptingWhitelist(const ScriptingWhitelist& whitelist) |
| 36 OVERRIDE; | 36 OVERRIDE; |
| 37 virtual const ScriptingWhitelist& GetScriptingWhitelist() const OVERRIDE; | 37 virtual const ScriptingWhitelist& GetScriptingWhitelist() const OVERRIDE; |
| 38 virtual URLPatternSet GetPermittedChromeSchemeHosts( | 38 virtual URLPatternSet GetPermittedChromeSchemeHosts( |
| 39 const Extension* extension, | 39 const Extension* extension, |
| 40 const APIPermissionSet& api_permissions) const OVERRIDE; | 40 const APIPermissionSet& api_permissions) const OVERRIDE; |
| 41 virtual bool IsScriptableURL(const GURL& url, std::string* error) const | 41 virtual bool IsScriptableURL(const GURL& url, std::string* error) const |
| 42 OVERRIDE; | 42 OVERRIDE; |
| 43 virtual bool IsAPISchemaGenerated(const std::string& name) const OVERRIDE; | 43 virtual bool IsAPISchemaGenerated(const std::string& name) const OVERRIDE; |
| 44 virtual base::StringPiece GetAPISchema(const std::string& name) const | 44 virtual base::StringPiece GetAPISchema(const std::string& name) const |
| 45 OVERRIDE; | 45 OVERRIDE; |
| 46 virtual void AddExtraFeatureFilters(SimpleFeature* feature) const OVERRIDE; | |
| 47 virtual bool ShouldSuppressFatalErrors() const OVERRIDE; | 46 virtual bool ShouldSuppressFatalErrors() const OVERRIDE; |
| 48 | 47 |
| 49 // Get the LazyInstance for ChromeExtensionsClient. | 48 // Get the LazyInstance for ChromeExtensionsClient. |
| 50 static ChromeExtensionsClient* GetInstance(); | 49 static ChromeExtensionsClient* GetInstance(); |
| 51 | 50 |
| 52 private: | 51 private: |
| 53 const ChromeAPIPermissions chrome_api_permissions_; | 52 const ChromeAPIPermissions chrome_api_permissions_; |
| 54 const ChromePermissionMessageProvider permission_message_provider_; | 53 const ChromePermissionMessageProvider permission_message_provider_; |
| 55 | 54 |
| 56 // A whitelist of extensions that can script anywhere. Do not add to this | 55 // A whitelist of extensions that can script anywhere. Do not add to this |
| 57 // list (except in tests) without consulting the Extensions team first. | 56 // list (except in tests) without consulting the Extensions team first. |
| 58 // Note: Component extensions have this right implicitly and do not need to be | 57 // Note: Component extensions have this right implicitly and do not need to be |
| 59 // added to this list. | 58 // added to this list. |
| 60 ScriptingWhitelist scripting_whitelist_; | 59 ScriptingWhitelist scripting_whitelist_; |
| 61 | 60 |
| 62 friend struct base::DefaultLazyInstanceTraits<ChromeExtensionsClient>; | 61 friend struct base::DefaultLazyInstanceTraits<ChromeExtensionsClient>; |
| 63 | 62 |
| 64 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsClient); | 63 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsClient); |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 } // namespace extensions | 66 } // namespace extensions |
| 68 | 67 |
| 69 #endif // CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_ | 68 #endif // CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_ |
| OLD | NEW |