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.h" | 9 #include "chrome/browser/history/history.h" |
10 #include "chrome/browser/history/top_sites.h" | 10 #include "chrome/browser/history/top_sites.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 | 165 |
166 HistoryService* HistoryTabHelper::GetHistoryService() { | 166 HistoryService* HistoryTabHelper::GetHistoryService() { |
167 Profile* profile = | 167 Profile* profile = |
168 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 168 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
169 if (profile->IsOffTheRecord()) | 169 if (profile->IsOffTheRecord()) |
170 return NULL; | 170 return NULL; |
171 | 171 |
172 return profile->GetHistoryService(Profile::IMPLICIT_ACCESS); | 172 return profile->GetHistoryService(Profile::IMPLICIT_ACCESS); |
173 } | 173 } |
| 174 |
| 175 void HistoryTabHelper::WebContentsDestroyed(WebContents* tab) { |
| 176 // We update the history for this URL. |
| 177 // The content returned from web_contents() has been destroyed by now. |
| 178 // We need to use tab value directly. |
| 179 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| 180 if (profile->IsOffTheRecord()) |
| 181 return; |
| 182 |
| 183 HistoryService* hs = profile->GetHistoryService(Profile::IMPLICIT_ACCESS); |
| 184 if (hs) { |
| 185 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); |
| 186 if (entry) { |
| 187 hs->UpdatePageInfo(tab, entry->GetPageID(), tab->GetURL(), |
| 188 base::Time::Now()); |
| 189 } |
| 190 } |
| 191 } |
OLD | NEW |