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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 base::Time timestamp, | 57 base::Time timestamp, |
58 bool did_replace_entry, | 58 bool did_replace_entry, |
| 59 int nav_entry_id, |
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(), nav_entry_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 17 matching lines...) Expand all Loading... |
89 const content::FrameNavigateParams& params) { | 90 const content::FrameNavigateParams& params) { |
90 // Update history. Note that this needs to happen after the entry is complete, | 91 // Update history. Note that this needs to happen after the entry is complete, |
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. |
| 100 NavigationEntry* last_committed = |
| 101 web_contents()->GetController().GetLastCommittedEntry(); |
99 const history::HistoryAddPageArgs& add_page_args = | 102 const history::HistoryAddPageArgs& add_page_args = |
100 CreateHistoryAddPageArgs( | 103 CreateHistoryAddPageArgs( |
101 web_contents()->GetURL(), details.entry->GetTimestamp(), | 104 web_contents()->GetURL(), details.entry->GetTimestamp(), |
102 details.did_replace_entry, params); | 105 details.did_replace_entry, last_committed->GetUniqueID(), params); |
103 | 106 |
104 prerender::PrerenderManager* prerender_manager = | 107 prerender::PrerenderManager* prerender_manager = |
105 prerender::PrerenderManagerFactory::GetForProfile( | 108 prerender::PrerenderManagerFactory::GetForProfile( |
106 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); | 109 Profile::FromBrowserContext(web_contents()->GetBrowserContext())); |
107 if (prerender_manager) { | 110 if (prerender_manager) { |
108 prerender::PrerenderContents* prerender_contents = | 111 prerender::PrerenderContents* prerender_contents = |
109 prerender_manager->GetPrerenderContents(web_contents()); | 112 prerender_manager->GetPrerenderContents(web_contents()); |
110 if (prerender_contents) { | 113 if (prerender_contents) { |
111 prerender_contents->DidNavigate(add_page_args); | 114 prerender_contents->DidNavigate(add_page_args); |
112 return; | 115 return; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 WebContents* tab = web_contents(); | 151 WebContents* tab = web_contents(); |
149 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); | 152 Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext()); |
150 if (profile->IsOffTheRecord()) | 153 if (profile->IsOffTheRecord()) |
151 return; | 154 return; |
152 | 155 |
153 HistoryService* hs = | 156 HistoryService* hs = |
154 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 157 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
155 if (hs) { | 158 if (hs) { |
156 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); | 159 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); |
157 if (entry) { | 160 if (entry) { |
158 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), | 161 hs->UpdateWithPageEndTime(tab, entry->GetUniqueID(), tab->GetURL(), |
159 base::Time::Now()); | 162 base::Time::Now()); |
160 } | 163 } |
161 hs->ClearCachedDataForContextID(tab); | 164 hs->ClearCachedDataForContextID(tab); |
162 } | 165 } |
163 } | 166 } |
OLD | NEW |