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