supervised_user_extensions_delegate.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2020 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. #ifndef EXTENSIONS_BROWSER_SUPERVISED_USER_EXTENSIONS_DELEGATE_H_
  5. #define EXTENSIONS_BROWSER_SUPERVISED_USER_EXTENSIONS_DELEGATE_H_
  6. #include "base/callback.h"
  7. #include "extensions/common/extension.h"
  8. namespace content {
  9. class BrowserContext;
  10. class WebContents;
  11. } // namespace content
  12. namespace extensions {
  13. class SupervisedUserExtensionsDelegate {
  14. public:
  15. // Result of the parent permission dialog invocation.
  16. enum class ParentPermissionDialogResult {
  17. kParentPermissionReceived,
  18. kParentPermissionCanceled,
  19. kParentPermissionFailed,
  20. };
  21. using ParentPermissionDialogDoneCallback =
  22. base::OnceCallback<void(ParentPermissionDialogResult)>;
  23. virtual ~SupervisedUserExtensionsDelegate() = default;
  24. // Returns true if |context| represents a supervised child account.
  25. virtual bool IsChild(content::BrowserContext* context) const = 0;
  26. // Returns true if the parent has already approved the |extension|.
  27. virtual bool IsExtensionAllowedByParent(
  28. const extensions::Extension& extension,
  29. content::BrowserContext* context) const = 0;
  30. // If the current user is a child, the child user has a custodian/parent, and
  31. // the parent has enabled the "Permissions for sites, apps and extensions"
  32. // toggle, then display the Parent Permission Dialog and call
  33. // |parent_permission_callback|. Otherwise, display the Extension Install
  34. // Blocked by Parent Dialog and call |error_callback|. The two paths are
  35. // mutually exclusive.
  36. virtual void PromptForParentPermissionOrShowError(
  37. const extensions::Extension& extension,
  38. content::BrowserContext* browser_context,
  39. content::WebContents* web_contents,
  40. ParentPermissionDialogDoneCallback parent_permission_callback,
  41. base::OnceClosure error_callback) = 0;
  42. };
  43. } // namespace extensions
  44. #endif // EXTENSIONS_BROWSER_SUPERVISED_USER_EXTENSIONS_DELEGATE_H_