| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // deleting some. | 85 // deleting some. |
| 86 static const int kMaxRedirectCount = 32; | 86 static const int kMaxRedirectCount = 32; |
| 87 | 87 |
| 88 // The number of days old a history entry can be before it is considered "old" | 88 // The number of days old a history entry can be before it is considered "old" |
| 89 // and is archived. | 89 // and is archived. |
| 90 static const int kArchiveDaysThreshold = 90; | 90 static const int kArchiveDaysThreshold = 90; |
| 91 | 91 |
| 92 // Converts from PageUsageData to MostVisitedURL. |redirects| is a | 92 // Converts from PageUsageData to MostVisitedURL. |redirects| is a |
| 93 // list of redirects for this URL. Empty list means no redirects. | 93 // list of redirects for this URL. Empty list means no redirects. |
| 94 MostVisitedURL MakeMostVisitedURL(const PageUsageData& page_data, | 94 MostVisitedURL MakeMostVisitedURL(const PageUsageData& page_data, |
| 95 const RedirectList& redirects) { | 95 const RedirectList& redirects) { |
| 96 MostVisitedURL mv; | 96 MostVisitedURL mv; |
| 97 mv.url = page_data.GetURL(); | 97 mv.url = page_data.GetURL(); |
| 98 mv.title = page_data.GetTitle(); | 98 mv.title = page_data.GetTitle(); |
| 99 if (redirects.empty()) { | 99 if (redirects.empty()) { |
| 100 // Redirects must contain at least the target url. | 100 // Redirects must contain at least the target url. |
| 101 mv.redirects.push_back(mv.url); | 101 mv.redirects.push_back(mv.url); |
| 102 } else { | 102 } else { |
| 103 mv.redirects = redirects; | 103 mv.redirects = redirects; |
| 104 if (mv.redirects[mv.redirects.size() - 1] != mv.url) { | 104 if (mv.redirects[mv.redirects.size() - 1] != mv.url) { |
| 105 // The last url must be the target url. | 105 // The last url must be the target url. |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // If the user is adding older history, we need to make sure our times | 399 // If the user is adding older history, we need to make sure our times |
| 400 // are correct. | 400 // are correct. |
| 401 if (request->time < first_recorded_time_) | 401 if (request->time < first_recorded_time_) |
| 402 first_recorded_time_ = request->time; | 402 first_recorded_time_ = request->time; |
| 403 | 403 |
| 404 content::PageTransition transition = | 404 content::PageTransition transition = |
| 405 content::PageTransitionStripQualifier(request->transition); | 405 content::PageTransitionStripQualifier(request->transition); |
| 406 bool is_keyword_generated = | 406 bool is_keyword_generated = |
| 407 (transition == content::PAGE_TRANSITION_KEYWORD_GENERATED); | 407 (transition == content::PAGE_TRANSITION_KEYWORD_GENERATED); |
| 408 | 408 |
| 409 if (request->redirects.size() <= 1) { | 409 // If the user is navigating to a not-previously-typed intranet hostname, |
| 410 // change the transition to TYPED so that the omnibox will learn that this is |
| 411 // a known host. |
| 412 bool has_redirects = request->redirects.size() > 1; |
| 413 if (content::PageTransitionIsMainFrame(request->transition) && |
| 414 (transition != content::PAGE_TRANSITION_TYPED) && !is_keyword_generated) { |
| 415 const GURL& origin_url(has_redirects ? |
| 416 request->redirects[0] : request->url); |
| 417 if (origin_url.SchemeIs(chrome::kHttpScheme)) { |
| 418 std::string host(origin_url.host()); |
| 419 if ((net::RegistryControlledDomainService::GetRegistryLength( |
| 420 host, false) == 0) && !db_->IsTypedHost(host)) { |
| 421 transition = content::PAGE_TRANSITION_TYPED; |
| 422 request->transition = content::PageTransitionFromInt(transition | |
| 423 content::PageTransitionGetQualifier(request->transition)); |
| 424 } |
| 425 } |
| 426 } |
| 427 |
| 428 if (!has_redirects) { |
| 410 // The single entry is both a chain start and end. | 429 // The single entry is both a chain start and end. |
| 411 content::PageTransition t = content::PageTransitionFromInt( | 430 content::PageTransition t = content::PageTransitionFromInt( |
| 412 request->transition | | 431 request->transition | |
| 413 content::PAGE_TRANSITION_CHAIN_START | | 432 content::PAGE_TRANSITION_CHAIN_START | |
| 414 content::PAGE_TRANSITION_CHAIN_END); | 433 content::PAGE_TRANSITION_CHAIN_END); |
| 415 | 434 |
| 416 // No redirect case (one element means just the page itself). | 435 // No redirect case (one element means just the page itself). |
| 417 last_ids = AddPageVisit(request->url, last_recorded_time_, | 436 last_ids = AddPageVisit(request->url, last_recorded_time_, |
| 418 last_ids.second, t, request->visit_source); | 437 last_ids.second, t, request->visit_source); |
| 419 | 438 |
| (...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2271 break; | 2290 break; |
| 2272 } | 2291 } |
| 2273 } | 2292 } |
| 2274 } | 2293 } |
| 2275 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name | 2294 UMA_HISTOGRAM_TIMES("History.GetFavIconFromDB", // historical name |
| 2276 TimeTicks::Now() - beginning_time); | 2295 TimeTicks::Now() - beginning_time); |
| 2277 return success; | 2296 return success; |
| 2278 } | 2297 } |
| 2279 | 2298 |
| 2280 } // namespace history | 2299 } // namespace history |
| OLD | NEW |