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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // they saw in the URL bar, so we add the virtual URL as a redirect. This | 75 // they saw in the URL bar, so we add the virtual URL as a redirect. This |
76 // only applies to the main frame, as the virtual URL doesn't apply to | 76 // only applies to the main frame, as the virtual URL doesn't apply to |
77 // sub-frames. | 77 // sub-frames. |
78 add_page_args.url = virtual_url; | 78 add_page_args.url = virtual_url; |
79 if (!add_page_args.redirects.empty()) | 79 if (!add_page_args.redirects.empty()) |
80 add_page_args.redirects.back() = virtual_url; | 80 add_page_args.redirects.back() = virtual_url; |
81 } | 81 } |
82 return add_page_args; | 82 return add_page_args; |
83 } | 83 } |
84 | 84 |
85 bool HistoryTabHelper::OnMessageReceived(const IPC::Message& message) { | |
86 bool handled = true; | |
87 IPC_BEGIN_MESSAGE_MAP(HistoryTabHelper, message) | |
88 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PageContents, OnPageContents) | |
89 IPC_MESSAGE_UNHANDLED(handled = false) | |
90 IPC_END_MESSAGE_MAP() | |
91 | |
92 return handled; | |
93 } | |
94 | |
95 void HistoryTabHelper::DidNavigateMainFrame( | 85 void HistoryTabHelper::DidNavigateMainFrame( |
96 const content::LoadCommittedDetails& details, | 86 const content::LoadCommittedDetails& details, |
97 const content::FrameNavigateParams& params) { | 87 const content::FrameNavigateParams& params) { |
98 // Allow the new page to set the title again. | 88 // Allow the new page to set the title again. |
99 received_page_title_ = false; | 89 received_page_title_ = false; |
100 } | 90 } |
101 | 91 |
102 void HistoryTabHelper::DidNavigateAnyFrame( | 92 void HistoryTabHelper::DidNavigateAnyFrame( |
103 const content::LoadCommittedDetails& details, | 93 const content::LoadCommittedDetails& details, |
104 const content::FrameNavigateParams& params) { | 94 const content::FrameNavigateParams& params) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 145 |
156 if (received_page_title_) | 146 if (received_page_title_) |
157 return; | 147 return; |
158 | 148 |
159 if (title->first) { | 149 if (title->first) { |
160 UpdateHistoryPageTitle(*title->first); | 150 UpdateHistoryPageTitle(*title->first); |
161 received_page_title_ = title->second; | 151 received_page_title_ = title->second; |
162 } | 152 } |
163 } | 153 } |
164 | 154 |
165 void HistoryTabHelper::OnPageContents(const GURL& url, | |
166 int32 page_id, | |
167 const string16& contents) { | |
168 // Don't index any https pages. People generally don't want their bank | |
169 // accounts, etc. indexed on their computer, especially since some of these | |
170 // things are not marked cachable. | |
171 // TODO(brettw) we may want to consider more elaborate heuristics such as | |
172 // the cachability of the page. We may also want to consider subframes (this | |
173 // test will still index subframes if the subframe is SSL). | |
174 // TODO(zelidrag) bug chromium-os:2808 - figure out if we want to reenable | |
175 // content indexing for chromeos in some future releases. | |
176 #if !defined(OS_CHROMEOS) | |
177 if (!url.SchemeIsSecure()) { | |
178 HistoryService* hs = GetHistoryService(); | |
179 if (hs) | |
180 hs->SetPageContents(url, contents); | |
181 } | |
182 #endif | |
183 } | |
184 | |
185 HistoryService* HistoryTabHelper::GetHistoryService() { | 155 HistoryService* HistoryTabHelper::GetHistoryService() { |
186 Profile* profile = | 156 Profile* profile = |
187 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 157 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
188 if (profile->IsOffTheRecord()) | 158 if (profile->IsOffTheRecord()) |
189 return NULL; | 159 return NULL; |
190 | 160 |
191 return HistoryServiceFactory::GetForProfile(profile, | 161 return HistoryServiceFactory::GetForProfile(profile, |
192 Profile::IMPLICIT_ACCESS); | 162 Profile::IMPLICIT_ACCESS); |
193 } | 163 } |
194 | 164 |
(...skipping 11 matching lines...) Expand all Loading... |
206 HistoryService* hs = | 176 HistoryService* hs = |
207 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 177 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
208 if (hs) { | 178 if (hs) { |
209 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); | 179 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); |
210 if (entry) { | 180 if (entry) { |
211 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), | 181 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), |
212 base::Time::Now()); | 182 base::Time::Now()); |
213 } | 183 } |
214 } | 184 } |
215 } | 185 } |
OLD | NEW |