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