Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_embedder.h

Issue 12086095: Fixed drag and drop into and out of Browser Plugin. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Splitting up patch Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_embedder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 // BrowserPluginGuestManager, which creates and manages the lifetime of the new 11 // BrowserPluginGuestManager, which creates and manages the lifetime of the new
12 // guest. 12 // guest.
13 13
14 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ 14 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
15 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ 15 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
16 16
17 #include <map> 17 #include <map>
18 18
19 #include "base/memory/weak_ptr.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_observer.h" 21 #include "content/public/browser/web_contents_observer.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
21 23
22 struct BrowserPluginHostMsg_Attach_Params; 24 struct BrowserPluginHostMsg_Attach_Params;
23 struct BrowserPluginHostMsg_ResizeGuest_Params; 25 struct BrowserPluginHostMsg_ResizeGuest_Params;
24 26
25 namespace gfx { 27 namespace gfx {
26 class Point; 28 class Point;
27 } 29 }
28 30
29 namespace content { 31 namespace content {
30 32
33 class BrowserPluginGuest;
31 class BrowserPluginGuestManager; 34 class BrowserPluginGuestManager;
32 class BrowserPluginHostFactory; 35 class BrowserPluginHostFactory;
33 class WebContentsImpl; 36 class WebContentsImpl;
34 37
35 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver { 38 class CONTENT_EXPORT BrowserPluginEmbedder : public WebContentsObserver {
36 public: 39 public:
37 virtual ~BrowserPluginEmbedder(); 40 virtual ~BrowserPluginEmbedder();
38 41
39 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents); 42 static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents);
40 43
41 // Returns the RenderViewHost at a point (|x|, |y|) asynchronously via 44 // Returns the RenderViewHost at a point (|x|, |y|) asynchronously via
42 // |callback|. We need a roundtrip to renderer process to get this 45 // |callback|. We need a roundtrip to renderer process to get this
43 // information. 46 // information.
44 void GetRenderViewHostAtPosition( 47 void GetRenderViewHostAtPosition(
45 int x, 48 int x,
46 int y, 49 int y,
47 const WebContents::GetRenderViewHostCallback& callback); 50 const WebContents::GetRenderViewHostCallback& callback);
48 51
49 // Overrides factory for testing. Default (NULL) value indicates regular 52 // Overrides factory for testing. Default (NULL) value indicates regular
50 // (non-test) environment. 53 // (non-test) environment.
51 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { 54 static void set_factory_for_testing(BrowserPluginHostFactory* factory) {
52 factory_ = factory; 55 factory_ = factory;
53 } 56 }
54 57
55 // WebContentsObserver implementation. 58 // WebContentsObserver implementation.
56 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 59 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 60 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
58 61
62 void DragSourceEndedAt(int client_x, int client_y, int screen_x,
63 int screen_y, WebKit::WebDragOperation operation);
64
65 void DragSourceMovedTo(int client_x, int client_y,
66 int screen_x, int screen_y);
67
68 void OnUpdateDragCursor(bool* handled);
69
70 void DragEnteredGuest(BrowserPluginGuest* guest);
71
72 void DragLeftGuest(BrowserPluginGuest* guest);
73
74 void StartDrag(BrowserPluginGuest* guest);
75
76 void StopDrag(BrowserPluginGuest* guest);
77
78 void SystemDragEnded();
79
59 private: 80 private:
60 friend class TestBrowserPluginEmbedder; 81 friend class TestBrowserPluginEmbedder;
61 82
62 BrowserPluginEmbedder(WebContentsImpl* web_contents); 83 BrowserPluginEmbedder(WebContentsImpl* web_contents);
63 84
64 void CleanUp(); 85 void CleanUp();
65 86
66 BrowserPluginGuestManager* GetBrowserPluginGuestManager(); 87 BrowserPluginGuestManager* GetBrowserPluginGuestManager();
67 88
68 // Message handlers. 89 // Message handlers.
(...skipping 10 matching lines...) Expand all
79 100
80 // Map that contains outstanding queries to |GetRenderViewHostAtPosition|. 101 // Map that contains outstanding queries to |GetRenderViewHostAtPosition|.
81 // We need a roundtrip to the renderer process to retrieve the answer, 102 // We need a roundtrip to the renderer process to retrieve the answer,
82 // so we store these callbacks until we hear back from the renderer. 103 // so we store these callbacks until we hear back from the renderer.
83 typedef std::map<int, WebContents::GetRenderViewHostCallback> 104 typedef std::map<int, WebContents::GetRenderViewHostCallback>
84 GetRenderViewHostCallbackMap; 105 GetRenderViewHostCallbackMap;
85 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_; 106 GetRenderViewHostCallbackMap pending_get_render_view_callbacks_;
86 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query. 107 // Next request id for BrowserPluginMsg_PluginAtPositionRequest query.
87 int next_get_render_view_request_id_; 108 int next_get_render_view_request_id_;
88 109
110 // Used to correctly update the cursor when dragging over a guest, and to
111 // handle a race condition when dropping onto the guest that started the drag
112 // (the race is that the dragend message arrives before the drop message so
113 // the drop never takes place).
114 // crbug.com/233571
115 base::WeakPtr<BrowserPluginGuest> guest_dragging_over_;
116
117 // Pointer to the guest that started the drag, used to forward necessary drag
118 // status messages to the correct guest.
119 base::WeakPtr<BrowserPluginGuest> guest_started_drag_;
120
89 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder); 121 DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
90 }; 122 };
91 123
92 } // namespace content 124 } // namespace content
93 125
94 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_ 126 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698