guest_view_manager_delegate.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2015 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 COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_DELEGATE_H_
  5. #define COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_DELEGATE_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/values.h"
  9. namespace base {
  10. class DictionaryValue;
  11. } // namespace base
  12. namespace content {
  13. class WebContents;
  14. } // namespace content
  15. namespace guest_view {
  16. class GuestViewBase;
  17. class GuestViewManager;
  18. // A GuestViewManagerDelegate interface allows GuestViewManager to delegate
  19. // responsibilities to other modules in Chromium. Different builds of Chromium
  20. // may use different GuestViewManagerDelegate implementations. For example,
  21. // mobile builds of Chromium do not include an extensions module and so
  22. // permission checks would be different, and IsOwnedByExtension would always
  23. // return false.
  24. class GuestViewManagerDelegate {
  25. public:
  26. GuestViewManagerDelegate();
  27. virtual ~GuestViewManagerDelegate();
  28. // Invoked after |guest_web_contents| is added.
  29. virtual void OnGuestAdded(content::WebContents* guest_web_contents) const {}
  30. // Dispatches the event with |name| with the provided |args| to the embedder
  31. // of the given |guest| with |instance_id| for routing.
  32. virtual void DispatchEvent(const std::string& event_name,
  33. std::unique_ptr<base::DictionaryValue> args,
  34. GuestViewBase* guest,
  35. int instance_id) {}
  36. // Indicates whether the |guest| can be used within the context of where it
  37. // was created.
  38. virtual bool IsGuestAvailableToContext(GuestViewBase* guest);
  39. // Indicates whether the |guest| is owned by an extension or Chrome App.
  40. virtual bool IsOwnedByExtension(GuestViewBase* guest);
  41. // Registers additional GuestView types the delegator (GuestViewManger) can
  42. // create.
  43. virtual void RegisterAdditionalGuestViewTypes(GuestViewManager* manager) {}
  44. };
  45. } // namespace guest_view
  46. #endif // COMPONENTS_GUEST_VIEW_BROWSER_GUEST_VIEW_MANAGER_DELEGATE_H_