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

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

Issue 299753011: Move allocate instance id to chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more comments addressed Created 6 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
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 "base/values.h" 7 #include "base/values.h"
8 #include "content/browser/browser_plugin/browser_plugin_guest.h" 8 #include "content/browser/browser_plugin/browser_plugin_guest.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/renderer_host/render_view_host_impl.h" 10 #include "content/browser/renderer_host/render_view_host_impl.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 void BrowserPluginEmbedder::DidSendScreenRects() { 82 void BrowserPluginEmbedder::DidSendScreenRects() {
83 GetBrowserPluginGuestManager()->ForEachGuest( 83 GetBrowserPluginGuestManager()->ForEachGuest(
84 GetWebContents(), base::Bind( 84 GetWebContents(), base::Bind(
85 &BrowserPluginEmbedder::DidSendScreenRectsCallback, 85 &BrowserPluginEmbedder::DidSendScreenRectsCallback,
86 base::Unretained(this))); 86 base::Unretained(this)));
87 } 87 }
88 88
89 bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) { 89 bool BrowserPluginEmbedder::OnMessageReceived(const IPC::Message& message) {
90 bool handled = true; 90 bool handled = true;
91 IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedder, message) 91 IPC_BEGIN_MESSAGE_MAP(BrowserPluginEmbedder, message)
92 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_AllocateInstanceID,
93 OnAllocateInstanceID)
94 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Attach, OnAttach) 92 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Attach, OnAttach)
95 IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_UpdateDragCursor, 93 IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_UpdateDragCursor,
96 OnUpdateDragCursor(&handled)); 94 OnUpdateDragCursor(&handled));
97 IPC_MESSAGE_UNHANDLED(handled = false) 95 IPC_MESSAGE_UNHANDLED(handled = false)
98 IPC_END_MESSAGE_MAP() 96 IPC_END_MESSAGE_MAP()
99 return handled; 97 return handled;
100 } 98 }
101 99
102 void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y, 100 void BrowserPluginEmbedder::DragSourceEndedAt(int client_x, int client_y,
103 int screen_x, int screen_y, blink::WebDragOperation operation) { 101 int screen_x, int screen_y, blink::WebDragOperation operation) {
(...skipping 12 matching lines...) Expand all
116 if (guest_started_drag_.get()) 114 if (guest_started_drag_.get())
117 guest_started_drag_->EndSystemDrag(); 115 guest_started_drag_->EndSystemDrag();
118 guest_started_drag_.reset(); 116 guest_started_drag_.reset();
119 guest_dragging_over_.reset(); 117 guest_dragging_over_.reset();
120 } 118 }
121 119
122 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { 120 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) {
123 *handled = (guest_dragging_over_.get() != NULL); 121 *handled = (guest_dragging_over_.get() != NULL);
124 } 122 }
125 123
126 void BrowserPluginEmbedder::OnAllocateInstanceID(int request_id) {
127 int instance_id = GetBrowserPluginGuestManager()->GetNextInstanceID();
128 Send(new BrowserPluginMsg_AllocateInstanceID_ACK(
129 routing_id(), request_id, instance_id));
130 }
131
132 void BrowserPluginEmbedder::OnGuestCallback( 124 void BrowserPluginEmbedder::OnGuestCallback(
133 int instance_id, 125 int instance_id,
134 const BrowserPluginHostMsg_Attach_Params& params, 126 const BrowserPluginHostMsg_Attach_Params& params,
135 const base::DictionaryValue* extra_params, 127 const base::DictionaryValue* extra_params,
136 WebContents* guest_web_contents) { 128 WebContents* guest_web_contents) {
137 BrowserPluginGuest* guest = guest_web_contents ? 129 BrowserPluginGuest* guest = guest_web_contents ?
138 static_cast<WebContentsImpl*>(guest_web_contents)-> 130 static_cast<WebContentsImpl*>(guest_web_contents)->
139 GetBrowserPluginGuest() : NULL; 131 GetBrowserPluginGuest() : NULL;
132 if (!guest) {
133 scoped_ptr<base::DictionaryValue> copy_extra_params(
134 extra_params->DeepCopy());
135 guest_web_contents = GetBrowserPluginGuestManager()->CreateGuest(
136 GetWebContents()->GetSiteInstance(),
137 instance_id,
138 copy_extra_params.Pass());
139 guest = guest_web_contents ?
140 static_cast<WebContentsImpl*>(guest_web_contents)->
141 GetBrowserPluginGuest() : NULL;
142 }
143
140 if (guest) { 144 if (guest) {
141 // There is an implicit order expectation here: 145 // There is an implicit order expectation here:
142 // 1. The content embedder is made aware of the attachment. 146 // 1. The content embedder is made aware of the attachment.
143 // 2. BrowserPluginGuest::Attach is called. 147 // 2. BrowserPluginGuest::Attach is called.
144 // 3. The content embedder issues queued events if any that happened 148 // 3. The content embedder issues queued events if any that happened
145 // prior to attachment. 149 // prior to attachment.
146 GetContentClient()->browser()->GuestWebContentsAttached( 150 GetContentClient()->browser()->GuestWebContentsAttached(
147 guest->GetWebContents(), 151 guest->GetWebContents(),
148 GetWebContents(), 152 GetWebContents(),
149 *extra_params); 153 *extra_params);
150 guest->Attach(GetWebContents(), params, *extra_params); 154 guest->Attach(GetWebContents(), params, *extra_params);
151 return;
152 }
153
154 scoped_ptr<base::DictionaryValue> copy_extra_params(extra_params->DeepCopy());
155 guest_web_contents = GetBrowserPluginGuestManager()->CreateGuest(
156 GetWebContents()->GetSiteInstance(),
157 instance_id,
158 params.storage_partition_id,
159 params.persist_storage,
160 copy_extra_params.Pass());
161 guest = guest_web_contents ?
162 static_cast<WebContentsImpl*>(guest_web_contents)->
163 GetBrowserPluginGuest() : NULL;
164 if (guest) {
165 GetContentClient()->browser()->GuestWebContentsAttached(
166 guest->GetWebContents(),
167 GetWebContents(),
168 *extra_params);
169 guest->Initialize(params, GetWebContents());
170 } 155 }
171 } 156 }
172 157
173 void BrowserPluginEmbedder::OnAttach( 158 void BrowserPluginEmbedder::OnAttach(
174 int instance_id, 159 int instance_id,
175 const BrowserPluginHostMsg_Attach_Params& params, 160 const BrowserPluginHostMsg_Attach_Params& params,
176 const base::DictionaryValue& extra_params) { 161 const base::DictionaryValue& extra_params) {
177 GetBrowserPluginGuestManager()->MaybeGetGuestByInstanceIDOrKill( 162 GetBrowserPluginGuestManager()->MaybeGetGuestByInstanceIDOrKill(
178 instance_id, GetWebContents()->GetRenderProcessHost()->GetID(), 163 instance_id, GetWebContents()->GetRenderProcessHost()->GetID(),
179 base::Bind(&BrowserPluginEmbedder::OnGuestCallback, 164 base::Bind(&BrowserPluginEmbedder::OnGuestCallback,
180 base::Unretained(this), 165 base::Unretained(this),
181 instance_id, 166 instance_id,
182 params, 167 params,
183 &extra_params)); 168 &extra_params));
184 } 169 }
185 170
186 } // namespace content 171 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698