Process Alt-Svc headers.
[chromium-blink-merge.git] / content / browser / browser_plugin / browser_plugin_embedder.h
blob842d3ee1b03835fbf3dceb8b5fde44931cc32460
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 // Closes modal dialogs in all of the guests.
60 void CancelGuestDialogs();
62 // Called by WebContentsViewGuest when a drag operation is started within
63 // |guest|. This |guest| will be signaled at the end of the drag operation.
64 void StartDrag(BrowserPluginGuest* guest);
66 // Sends EndSystemDrag message to the guest that initiated the last drag/drop
67 // operation, if there's any.
68 void SystemDragEnded();
70 // Used to handle special keyboard events.
71 bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
73 // Returns the "full page" guest if there is one. That is, if there is a
74 // single BrowserPlugin in the embedder which takes up the full page, then it
75 // is returned.
76 BrowserPluginGuest* GetFullPageGuest();
78 private:
79 explicit BrowserPluginEmbedder(WebContentsImpl* web_contents);
81 BrowserPluginGuestManager* GetBrowserPluginGuestManager() const;
83 void ClearGuestDragStateIfApplicable();
85 static bool DidSendScreenRectsCallback(WebContents* guest_web_contents);
87 // Notifies a guest that the embedder's screen info has changed.
88 static bool NotifyScreenInfoChanged(WebContents* guest_web_contents);
90 // Closes modal dialogs in |guest_web_contents|.
91 static bool CancelDialogs(WebContents* guest_web_contents);
93 static bool UnlockMouseIfNecessaryCallback(bool* mouse_unlocked,
94 WebContents* guest);
96 // Message handlers.
98 void OnAttach(RenderFrameHost* render_frame_host,
99 int instance_id,
100 const BrowserPluginHostMsg_Attach_Params& params);
101 void OnUpdateDragCursor(bool* handled);
103 // Used to correctly update the cursor when dragging over a guest, and to
104 // handle a race condition when dropping onto the guest that started the drag
105 // (the race is that the dragend message arrives before the drop message so
106 // the drop never takes place).
107 // crbug.com/233571
108 base::WeakPtr<BrowserPluginGuest> guest_dragging_over_;
110 // Pointer to the guest that started the drag, used to forward necessary drag
111 // status messages to the correct guest.
112 base::WeakPtr<BrowserPluginGuest> guest_started_drag_;
114 // Keeps track of "dragend" state.
115 bool guest_drag_ending_;
117 base::WeakPtrFactory<BrowserPluginEmbedder> weak_ptr_factory_;
119 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
122 } // namespace content
124 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_