Chromium Code Reviews| 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, |
| 232 const std::string& partition_id, | |
| 236 const WebViewInfo& webview_info) { | 233 const WebViewInfo& webview_info) { |
| 237 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 234 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 238 RenderId render_id(guest_process_id, guest_routing_id); | 235 RenderId render_id(guest_process_id, guest_routing_id); |
| 239 webview_info_map_[render_id] = webview_info; | 236 webview_info_map_[render_id] = webview_info; |
| 237 WebViewPartitionIDMap::iterator iter = | |
| 238 webview_partition_id_map_.find(guest_process_id); | |
| 239 if (iter != webview_partition_id_map_.end()) { | |
| 240 PartitionID partition_id_pair = iter->second; | |
| 241 partition_id_pair.second += 1; | |
|
Fady Samuel
2014/06/16 22:02:32
++ instead of +=
Xi Han
2014/06/17 13:42:30
Done.
| |
| 242 webview_partition_id_map_[guest_process_id] = partition_id_pair; | |
|
Fady Samuel
2014/06/16 22:02:32
If you grab iter->second as a reference, then you
Xi Han
2014/06/17 13:42:30
Done.
| |
| 243 return; | |
| 244 } | |
| 245 PartitionID partition_id_pair(partition_id, 1); | |
| 246 webview_partition_id_map_[guest_process_id] = partition_id_pair; | |
| 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() && iter->second.second > 1) { | |
| 257 PartitionID partition_id_pair = iter->second; | |
|
Fady Samuel
2014/06/16 22:02:32
Grab it as a reference?
Xi Han
2014/06/17 13:42:30
Done.
| |
| 258 partition_id_pair.second -= 1; | |
|
Fady Samuel
2014/06/16 22:02:32
-- instead of -= 1?
Xi Han
2014/06/17 13:42:30
Done.
| |
| 259 webview_partition_id_map_[guest_process_id] = partition_id_pair; | |
|
Fady Samuel
2014/06/16 22:02:32
If you grab it as a reference, you don't need to d
Xi Han
2014/06/17 13:42:30
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.first; | |
| 285 return true; | |
| 286 } | |
| 287 return false; | |
| 288 } | |
| OLD | NEW |