| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/search_engines/chrome_template_url_service_client.h" | 5 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "components/history/core/browser/history_service.h" | 8 #include "components/history/core/browser/history_service.h" |
| 9 #include "components/search_engines/template_url_service.h" | 9 #include "components/search_engines/template_url_service.h" |
| 10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 const base::string16& term) { | 53 const base::string16& term) { |
| 54 if (history_service_) | 54 if (history_service_) |
| 55 history_service_->SetKeywordSearchTermsForURL(url, id, term); | 55 history_service_->SetKeywordSearchTermsForURL(url, id, term); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ChromeTemplateURLServiceClient::AddKeywordGeneratedVisit(const GURL& url) { | 58 void ChromeTemplateURLServiceClient::AddKeywordGeneratedVisit(const GURL& url) { |
| 59 if (history_service_) | 59 if (history_service_) |
| 60 history_service_->AddPage(url, base::Time::Now(), NULL, 0, GURL(), | 60 history_service_->AddPage(url, base::Time::Now(), NULL, 0, GURL(), |
| 61 history::RedirectList(), | 61 history::RedirectList(), |
| 62 ui::PAGE_TRANSITION_KEYWORD_GENERATED, | 62 ui::PAGE_TRANSITION_KEYWORD_GENERATED, |
| 63 history::SOURCE_BROWSED, false); | 63 history::SOURCE_BROWSED, base::nullopt); |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool ChromeTemplateURLServiceClient::IsOmniboxExtensionURL( | 66 bool ChromeTemplateURLServiceClient::IsOmniboxExtensionURL( |
| 67 const std::string& url) { | 67 const std::string& url) { |
| 68 return GURL(url).SchemeIs(extensions::kExtensionScheme); | 68 return GURL(url).SchemeIs(extensions::kExtensionScheme); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void ChromeTemplateURLServiceClient::OnURLVisited( | 71 void ChromeTemplateURLServiceClient::OnURLVisited( |
| 72 history::HistoryService* history_service, | 72 history::HistoryService* history_service, |
| 73 ui::PageTransition transition, | 73 ui::PageTransition transition, |
| 74 const history::URLRow& row, | 74 const history::URLRow& row, |
| 75 const history::RedirectList& redirects, | 75 const history::RedirectList& redirects, |
| 76 base::Time visit_time) { | 76 base::Time visit_time) { |
| 77 DCHECK_EQ(history_service_, history_service); | 77 DCHECK_EQ(history_service_, history_service); |
| 78 if (!owner_) | 78 if (!owner_) |
| 79 return; | 79 return; |
| 80 | 80 |
| 81 TemplateURLService::URLVisitedDetails visited_details; | 81 TemplateURLService::URLVisitedDetails visited_details; |
| 82 visited_details.url = row.url(); | 82 visited_details.url = row.url(); |
| 83 visited_details.is_keyword_transition = | 83 visited_details.is_keyword_transition = |
| 84 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_KEYWORD); | 84 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_KEYWORD); |
| 85 owner_->OnHistoryURLVisited(visited_details); | 85 owner_->OnHistoryURLVisited(visited_details); |
| 86 } | 86 } |
| OLD | NEW |