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" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 RenderId render_id(render_process_host_id, routing_id); | 205 RenderId render_id(render_process_host_id, routing_id); |
206 TabAndWindowIdMap::iterator iter = map_.find(render_id); | 206 TabAndWindowIdMap::iterator iter = map_.find(render_id); |
207 if (iter != map_.end()) { | 207 if (iter != map_.end()) { |
208 *tab_id = iter->second.first; | 208 *tab_id = iter->second.first; |
209 *window_id = iter->second.second; | 209 *window_id = iter->second.second; |
210 return true; | 210 return true; |
211 } | 211 } |
212 return false; | 212 return false; |
213 } | 213 } |
214 | 214 |
| 215 bool ExtensionRendererState::IsWebViewRenderer(int render_process_id) { |
| 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 217 for (WebViewInfoMap::iterator i = webview_info_map_.begin(); |
| 218 i != webview_info_map_.end(); ++i) { |
| 219 if (i->first.first == render_process_id) |
| 220 return true; |
| 221 } |
| 222 return false; |
| 223 } |
| 224 |
215 void ExtensionRendererState::AddWebView(int guest_process_id, | 225 void ExtensionRendererState::AddWebView(int guest_process_id, |
216 int guest_routing_id, | 226 int guest_routing_id, |
217 const WebViewInfo& webview_info) { | 227 const WebViewInfo& webview_info) { |
218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
219 RenderId render_id(guest_process_id, guest_routing_id); | 229 RenderId render_id(guest_process_id, guest_routing_id); |
220 webview_info_map_[render_id] = webview_info; | 230 webview_info_map_[render_id] = webview_info; |
221 } | 231 } |
222 | 232 |
223 void ExtensionRendererState::RemoveWebView(int guest_process_id, | 233 void ExtensionRendererState::RemoveWebView(int guest_process_id, |
224 int guest_routing_id) { | 234 int guest_routing_id) { |
225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
226 RenderId render_id(guest_process_id, guest_routing_id); | 236 RenderId render_id(guest_process_id, guest_routing_id); |
227 webview_info_map_.erase(render_id); | 237 webview_info_map_.erase(render_id); |
228 } | 238 } |
229 | 239 |
230 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, | 240 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, |
231 int guest_routing_id, | 241 int guest_routing_id, |
232 WebViewInfo* webview_info) { | 242 WebViewInfo* webview_info) { |
233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
234 RenderId render_id(guest_process_id, guest_routing_id); | 244 RenderId render_id(guest_process_id, guest_routing_id); |
235 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); | 245 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); |
236 if (iter != webview_info_map_.end()) { | 246 if (iter != webview_info_map_.end()) { |
237 *webview_info = iter->second; | 247 *webview_info = iter->second; |
238 return true; | 248 return true; |
239 } | 249 } |
240 return false; | 250 return false; |
241 } | 251 } |
OLD | NEW |