| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(WebContents* tab) { |
| 157 // TODO(sky): nuke this since no one is using visit_duration (and this is all | |
| 158 // wrong). | |
| 159 | |
| 160 // We update the history for this URL. | 157 // We update the history for this URL. |
| 161 // The content returned from web_contents() has been destroyed by now. | 158 // The content returned from web_contents() has been destroyed by now. |
| 162 // We need to use tab value directly. | 159 // We need to use tab value directly. |
| 163 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 160 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| 164 if (profile->IsOffTheRecord()) | 161 if (profile->IsOffTheRecord()) |
| 165 return; | 162 return; |
| 166 | 163 |
| 167 HistoryService* hs = | 164 HistoryService* hs = |
| 168 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 165 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
| 169 if (hs) { | 166 if (hs) { |
| 170 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); | 167 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); |
| 171 if (entry) { | 168 if (entry) { |
| 172 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), | 169 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), |
| 173 base::Time::Now()); | 170 base::Time::Now()); |
| 174 } | 171 } |
| 175 } | 172 } |
| 176 } | 173 } |
| OLD | NEW |