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; | |
Fady Samuel
2014/06/18 13:39:16
There's actually no need for this local variable:
Xi Han
2014/06/18 14:09:19
Done.
| |
240 ++partition_info.web_view_count; | |
241 return; | |
242 } | |
243 WebViewPartitionInfo partition_info(1, webview_info.partition_id); | |
244 webview_partition_id_map_.insert( | |
Fady Samuel
2014/06/18 13:39:16
nit
This is more readable:
webview_partition_id_
Xi Han
2014/06/18 14:09:19
Done.
| |
245 std::pair<char, WebViewPartitionInfo>(guest_process_id, | |
246 partition_info)); | |
240 } | 247 } |
241 | 248 |
242 void ExtensionRendererState::RemoveWebView(int guest_process_id, | 249 void ExtensionRendererState::RemoveWebView(int guest_process_id, |
243 int guest_routing_id) { | 250 int guest_routing_id) { |
244 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 251 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
245 RenderId render_id(guest_process_id, guest_routing_id); | 252 RenderId render_id(guest_process_id, guest_routing_id); |
246 webview_info_map_.erase(render_id); | 253 webview_info_map_.erase(render_id); |
254 WebViewPartitionIDMap::iterator iter = | |
255 webview_partition_id_map_.find(guest_process_id); | |
256 if (iter != webview_partition_id_map_.end() && | |
257 iter->second.web_view_count > 1) { | |
258 WebViewPartitionInfo& partition_info = iter->second; | |
259 --partition_info.web_view_count; | |
Fady Samuel
2014/06/18 13:39:16
There's no need for a local variable:
--iter->sec
Xi Han
2014/06/18 14:09:19
Done.
| |
260 return; | |
261 } | |
262 webview_partition_id_map_.erase(guest_process_id); | |
247 } | 263 } |
248 | 264 |
249 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, | 265 bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, |
250 int guest_routing_id, | 266 int guest_routing_id, |
251 WebViewInfo* webview_info) { | 267 WebViewInfo* webview_info) { |
252 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 268 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
253 RenderId render_id(guest_process_id, guest_routing_id); | 269 RenderId render_id(guest_process_id, guest_routing_id); |
254 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); | 270 WebViewInfoMap::iterator iter = webview_info_map_.find(render_id); |
255 if (iter != webview_info_map_.end()) { | 271 if (iter != webview_info_map_.end()) { |
256 *webview_info = iter->second; | 272 *webview_info = iter->second; |
257 return true; | 273 return true; |
258 } | 274 } |
259 return false; | 275 return false; |
260 } | 276 } |
277 | |
278 bool ExtensionRendererState::GetWebViewPartitionID(int guest_process_id, | |
279 std::string* partition_id) { | |
280 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
281 WebViewPartitionIDMap::iterator iter = | |
282 webview_partition_id_map_.find(guest_process_id); | |
283 if (iter != webview_partition_id_map_.end()) { | |
284 *partition_id = iter->second.partition_id; | |
285 return true; | |
286 } | |
287 return false; | |
288 } | |
OLD | NEW |