OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/extensions/extension_renderer_state.h" | 5 #include "chrome/browser/extensions/extension_renderer_state.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/sessions/session_tab_helper.h" | 10 #include "chrome/browser/sessions/session_tab_helper.h" |
11 #include "chrome/browser/tab_contents/retargeting_details.h" | 11 #include "chrome/browser/tab_contents/retargeting_details.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/navigation_details.h" | 13 #include "content/public/browser/navigation_details.h" |
14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
18 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/resource_request_info.h" |
20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
21 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
| 23 #include "content/public/common/process_type.h" |
22 | 24 |
23 using content::BrowserThread; | 25 using content::BrowserThread; |
24 using content::RenderProcessHost; | 26 using content::RenderProcessHost; |
25 using content::RenderViewHost; | 27 using content::RenderViewHost; |
26 using content::WebContents; | 28 using content::WebContents; |
27 | 29 |
28 // | 30 // |
29 // ExtensionRendererState::RenderViewHostObserver | 31 // ExtensionRendererState::RenderViewHostObserver |
30 // | 32 // |
31 | 33 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 195 } |
194 | 196 |
195 void ExtensionRendererState::ClearTabAndWindowId( | 197 void ExtensionRendererState::ClearTabAndWindowId( |
196 int render_process_host_id, int routing_id) { | 198 int render_process_host_id, int routing_id) { |
197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
198 RenderId render_id(render_process_host_id, routing_id); | 200 RenderId render_id(render_process_host_id, routing_id); |
199 map_.erase(render_id); | 201 map_.erase(render_id); |
200 } | 202 } |
201 | 203 |
202 bool ExtensionRendererState::GetTabAndWindowId( | 204 bool ExtensionRendererState::GetTabAndWindowId( |
203 int render_process_host_id, int routing_id, int* tab_id, int* window_id) { | 205 const content::ResourceRequestInfo* info, int* tab_id, int* window_id) { |
204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
205 RenderId render_id(render_process_host_id, routing_id); | 207 int render_process_id; |
| 208 if (info->GetProcessType() == content::PROCESS_TYPE_PLUGIN) { |
| 209 render_process_id = info->GetOriginPID(); |
| 210 } else { |
| 211 render_process_id = info->GetChildID(); |
| 212 } |
| 213 int render_view_id = info->GetRouteID(); |
| 214 RenderId render_id(render_process_id, render_view_id); |
206 TabAndWindowIdMap::iterator iter = map_.find(render_id); | 215 TabAndWindowIdMap::iterator iter = map_.find(render_id); |
207 if (iter != map_.end()) { | 216 if (iter != map_.end()) { |
208 *tab_id = iter->second.first; | 217 *tab_id = iter->second.first; |
209 *window_id = iter->second.second; | 218 *window_id = iter->second.second; |
210 return true; | 219 return true; |
211 } | 220 } |
212 return false; | 221 return false; |
213 } | 222 } |
214 | 223 |
215 bool ExtensionRendererState::IsWebViewRenderer(int render_process_id) { | 224 bool ExtensionRendererState::IsWebViewRenderer(int render_process_id) { |
(...skipping 26 matching lines...) Expand all Loading... |
242 WebViewInfo* webview_info) { | 251 WebViewInfo* webview_info) { |
243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
244 RenderId render_id(guest_process_id, guest_routing_id); | 253 RenderId render_id(guest_process_id, guest_routing_id); |
245 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); | 254 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); |
246 if (iter != webview_info_map_.end()) { | 255 if (iter != webview_info_map_.end()) { |
247 *webview_info = iter->second; | 256 *webview_info = iter->second; |
248 return true; | 257 return true; |
249 } | 258 } |
250 return false; | 259 return false; |
251 } | 260 } |
OLD | NEW |