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

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

Issue 16256018: Update content/ to use WeakPtr<T>::get() instead of implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix incorrectly modified code Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_guest.h » ('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 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
6 6
7 #include "content/browser/browser_plugin/browser_plugin_guest.h" 7 #include "content/browser/browser_plugin/browser_plugin_guest.h"
8 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h" 8 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h"
9 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 9 #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
(...skipping 30 matching lines...) Expand all
41 return new BrowserPluginEmbedder(web_contents); 41 return new BrowserPluginEmbedder(web_contents);
42 } 42 }
43 43
44 void BrowserPluginEmbedder::DragEnteredGuest(BrowserPluginGuest* guest) { 44 void BrowserPluginEmbedder::DragEnteredGuest(BrowserPluginGuest* guest) {
45 guest_dragging_over_ = guest->AsWeakPtr(); 45 guest_dragging_over_ = guest->AsWeakPtr();
46 } 46 }
47 47
48 void BrowserPluginEmbedder::DragLeftGuest(BrowserPluginGuest* guest) { 48 void BrowserPluginEmbedder::DragLeftGuest(BrowserPluginGuest* guest) {
49 // Avoid race conditions in switching between guests being hovered over by 49 // Avoid race conditions in switching between guests being hovered over by
50 // only un-setting if the caller is marked as the guest being dragged over. 50 // only un-setting if the caller is marked as the guest being dragged over.
51 if (guest_dragging_over_ == guest) { 51 if (guest_dragging_over_.get() == guest) {
52 guest_dragging_over_.reset(); 52 guest_dragging_over_.reset();
53 } 53 }
54 } 54 }
55 55
56 void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) { 56 void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) {
57 guest_started_drag_ = guest->AsWeakPtr(); 57 guest_started_drag_ = guest->AsWeakPtr();
58 } 58 }
59 59
60 void BrowserPluginEmbedder::StopDrag(BrowserPluginGuest* guest) { 60 void BrowserPluginEmbedder::StopDrag(BrowserPluginGuest* guest) {
61 if (guest_started_drag_ == guest) { 61 if (guest_started_drag_.get() == guest) {
62 guest_started_drag_.reset(); 62 guest_started_drag_.reset();
63 } 63 }
64 } 64 }
65 65
66 void BrowserPluginEmbedder::GetRenderViewHostAtPosition( 66 void BrowserPluginEmbedder::GetRenderViewHostAtPosition(
67 int x, int y, const WebContents::GetRenderViewHostCallback& callback) { 67 int x, int y, const WebContents::GetRenderViewHostCallback& callback) {
68 // Store the callback so we can call it later when we have the response. 68 // Store the callback so we can call it later when we have the response.
69 pending_get_render_view_callbacks_.insert( 69 pending_get_render_view_callbacks_.insert(
70 std::make_pair(next_get_render_view_request_id_, callback)); 70 std::make_pair(next_get_render_view_request_id_, callback));
71 Send(new BrowserPluginMsg_PluginAtPositionRequest( 71 Send(new BrowserPluginMsg_PluginAtPositionRequest(
(...skipping 21 matching lines...) Expand all
93 OnPluginAtPositionResponse) 93 OnPluginAtPositionResponse)
94 IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_UpdateDragCursor, 94 IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_UpdateDragCursor,
95 OnUpdateDragCursor(&handled)); 95 OnUpdateDragCursor(&handled));
96 IPC_MESSAGE_UNHANDLED(handled = false) 96 IPC_MESSAGE_UNHANDLED(handled = false)
97 IPC_END_MESSAGE_MAP() 97 IPC_END_MESSAGE_MAP()
98 return handled; 98 return handled;
99 } 99 }
100 100
101 void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y, 101 void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y,
102 int screen_x, int screen_y, WebKit::WebDragOperation operation) { 102 int screen_x, int screen_y, WebKit::WebDragOperation operation) {
103 if (guest_started_drag_) { 103 if (guest_started_drag_.get()) {
104 gfx::Point guest_offset = 104 gfx::Point guest_offset =
105 guest_started_drag_->GetScreenCoordinates(gfx::Point()); 105 guest_started_drag_->GetScreenCoordinates(gfx::Point());
106 guest_started_drag_->DragSourceEndedAt(client_x - guest_offset.x(), 106 guest_started_drag_->DragSourceEndedAt(client_x - guest_offset.x(),
107 client_y - guest_offset.y(), screen_x, screen_y, operation); 107 client_y - guest_offset.y(), screen_x, screen_y, operation);
108 } 108 }
109 } 109 }
110 110
111 void BrowserPluginEmbedder::DragSourceMovedTo(int client_x, int client_y, 111 void BrowserPluginEmbedder::DragSourceMovedTo(int client_x, int client_y,
112 int screen_x, int screen_y) { 112 int screen_x, int screen_y) {
113 if (guest_started_drag_) { 113 if (guest_started_drag_.get()) {
114 gfx::Point guest_offset = 114 gfx::Point guest_offset =
115 guest_started_drag_->GetScreenCoordinates(gfx::Point()); 115 guest_started_drag_->GetScreenCoordinates(gfx::Point());
116 guest_started_drag_->DragSourceMovedTo(client_x - guest_offset.x(), 116 guest_started_drag_->DragSourceMovedTo(client_x - guest_offset.x(),
117 client_y - guest_offset.y(), screen_x, screen_y); 117 client_y - guest_offset.y(), screen_x, screen_y);
118 } 118 }
119 } 119 }
120 120
121 void BrowserPluginEmbedder::SystemDragEnded() { 121 void BrowserPluginEmbedder::SystemDragEnded() {
122 if (guest_started_drag_ && (guest_started_drag_ != guest_dragging_over_)) 122 if (guest_started_drag_.get() &&
123 (guest_started_drag_.get() != guest_dragging_over_.get()))
123 guest_started_drag_->EndSystemDrag(); 124 guest_started_drag_->EndSystemDrag();
124 guest_started_drag_.reset(); 125 guest_started_drag_.reset();
125 guest_dragging_over_.reset(); 126 guest_dragging_over_.reset();
126 } 127 }
127 128
128 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { 129 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) {
129 *handled = (guest_dragging_over_ != NULL); 130 *handled = (guest_dragging_over_.get() != NULL);
130 } 131 }
131 132
132 void BrowserPluginEmbedder::CleanUp() { 133 void BrowserPluginEmbedder::CleanUp() {
133 // CleanUp gets called when BrowserPluginEmbedder's WebContents goes away 134 // CleanUp gets called when BrowserPluginEmbedder's WebContents goes away
134 // or the associated RenderViewHost is destroyed or swapped out. Therefore we 135 // or the associated RenderViewHost is destroyed or swapped out. Therefore we
135 // don't need to care about the pending callbacks anymore. 136 // don't need to care about the pending callbacks anymore.
136 pending_get_render_view_callbacks_.clear(); 137 pending_get_render_view_callbacks_.clear();
137 } 138 }
138 139
139 BrowserPluginGuestManager* 140 BrowserPluginGuestManager*
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (guest) 194 if (guest)
194 render_view_host = guest->GetWebContents()->GetRenderViewHost(); 195 render_view_host = guest->GetWebContents()->GetRenderViewHost();
195 else // No plugin, use embedder's RenderViewHost. 196 else // No plugin, use embedder's RenderViewHost.
196 render_view_host = web_contents()->GetRenderViewHost(); 197 render_view_host = web_contents()->GetRenderViewHost();
197 198
198 callback_iter->second.Run(render_view_host, position.x(), position.y()); 199 callback_iter->second.Run(render_view_host, position.x(), position.y());
199 pending_get_render_view_callbacks_.erase(callback_iter); 200 pending_get_render_view_callbacks_.erase(callback_iter);
200 } 201 }
201 202
202 } // namespace content 203 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698