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 WebViewPartitionInfo& partition_info = iter->second; | |
240 ++partition_info.web_view_count; | |
241 return; | |
242 } | |
243 WebViewPartitionInfo partition_info ={1, webview_info.partition_id}; | |
Fady Samuel
2014/06/17 18:20:29
I can't find anything in the style guide that expl
Xi Han
2014/06/17 19:01:07
Done.
| |
244 webview_partition_id_map_[guest_process_id] = partition_info; | |
240 } | 245 } |
241 | 246 |
242 void ExtensionRendererState::RemoveWebView(int guest_process_id, | 247 void ExtensionRendererState::RemoveWebView(int guest_process_id, |
243 int guest_routing_id) { | 248 int guest_routing_id) { |
244 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 249 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
245 RenderId render_id(guest_process_id, guest_routing_id); | 250 RenderId render_id(guest_process_id, guest_routing_id); |
246 webview_info_map_.erase(render_id); | 251 webview_info_map_.erase(render_id); |
252 WebViewPartitionIDMap::iterator iter = | |
253 webview_partition_id_map_.find(guest_process_id); | |
254 if (iter != webview_partition_id_map_.end() && | |
255 iter->second.web_view_count > 1) { | |
256 WebViewPartitionInfo& partition_info = iter->second; | |
257 --partition_info.web_view_count; | |
258 return; | |
259 } | |
260 webview_partition_id_map_.erase(guest_process_id); | |
247 } | 261 } |
248 | 262 |
249 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, | 263 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, |
250 int guest_routing_id, | 264 int guest_routing_id, |
251 WebViewInfo* webview_info) { | 265 WebViewInfo* webview_info) { |
252 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 266 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
253 RenderId render_id(guest_process_id, guest_routing_id); | 267 RenderId render_id(guest_process_id, guest_routing_id); |
254 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); | 268 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); |
255 if (iter != webview_info_map_.end()) { | 269 if (iter != webview_info_map_.end()) { |
256 *webview_info = iter->second; | 270 *webview_info = iter->second; |
257 return true; | 271 return true; |
258 } | 272 } |
259 return false; | 273 return false; |
260 } | 274 } |
275 | |
276 bool ExtensionRendererState::GetWebViewPartitionID(int guest_process_id, | |
277 std::string* partition_id) { | |
278 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
279 WebViewPartitionIDMap::iterator iter = | |
280 webview_partition_id_map_.find(guest_process_id); | |
281 if (iter != webview_partition_id_map_.end()) { | |
282 *partition_id = iter->second.partition_id; | |
283 return true; | |
284 } | |
285 return false; | |
286 } | |
OLD | NEW |