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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (iter != map_.end()) { | 216 if (iter != map_.end()) { |
217 *tab_id = iter->second.first; | 217 *tab_id = iter->second.first; |
218 *window_id = iter->second.second; | 218 *window_id = iter->second.second; |
219 return true; | 219 return true; |
220 } | 220 } |
221 return false; | 221 return false; |
222 } | 222 } |
223 | 223 |
224 bool ExtensionRendererState::IsWebViewRenderer(int render_process_id) { | 224 bool ExtensionRendererState::IsWebViewRenderer(int render_process_id) { |
225 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 225 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
226 for (WebViewInfoMap::iterator i = webview_info_map_.begin(); | 226 return webview_partition_id_map_.find(render_process_id) != |
227 i != webview_info_map_.end(); ++i) { | 227 webview_partition_id_map_.end(); |
228 if (i->first.first == render_process_id) | |
229 return true; | |
230 } | |
231 return false; | |
232 } | 228 } |
233 | 229 |
234 void ExtensionRendererState::AddWebView(int guest_process_id, | 230 void ExtensionRendererState::AddWebView(int guest_process_id, |
235 int guest_routing_id, | 231 int guest_routing_id, |
236 const WebViewInfo& webview_info) { | 232 const WebViewInfo& webview_info) { |
237 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 233 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
238 RenderId render_id(guest_process_id, guest_routing_id); | 234 RenderId render_id(guest_process_id, guest_routing_id); |
239 webview_info_map_[render_id] = webview_info; | 235 webview_info_map_[render_id] = webview_info; |
| 236 WebViewPartitionIDMap::iterator iter = |
| 237 webview_partition_id_map_.find(guest_process_id); |
| 238 if (iter != webview_partition_id_map_.end()) { |
| 239 ++iter->second.web_view_count; |
| 240 return; |
| 241 } |
| 242 WebViewPartitionInfo partition_info(1, webview_info.partition_id); |
| 243 webview_partition_id_map_[guest_process_id] = partition_info; |
240 } | 244 } |
241 | 245 |
242 void ExtensionRendererState::RemoveWebView(int guest_process_id, | 246 void ExtensionRendererState::RemoveWebView(int guest_process_id, |
243 int guest_routing_id) { | 247 int guest_routing_id) { |
244 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 248 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
245 RenderId render_id(guest_process_id, guest_routing_id); | 249 RenderId render_id(guest_process_id, guest_routing_id); |
246 webview_info_map_.erase(render_id); | 250 webview_info_map_.erase(render_id); |
| 251 WebViewPartitionIDMap::iterator iter = |
| 252 webview_partition_id_map_.find(guest_process_id); |
| 253 if (iter != webview_partition_id_map_.end() && |
| 254 iter->second.web_view_count > 1) { |
| 255 --iter->second.web_view_count; |
| 256 return; |
| 257 } |
| 258 webview_partition_id_map_.erase(guest_process_id); |
247 } | 259 } |
248 | 260 |
249 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, | 261 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, |
250 int guest_routing_id, | 262 int guest_routing_id, |
251 WebViewInfo* webview_info) { | 263 WebViewInfo* webview_info) { |
252 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 264 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
253 RenderId render_id(guest_process_id, guest_routing_id); | 265 RenderId render_id(guest_process_id, guest_routing_id); |
254 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); | 266 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); |
255 if (iter != webview_info_map_.end()) { | 267 if (iter != webview_info_map_.end()) { |
256 *webview_info = iter->second; | 268 *webview_info = iter->second; |
257 return true; | 269 return true; |
258 } | 270 } |
259 return false; | 271 return false; |
260 } | 272 } |
| 273 |
| 274 bool ExtensionRendererState::GetWebViewPartitionID(int guest_process_id, |
| 275 std::string* partition_id) { |
| 276 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 277 WebViewPartitionIDMap::iterator iter = |
| 278 webview_partition_id_map_.find(guest_process_id); |
| 279 if (iter != webview_partition_id_map_.end()) { |
| 280 *partition_id = iter->second.partition_id; |
| 281 return true; |
| 282 } |
| 283 return false; |
| 284 } |
OLD | NEW |