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