Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / browser / browser_plugin / browser_plugin_embedder.h
blob721814f504fd19807159c2fa3c96040f80d8f526
1 // Copyright (c) 2012 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 // A BrowserPluginEmbedder handles messages coming from a BrowserPlugin's
6 // embedder that are not directed at any particular existing guest process.
7 // In the beginning, when a BrowserPlugin instance in the embedder renderer
8 // process requests an initial navigation, the WebContents for that renderer
9 // renderer creates a BrowserPluginEmbedder for itself. The
10 // BrowserPluginEmbedder, in turn, forwards the requests to a
11 // BrowserPluginGuestManager, which creates and manages the lifetime of the new
12 // guest.
14 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
15 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
17 #include "base/memory/weak_ptr.h"
18 #include "content/public/browser/web_contents.h"
19 #include "content/public/browser/web_contents_observer.h"
20 #include "third_party/WebKit/public/web/WebDragOperation.h"
22 struct BrowserPluginHostMsg_Attach_Params;
24 namespace content {
26 class BrowserPluginGuest;
27 class BrowserPluginGuestManager;
28 class RenderWidgetHostImpl;
29 struct NativeWebKeyboardEvent;
31 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver {
32 public:
33 ~BrowserPluginEmbedder() override;
35 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents);
37 // Called when embedder's |rwh| has sent screen rects to renderer.
38 void DidSendScreenRects();
40 // WebContentsObserver implementation.
41 bool OnMessageReceived(const IPC::Message& message) override;
42 bool OnMessageReceived(const IPC::Message& message,
43 RenderFrameHost* render_frame_host) override;
45 // Sends a 'dragend' message to the guest that started the drag.
46 void DragSourceEndedAt(int client_x, int client_y, int screen_x,
47 int screen_y, blink::WebDragOperation operation);
49 // Indicates that a drag operation has entered into the bounds of a given
50 // |guest|. Returns whether the |guest| also started the operation.
51 bool DragEnteredGuest(BrowserPluginGuest* guest);
53 // Indicates that a drag operation has left the bounds of a given |guest|.
54 void DragLeftGuest(BrowserPluginGuest* guest);
56 // Called when the screen info has changed.
57 void ScreenInfoChanged();
59 // Called by WebContentsViewGuest when a drag operation is started within
60 // |guest|. This |guest| will be signaled at the end of the drag operation.
61 void StartDrag(BrowserPluginGuest* guest);
63 // Sends EndSystemDrag message to the guest that initiated the last drag/drop
64 // operation, if there's any.
65 void SystemDragEnded();
67 // Used to handle special keyboard events.
68 bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
70 // Returns the "full page" guest if there is one. That is, if there is a
71 // single BrowserPlugin in the embedder which takes up the full page, then it
72 // is returned.
73 BrowserPluginGuest* GetFullPageGuest();
75 private:
76 explicit BrowserPluginEmbedder(WebContentsImpl* web_contents);
78 BrowserPluginGuestManager* GetBrowserPluginGuestManager() const;
80 void ClearGuestDragStateIfApplicable();
82 static bool DidSendScreenRectsCallback(WebContents* guest_web_contents);
84 // Notifies a guest that the embedder's screen info has changed.
85 static bool NotifyScreenInfoChanged(WebContents* guest_web_contents);
87 static bool UnlockMouseIfNecessaryCallback(bool* mouse_unlocked,
88 WebContents* guest);
90 // Message handlers.
92 void OnAttach(RenderFrameHost* render_frame_host,
93 int instance_id,
94 const BrowserPluginHostMsg_Attach_Params& params);
95 void OnUpdateDragCursor(bool* handled);
97 // Used to correctly update the cursor when dragging over a guest, and to
98 // handle a race condition when dropping onto the guest that started the drag
99 // (the race is that the dragend message arrives before the drop message so
100 // the drop never takes place).
101 // crbug.com/233571
102 base::WeakPtr<BrowserPluginGuest> guest_dragging_over_;
104 // Pointer to the guest that started the drag, used to forward necessary drag
105 // status messages to the correct guest.
106 base::WeakPtr<BrowserPluginGuest> guest_started_drag_;
108 // Keeps track of "dragend" state.
109 bool guest_drag_ending_;
111 base::WeakPtrFactory<BrowserPluginEmbedder> weak_ptr_factory_;
113 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
116 } // namespace content
118 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_