Chromium Code Reviews| Index: chrome/browser/extensions/extension_renderer_state.cc |
| diff --git a/chrome/browser/extensions/extension_renderer_state.cc b/chrome/browser/extensions/extension_renderer_state.cc |
| index 341db2788cc789e4cbde81f2b1df20f39716a7b5..7352d55e887d59b75ff2f834494ea4f0c51d09d3 100644 |
| --- a/chrome/browser/extensions/extension_renderer_state.cc |
| +++ b/chrome/browser/extensions/extension_renderer_state.cc |
| @@ -223,20 +223,27 @@ bool ExtensionRendererState::GetTabAndWindowId( |
| bool ExtensionRendererState::IsWebViewRenderer(int render_process_id) { |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| - for (WebViewInfoMap::iterator i = webview_info_map_.begin(); |
| - i != webview_info_map_.end(); ++i) { |
| - if (i->first.first == render_process_id) |
| - return true; |
| - } |
| - return false; |
| + return webview_partition_id_map_.find(render_process_id) != |
| + webview_partition_id_map_.end(); |
| } |
| void ExtensionRendererState::AddWebView(int guest_process_id, |
| int guest_routing_id, |
| + const std::string& partition_id, |
| const WebViewInfo& webview_info) { |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| RenderId render_id(guest_process_id, guest_routing_id); |
| webview_info_map_[render_id] = webview_info; |
| + WebViewPartitionIDMap::iterator iter = |
| + webview_partition_id_map_.find(guest_process_id); |
| + if (iter != webview_partition_id_map_.end()) { |
| + PartitionID partition_id_pair = iter->second; |
| + partition_id_pair.second += 1; |
|
Fady Samuel
2014/06/16 22:02:32
++ instead of +=
Xi Han
2014/06/17 13:42:30
Done.
|
| + 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.
|
| + return; |
| + } |
| + PartitionID partition_id_pair(partition_id, 1); |
| + webview_partition_id_map_[guest_process_id] = partition_id_pair; |
| } |
| void ExtensionRendererState::RemoveWebView(int guest_process_id, |
| @@ -244,6 +251,15 @@ void ExtensionRendererState::RemoveWebView(int guest_process_id, |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| RenderId render_id(guest_process_id, guest_routing_id); |
| webview_info_map_.erase(render_id); |
| + WebViewPartitionIDMap::iterator iter = |
| + webview_partition_id_map_.find(guest_process_id); |
| + if (iter != webview_partition_id_map_.end() && iter->second.second > 1) { |
| + 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.
|
| + 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.
|
| + 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.
|
| + return; |
| + } |
| + webview_partition_id_map_.erase(guest_process_id); |
| } |
| bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, |
| @@ -258,3 +274,15 @@ bool ExtensionRendererState::GetWebViewInfo(int guest_process_id, |
| } |
| return false; |
| } |
| + |
| +bool ExtensionRendererState::GetWebViewPartitionID(int guest_process_id, |
| + std::string* partition_id) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + WebViewPartitionIDMap::iterator iter = |
| + webview_partition_id_map_.find(guest_process_id); |
| + if (iter != webview_partition_id_map_.end()) { |
| + *partition_id = iter->second.first; |
| + return true; |
| + } |
| + return false; |
| +} |