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