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.
5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
8 #include "base/callback_forward.h"
9 #include "base/process/kill.h"
10 #include "content/common/content_export.h"
11 #include "content/public/browser/web_contents.h"
14 class DictionaryValue
;
25 // Objects implement this interface to get notified about changes in the guest
26 // WebContents and to provide necessary functionality.
27 class CONTENT_EXPORT BrowserPluginGuestDelegate
{
29 virtual ~BrowserPluginGuestDelegate() {}
31 // Notification that the embedder will begin attachment. This is called
32 // prior to resuming resource loads. |element_instance_id| uniquely identifies
33 // the element that will serve as a container for the guest.
34 virtual void WillAttach(content::WebContents
* embedder_web_contents
,
35 int element_instance_id
,
36 bool is_full_page_plugin
) {}
38 virtual WebContents
* CreateNewGuestWindow(
39 const WebContents::CreateParams
& create_params
);
41 // Asks the delegate whether this guest can run while detached from a
42 // container. A detached guest is a WebContents that has no visual surface
43 // into which it can composite its content. Detached guests can be thought
44 // of as workers with a DOM.
45 virtual bool CanRunInDetachedState() const;
47 // Notification that the embedder has completed attachment. The
48 // |guest_proxy_routing_id| is the routing ID for the RenderView in the
49 // embedder that will serve as a contentWindow proxy for the guest.
50 virtual void DidAttach(int guest_proxy_routing_id
) {}
52 // Notification that the guest has detached from its container.
53 virtual void DidDetach() {}
55 // Notification that a valid |url| was dropped over the guest.
56 virtual void DidDropLink(const GURL
& url
) {}
58 // Notification that the BrowserPlugin has resized.
59 virtual void ElementSizeChanged(const gfx::Size
& size
) {}
61 // Returns the WebContents that currently owns this guest.
62 virtual WebContents
* GetOwnerWebContents() const;
64 // Notifies that the content size of the guest has changed.
65 // Note: In autosize mode, it is possible that the guest size may not match
67 virtual void GuestSizeChanged(const gfx::Size
& new_size
) {}
69 // Asks the delegate if the given guest can lock the pointer.
70 // Invoking the |callback| synchronously is OK.
71 virtual void RequestPointerLockPermission(
73 bool last_unlocked_by_target
,
74 const base::Callback
<void(bool)>& callback
) {}
76 // Find the given |search_text| in the page. Returns true if the find request
77 // is handled by this browser plugin guest delegate.
78 virtual bool Find(int request_id
,
79 const base::string16
& search_text
,
80 const blink::WebFindOptions
& options
);
81 virtual bool StopFinding(StopFindAction action
);
83 // Provides the delegate with an interface with which to communicate with the
85 virtual void SetGuestHost(GuestHost
* guest_host
) {}
88 } // namespace content
90 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_