| OLD | NEW |
| 1 // Copyright (c) 2012 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/history/history_tab_helper.h" | 5 #include "chrome/browser/history/history_tab_helper.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/history/history_service.h" | 9 #include "chrome/browser/history/history_service.h" |
| 10 #include "chrome/browser/history/history_service_factory.h" | 10 #include "chrome/browser/history/history_service_factory.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 HistoryService* HistoryTabHelper::GetHistoryService() { | 146 HistoryService* HistoryTabHelper::GetHistoryService() { |
| 147 Profile* profile = | 147 Profile* profile = |
| 148 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 148 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 149 if (profile->IsOffTheRecord()) | 149 if (profile->IsOffTheRecord()) |
| 150 return NULL; | 150 return NULL; |
| 151 | 151 |
| 152 return HistoryServiceFactory::GetForProfile(profile, | 152 return HistoryServiceFactory::GetForProfile(profile, |
| 153 Profile::IMPLICIT_ACCESS); | 153 Profile::IMPLICIT_ACCESS); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void HistoryTabHelper::WebContentsDestroyed(WebContents* tab) { | 156 void HistoryTabHelper::WebContentsDestroyed() { |
| 157 // We update the history for this URL. | 157 // We update the history for this URL. |
| 158 // The content returned from web_contents() has been destroyed by now. | 158 WebContents* tab = web_contents(); |
| 159 // We need to use tab value directly. | |
| 160 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 159 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| 161 if (profile->IsOffTheRecord()) | 160 if (profile->IsOffTheRecord()) |
| 162 return; | 161 return; |
| 163 | 162 |
| 164 HistoryService* hs = | 163 HistoryService* hs = |
| 165 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 164 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
| 166 if (hs) { | 165 if (hs) { |
| 167 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); | 166 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); |
| 168 if (entry) { | 167 if (entry) { |
| 169 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), | 168 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), |
| 170 base::Time::Now()); | 169 base::Time::Now()); |
| 171 } | 170 } |
| 172 } | 171 } |
| 173 } | 172 } |
| OLD | NEW |