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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 void HistoryTabHelper::UpdateHistoryPageTitle(const NavigationEntry& entry) { | 47 void HistoryTabHelper::UpdateHistoryPageTitle(const NavigationEntry& entry) { |
48 HistoryService* hs = GetHistoryService(); | 48 HistoryService* hs = GetHistoryService(); |
49 if (hs) | 49 if (hs) |
50 hs->SetPageTitle(entry.GetVirtualURL(), | 50 hs->SetPageTitle(entry.GetVirtualURL(), |
51 entry.GetTitleForDisplay(std::string())); | 51 entry.GetTitleForDisplay(std::string())); |
52 } | 52 } |
53 | 53 |
54 history::HistoryAddPageArgs | 54 history::HistoryAddPageArgs |
55 HistoryTabHelper::CreateHistoryAddPageArgs( | 55 HistoryTabHelper::CreateHistoryAddPageArgs( |
56 const GURL& virtual_url, | 56 const GURL& virtual_url, |
| 57 int32 page_id, |
57 base::Time timestamp, | 58 base::Time timestamp, |
58 bool did_replace_entry, | 59 bool did_replace_entry, |
59 const content::FrameNavigateParams& params) { | 60 const content::FrameNavigateParams& params) { |
60 history::HistoryAddPageArgs add_page_args( | 61 history::HistoryAddPageArgs add_page_args( |
61 params.url, timestamp, web_contents(), params.page_id, | 62 params.url, timestamp, web_contents(), page_id, |
62 params.referrer.url, params.redirects, params.transition, | 63 params.referrer.url, params.redirects, params.transition, |
63 history::SOURCE_BROWSED, did_replace_entry); | 64 history::SOURCE_BROWSED, did_replace_entry); |
64 if (ui::PageTransitionIsMainFrame(params.transition) && | 65 if (ui::PageTransitionIsMainFrame(params.transition) && |
65 virtual_url != params.url) { | 66 virtual_url != params.url) { |
66 // Hack on the "virtual" URL so that it will appear in history. For some | 67 // Hack on the "virtual" URL so that it will appear in history. For some |
67 // types of URLs, we will display a magic URL that is different from where | 68 // types of URLs, we will display a magic URL that is different from where |
68 // the page is actually navigated. We want the user to see in history what | 69 // the page is actually navigated. We want the user to see in history what |
69 // they saw in the URL bar, so we add the virtual URL as a redirect. This | 70 // they saw in the URL bar, so we add the virtual URL as a redirect. This |
70 // only applies to the main frame, as the virtual URL doesn't apply to | 71 // only applies to the main frame, as the virtual URL doesn't apply to |
71 // sub-frames. | 72 // sub-frames. |
(...skipping 19 matching lines...) Expand all Loading... |
91 // which WillNavigate[Main,Sub]Frame will do before this function is called. | 92 // which WillNavigate[Main,Sub]Frame will do before this function is called. |
92 if (!params.should_update_history) | 93 if (!params.should_update_history) |
93 return; | 94 return; |
94 | 95 |
95 // Most of the time, the displayURL matches the loaded URL, but for about: | 96 // Most of the time, the displayURL matches the loaded URL, but for about: |
96 // URLs, we use a data: URL as the real value. We actually want to save the | 97 // URLs, we use a data: URL as the real value. We actually want to save the |
97 // about: URL to the history db and keep the data: URL hidden. This is what | 98 // about: URL to the history db and keep the data: URL hidden. This is what |
98 // the WebContents' URL getter does. | 99 // the WebContents' URL getter does. |
99 const history::HistoryAddPageArgs& add_page_args = | 100 const history::HistoryAddPageArgs& add_page_args = |
100 CreateHistoryAddPageArgs( | 101 CreateHistoryAddPageArgs( |
101 web_contents()->GetURL(), details.entry->GetTimestamp(), | 102 web_contents()->GetURL(), |
102 details.did_replace_entry, params); | 103 details.entry->GetPageID(), |
| 104 details.entry->GetTimestamp(), |
| 105 details.did_replace_entry, |
| 106 params); |
103 | 107 |
104 prerender::PrerenderManager* prerender_manager = | 108 prerender::PrerenderManager* prerender_manager = |
105 prerender::PrerenderManagerFactory::GetForProfile( | 109 prerender::PrerenderManagerFactory::GetForProfile( |
106 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); | 110 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); |
107 if (prerender_manager) { | 111 if (prerender_manager) { |
108 prerender::PrerenderContents* prerender_contents = | 112 prerender::PrerenderContents* prerender_contents = |
109 prerender_manager->GetPrerenderContents(web_contents()); | 113 prerender_manager->GetPrerenderContents(web_contents()); |
110 if (prerender_contents) { | 114 if (prerender_contents) { |
111 prerender_contents->DidNavigate(add_page_args); | 115 prerender_contents->DidNavigate(add_page_args); |
112 return; | 116 return; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 158 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
155 if (hs) { | 159 if (hs) { |
156 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); | 160 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); |
157 if (entry) { | 161 if (entry) { |
158 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), | 162 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), |
159 base::Time::Now()); | 163 base::Time::Now()); |
160 } | 164 } |
161 hs->ClearCachedDataForContextID(tab); | 165 hs->ClearCachedDataForContextID(tab); |
162 } | 166 } |
163 } | 167 } |
OLD | NEW |