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 |
84 void HistoryTabHelper::DidNavigateMainFrame( | 94 void HistoryTabHelper::DidNavigateMainFrame( |
85 const content::LoadCommittedDetails& details, | 95 const content::LoadCommittedDetails& details, |
86 const content::FrameNavigateParams& params) { | 96 const content::FrameNavigateParams& params) { |
87 // Allow the new page to set the title again. | 97 // Allow the new page to set the title again. |
88 received_page_title_ = false; | 98 received_page_title_ = false; |
89 } | 99 } |
90 | 100 |
91 void HistoryTabHelper::DidNavigateAnyFrame( | 101 void HistoryTabHelper::DidNavigateAnyFrame( |
92 const content::LoadCommittedDetails& details, | 102 const content::LoadCommittedDetails& details, |
93 const content::FrameNavigateParams& params) { | 103 const content::FrameNavigateParams& params) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 147 |
138 if (received_page_title_) | 148 if (received_page_title_) |
139 return; | 149 return; |
140 | 150 |
141 if (title->first) { | 151 if (title->first) { |
142 UpdateHistoryPageTitle(*title->first); | 152 UpdateHistoryPageTitle(*title->first); |
143 received_page_title_ = title->second; | 153 received_page_title_ = title->second; |
144 } | 154 } |
145 } | 155 } |
146 | 156 |
| 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 |
147 HistoryService* HistoryTabHelper::GetHistoryService() { | 177 HistoryService* HistoryTabHelper::GetHistoryService() { |
148 Profile* profile = | 178 Profile* profile = |
149 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 179 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
150 if (profile->IsOffTheRecord()) | 180 if (profile->IsOffTheRecord()) |
151 return NULL; | 181 return NULL; |
152 | 182 |
153 return HistoryServiceFactory::GetForProfile(profile, | 183 return HistoryServiceFactory::GetForProfile(profile, |
154 Profile::IMPLICIT_ACCESS); | 184 Profile::IMPLICIT_ACCESS); |
155 } | 185 } |
156 | 186 |
(...skipping 11 matching lines...) Expand all Loading... |
168 HistoryService* hs = | 198 HistoryService* hs = |
169 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 199 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
170 if (hs) { | 200 if (hs) { |
171 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); | 201 NavigationEntry* entry = tab->GetController().GetLastCommittedEntry(); |
172 if (entry) { | 202 if (entry) { |
173 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), | 203 hs->UpdateWithPageEndTime(tab, entry->GetPageID(), tab->GetURL(), |
174 base::Time::Now()); | 204 base::Time::Now()); |
175 } | 205 } |
176 } | 206 } |
177 } | 207 } |
OLD | NEW |