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 "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/history/history_notifications.h" | 8 #include "chrome/browser/history/history_notifications.h" |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 HistoryService* history_service = | 59 HistoryService* history_service = |
60 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 60 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
61 if (history_service) | 61 if (history_service) |
62 history_service->AddPage(url, base::Time::Now(), NULL, 0, GURL(), | 62 history_service->AddPage(url, base::Time::Now(), NULL, 0, GURL(), |
63 history::RedirectList(), | 63 history::RedirectList(), |
64 content::PAGE_TRANSITION_KEYWORD_GENERATED, | 64 ui::PAGE_TRANSITION_KEYWORD_GENERATED, |
65 history::SOURCE_BROWSED, false); | 65 history::SOURCE_BROWSED, false); |
66 } | 66 } |
67 | 67 |
68 void ChromeTemplateURLServiceClient::RestoreExtensionInfoIfNecessary( | 68 void ChromeTemplateURLServiceClient::RestoreExtensionInfoIfNecessary( |
69 TemplateURL* template_url) { | 69 TemplateURL* template_url) { |
70 const TemplateURLData& data = template_url->data(); | 70 const TemplateURLData& data = template_url->data(); |
71 GURL url(data.url()); | 71 GURL url(data.url()); |
72 if (url.SchemeIs(extensions::kExtensionScheme)) { | 72 if (url.SchemeIs(extensions::kExtensionScheme)) { |
73 const std::string& extension_id = url.host(); | 73 const std::string& extension_id = url.host(); |
74 template_url->set_extension_info(make_scoped_ptr( | 74 template_url->set_extension_info(make_scoped_ptr( |
75 new TemplateURL::AssociatedExtensionInfo( | 75 new TemplateURL::AssociatedExtensionInfo( |
76 TemplateURL::OMNIBOX_API_EXTENSION, extension_id))); | 76 TemplateURL::OMNIBOX_API_EXTENSION, extension_id))); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 void ChromeTemplateURLServiceClient::Observe( | 80 void ChromeTemplateURLServiceClient::Observe( |
81 int type, | 81 int type, |
82 const content::NotificationSource& source, | 82 const content::NotificationSource& source, |
83 const content::NotificationDetails& details) { | 83 const content::NotificationDetails& details) { |
84 DCHECK_EQ(type, chrome::NOTIFICATION_HISTORY_URL_VISITED); | 84 DCHECK_EQ(type, chrome::NOTIFICATION_HISTORY_URL_VISITED); |
85 | 85 |
86 if (!owner_) | 86 if (!owner_) |
87 return; | 87 return; |
88 | 88 |
89 content::Details<history::URLVisitedDetails> history_details(details); | 89 content::Details<history::URLVisitedDetails> history_details(details); |
90 TemplateURLService::URLVisitedDetails visited_details; | 90 TemplateURLService::URLVisitedDetails visited_details; |
91 visited_details.url = history_details->row.url(); | 91 visited_details.url = history_details->row.url(); |
92 visited_details.is_keyword_transition = | 92 visited_details.is_keyword_transition = |
93 content::PageTransitionStripQualifier(history_details->transition) == | 93 ui::PageTransitionStripQualifier(history_details->transition) == |
94 content::PAGE_TRANSITION_KEYWORD; | 94 ui::PAGE_TRANSITION_KEYWORD; |
95 owner_->OnHistoryURLVisited(visited_details); | 95 owner_->OnHistoryURLVisited(visited_details); |
96 } | 96 } |
OLD | NEW |