| 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_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/prerender/prerender_contents.h" | 10 #include "chrome/browser/prerender/prerender_contents.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 void HistoryTabHelper::TitleWasSet(NavigationEntry* entry, bool explicit_set) { | 130 void HistoryTabHelper::TitleWasSet(NavigationEntry* entry, bool explicit_set) { |
| 131 if (received_page_title_) | 131 if (received_page_title_) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 if (entry) { | 134 if (entry) { |
| 135 UpdateHistoryPageTitle(*entry); | 135 UpdateHistoryPageTitle(*entry); |
| 136 received_page_title_ = explicit_set; | 136 received_page_title_ = explicit_set; |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 void HistoryTabHelper::SetHistoryContext(NavigationEntry* entry, int context) { |
| 141 history::HistoryService* hs = GetHistoryService(); |
| 142 if (hs) |
| 143 hs->SetPageHistoryContext(entry->GetVirtualURL(), |
| 144 static_cast<history::HistoryContext>(context)); |
| 145 } |
| 146 |
| 140 history::HistoryService* HistoryTabHelper::GetHistoryService() { | 147 history::HistoryService* HistoryTabHelper::GetHistoryService() { |
| 141 Profile* profile = | 148 Profile* profile = |
| 142 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 149 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 143 if (profile->IsOffTheRecord()) | 150 if (profile->IsOffTheRecord()) |
| 144 return NULL; | 151 return NULL; |
| 145 | 152 |
| 146 return HistoryServiceFactory::GetForProfile( | 153 return HistoryServiceFactory::GetForProfile( |
| 147 profile, ServiceAccessType::IMPLICIT_ACCESS); | 154 profile, ServiceAccessType::IMPLICIT_ACCESS); |
| 148 } | 155 } |
| 149 | 156 |
| 150 void HistoryTabHelper::WebContentsDestroyed() { | 157 void HistoryTabHelper::WebContentsDestroyed() { |
| 151 // We update the history for this URL. | 158 // We update the history for this URL. |
| 152 WebContents* tab = web_contents(); | 159 WebContents* tab = web_contents(); |
| 153 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 160 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
| 154 if (profile->IsOffTheRecord()) | 161 if (profile->IsOffTheRecord()) |
| 155 return; | 162 return; |
| 156 | 163 |
| 157 history::HistoryService* hs = HistoryServiceFactory::GetForProfile( | 164 history::HistoryService* hs = HistoryServiceFactory::GetForProfile( |
| 158 profile, ServiceAccessType::IMPLICIT_ACCESS); | 165 profile, ServiceAccessType::IMPLICIT_ACCESS); |
| 159 if (hs) { | 166 if (hs) { |
| 160 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); | 167 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); |
| 161 history::ContextID context_id = history::ContextIDForWebContents(tab); | 168 history::ContextID context_id = history::ContextIDForWebContents(tab); |
| 162 if (entry) { | 169 if (entry) { |
| 163 hs->UpdateWithPageEndTime(context_id, entry->GetUniqueID(), tab->GetURL(), | 170 hs->UpdateWithPageEndTime(context_id, entry->GetUniqueID(), tab->GetURL(), |
| 164 base::Time::Now()); | 171 base::Time::Now()); |
| 165 } | 172 } |
| 166 hs->ClearCachedDataForContextID(context_id); | 173 hs->ClearCachedDataForContextID(context_id); |
| 167 } | 174 } |
| 168 } | 175 } |
| OLD | NEW |