OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // A BrowserPluginEmbedder handles messages coming from a BrowserPlugin's | 5 // A BrowserPluginEmbedder handles messages coming from a BrowserPlugin's |
6 // embedder that are not directed at any particular existing guest process. | 6 // embedder that are not directed at any particular existing guest process. |
7 // In the beginning, when a BrowserPlugin instance in the embedder renderer | 7 // In the beginning, when a BrowserPlugin instance in the embedder renderer |
8 // process requests an initial navigation, the WebContents for that renderer | 8 // process requests an initial navigation, the WebContents for that renderer |
9 // renderer creates a BrowserPluginEmbedder for itself. The | 9 // renderer creates a BrowserPluginEmbedder for itself. The |
10 // BrowserPluginEmbedder, in turn, forwards the requests to a | 10 // BrowserPluginEmbedder, in turn, forwards the requests to a |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // |guest|. This |guest| will be signaled at the end of the drag operation. | 60 // |guest|. This |guest| will be signaled at the end of the drag operation. |
61 void StartDrag(BrowserPluginGuest* guest); | 61 void StartDrag(BrowserPluginGuest* guest); |
62 | 62 |
63 // Sends EndSystemDrag message to the guest that initiated the last drag/drop | 63 // Sends EndSystemDrag message to the guest that initiated the last drag/drop |
64 // operation, if there's any. | 64 // operation, if there's any. |
65 void SystemDragEnded(); | 65 void SystemDragEnded(); |
66 | 66 |
67 // Used to handle special keyboard events. | 67 // Used to handle special keyboard events. |
68 bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event); | 68 bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
69 | 69 |
70 // Find the given |search_text| in the page. Returns true if the find request | 70 // Returns the "full page" guest if there is one. That is, if there is a |
71 // is handled by this browser plugin embedder. | 71 // single BrowserPlugin in the embedder which takes up the full page, then it |
72 bool Find(int request_id, | 72 // is returned. |
73 const base::string16& search_text, | 73 BrowserPluginGuest* GetFullPageGuest(); |
74 const blink::WebFindOptions& options); | |
75 bool StopFinding(StopFindAction action); | |
76 | 74 |
77 private: | 75 private: |
78 explicit BrowserPluginEmbedder(WebContentsImpl* web_contents); | 76 explicit BrowserPluginEmbedder(WebContentsImpl* web_contents); |
79 | 77 |
80 BrowserPluginGuestManager* GetBrowserPluginGuestManager() const; | 78 BrowserPluginGuestManager* GetBrowserPluginGuestManager() const; |
81 | 79 |
82 void ClearGuestDragStateIfApplicable(); | 80 void ClearGuestDragStateIfApplicable(); |
83 | 81 |
84 static bool DidSendScreenRectsCallback(WebContents* guest_web_contents); | 82 static bool DidSendScreenRectsCallback(WebContents* guest_web_contents); |
85 | 83 |
86 // Notifies a guest that the embedder's screen info has changed. | 84 // Notifies a guest that the embedder's screen info has changed. |
87 static bool NotifyScreenInfoChanged(WebContents* guest_web_contents); | 85 static bool NotifyScreenInfoChanged(WebContents* guest_web_contents); |
88 | 86 |
89 static bool UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, | 87 static bool UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, |
90 WebContents* guest); | 88 WebContents* guest); |
91 | 89 |
92 static bool FindInGuest(int request_id, | |
93 const base::string16& search_text, | |
94 const blink::WebFindOptions& options, | |
95 WebContents* guest); | |
96 static bool StopFindingInGuest(StopFindAction action, WebContents* guest); | |
97 | |
98 // Message handlers. | 90 // Message handlers. |
99 | 91 |
100 void OnAttach(RenderFrameHost* render_frame_host, | 92 void OnAttach(RenderFrameHost* render_frame_host, |
101 int instance_id, | 93 int instance_id, |
102 const BrowserPluginHostMsg_Attach_Params& params); | 94 const BrowserPluginHostMsg_Attach_Params& params); |
103 void OnUpdateDragCursor(bool* handled); | 95 void OnUpdateDragCursor(bool* handled); |
104 | 96 |
105 // Used to correctly update the cursor when dragging over a guest, and to | 97 // Used to correctly update the cursor when dragging over a guest, and to |
106 // handle a race condition when dropping onto the guest that started the drag | 98 // handle a race condition when dropping onto the guest that started the drag |
107 // (the race is that the dragend message arrives before the drop message so | 99 // (the race is that the dragend message arrives before the drop message so |
108 // the drop never takes place). | 100 // the drop never takes place). |
109 // crbug.com/233571 | 101 // crbug.com/233571 |
110 base::WeakPtr<BrowserPluginGuest> guest_dragging_over_; | 102 base::WeakPtr<BrowserPluginGuest> guest_dragging_over_; |
111 | 103 |
112 // Pointer to the guest that started the drag, used to forward necessary drag | 104 // Pointer to the guest that started the drag, used to forward necessary drag |
113 // status messages to the correct guest. | 105 // status messages to the correct guest. |
114 base::WeakPtr<BrowserPluginGuest> guest_started_drag_; | 106 base::WeakPtr<BrowserPluginGuest> guest_started_drag_; |
115 | 107 |
116 // Keeps track of "dragend" state. | 108 // Keeps track of "dragend" state. |
117 bool guest_drag_ending_; | 109 bool guest_drag_ending_; |
118 | 110 |
119 base::WeakPtrFactory<BrowserPluginEmbedder> weak_ptr_factory_; | 111 base::WeakPtrFactory<BrowserPluginEmbedder> weak_ptr_factory_; |
120 | 112 |
121 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); | 113 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); |
122 }; | 114 }; |
123 | 115 |
124 } // namespace content | 116 } // namespace content |
125 | 117 |
126 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ | 118 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ |
OLD | NEW |