| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_tab_id_map.h" | 5 #include "chrome/browser/extensions/extension_tab_id_map.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/sessions/restore_tab_helper.h" | 9 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 if (!tab) | 67 if (!tab) |
| 68 break; | 68 break; |
| 69 RenderViewHost* host = content::Details<RenderViewHost>(details).ptr(); | 69 RenderViewHost* host = content::Details<RenderViewHost>(details).ptr(); |
| 70 // TODO(mpcmoplete): How can we tell if window_id is bogus? It may not | 70 // TODO(mpcmoplete): How can we tell if window_id is bogus? It may not |
| 71 // have been set yet. | 71 // have been set yet. |
| 72 BrowserThread::PostTask( | 72 BrowserThread::PostTask( |
| 73 BrowserThread::IO, FROM_HERE, | 73 BrowserThread::IO, FROM_HERE, |
| 74 base::Bind( | 74 base::Bind( |
| 75 &ExtensionTabIdMap::SetTabAndWindowId, | 75 &ExtensionTabIdMap::SetTabAndWindowId, |
| 76 base::Unretained(ExtensionTabIdMap::GetInstance()), | 76 base::Unretained(ExtensionTabIdMap::GetInstance()), |
| 77 host->process()->id(), host->routing_id(), | 77 host->process()->GetID(), host->routing_id(), |
| 78 tab->restore_tab_helper()->session_id().id(), | 78 tab->restore_tab_helper()->session_id().id(), |
| 79 tab->restore_tab_helper()->window_id().id())); | 79 tab->restore_tab_helper()->window_id().id())); |
| 80 break; | 80 break; |
| 81 } | 81 } |
| 82 case content::NOTIFICATION_TAB_PARENTED: { | 82 case content::NOTIFICATION_TAB_PARENTED: { |
| 83 TabContentsWrapper* tab = | 83 TabContentsWrapper* tab = |
| 84 content::Source<TabContentsWrapper>(source).ptr(); | 84 content::Source<TabContentsWrapper>(source).ptr(); |
| 85 RenderViewHost* host = tab->render_view_host(); | 85 RenderViewHost* host = tab->render_view_host(); |
| 86 BrowserThread::PostTask( | 86 BrowserThread::PostTask( |
| 87 BrowserThread::IO, FROM_HERE, | 87 BrowserThread::IO, FROM_HERE, |
| 88 base::Bind( | 88 base::Bind( |
| 89 &ExtensionTabIdMap::SetTabAndWindowId, | 89 &ExtensionTabIdMap::SetTabAndWindowId, |
| 90 base::Unretained(ExtensionTabIdMap::GetInstance()), | 90 base::Unretained(ExtensionTabIdMap::GetInstance()), |
| 91 host->process()->id(), host->routing_id(), | 91 host->process()->GetID(), host->routing_id(), |
| 92 tab->restore_tab_helper()->session_id().id(), | 92 tab->restore_tab_helper()->session_id().id(), |
| 93 tab->restore_tab_helper()->window_id().id())); | 93 tab->restore_tab_helper()->window_id().id())); |
| 94 break; | 94 break; |
| 95 } | 95 } |
| 96 case content::NOTIFICATION_RETARGETING: { | 96 case content::NOTIFICATION_RETARGETING: { |
| 97 content::RetargetingDetails* retargeting_details = | 97 content::RetargetingDetails* retargeting_details = |
| 98 content::Details<content::RetargetingDetails>(details).ptr(); | 98 content::Details<content::RetargetingDetails>(details).ptr(); |
| 99 TabContents* contents = retargeting_details->target_tab_contents; | 99 TabContents* contents = retargeting_details->target_tab_contents; |
| 100 TabContentsWrapper* tab = | 100 TabContentsWrapper* tab = |
| 101 TabContentsWrapper::GetCurrentWrapperForContents(contents); | 101 TabContentsWrapper::GetCurrentWrapperForContents(contents); |
| 102 if (!tab) | 102 if (!tab) |
| 103 break; | 103 break; |
| 104 RenderViewHost* host = tab->render_view_host(); | 104 RenderViewHost* host = tab->render_view_host(); |
| 105 BrowserThread::PostTask( | 105 BrowserThread::PostTask( |
| 106 BrowserThread::IO, FROM_HERE, | 106 BrowserThread::IO, FROM_HERE, |
| 107 base::Bind( | 107 base::Bind( |
| 108 &ExtensionTabIdMap::SetTabAndWindowId, | 108 &ExtensionTabIdMap::SetTabAndWindowId, |
| 109 base::Unretained(ExtensionTabIdMap::GetInstance()), | 109 base::Unretained(ExtensionTabIdMap::GetInstance()), |
| 110 host->process()->id(), host->routing_id(), | 110 host->process()->GetID(), host->routing_id(), |
| 111 tab->restore_tab_helper()->session_id().id(), | 111 tab->restore_tab_helper()->session_id().id(), |
| 112 tab->restore_tab_helper()->window_id().id())); | 112 tab->restore_tab_helper()->window_id().id())); |
| 113 break; | 113 break; |
| 114 } | 114 } |
| 115 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: { | 115 case content::NOTIFICATION_RENDER_VIEW_HOST_DELETED: { |
| 116 RenderViewHost* host = content::Source<RenderViewHost>(source).ptr(); | 116 RenderViewHost* host = content::Source<RenderViewHost>(source).ptr(); |
| 117 BrowserThread::PostTask( | 117 BrowserThread::PostTask( |
| 118 BrowserThread::IO, FROM_HERE, | 118 BrowserThread::IO, FROM_HERE, |
| 119 base::Bind( | 119 base::Bind( |
| 120 &ExtensionTabIdMap::ClearTabAndWindowId, | 120 &ExtensionTabIdMap::ClearTabAndWindowId, |
| 121 base::Unretained(ExtensionTabIdMap::GetInstance()), | 121 base::Unretained(ExtensionTabIdMap::GetInstance()), |
| 122 host->process()->id(), host->routing_id())); | 122 host->process()->GetID(), host->routing_id())); |
| 123 break; | 123 break; |
| 124 } | 124 } |
| 125 default: | 125 default: |
| 126 NOTREACHED(); | 126 NOTREACHED(); |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 // | 131 // |
| 132 // ExtensionTabIdMap | 132 // ExtensionTabIdMap |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 171 RenderId render_id(render_process_host_id, routing_id); | 171 RenderId render_id(render_process_host_id, routing_id); |
| 172 TabAndWindowIdMap::iterator iter = map_.find(render_id); | 172 TabAndWindowIdMap::iterator iter = map_.find(render_id); |
| 173 if (iter != map_.end()) { | 173 if (iter != map_.end()) { |
| 174 *tab_id = iter->second.first; | 174 *tab_id = iter->second.first; |
| 175 *window_id = iter->second.second; | 175 *window_id = iter->second.second; |
| 176 return true; | 176 return true; |
| 177 } | 177 } |
| 178 return false; | 178 return false; |
| 179 } | 179 } |
| OLD | NEW |