| 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 "athena/extensions/shell/url_search_provider.h" | 5 #include "athena/extensions/shell/url_search_provider.h" |
| 6 | 6 |
| 7 #include "athena/activity/public/activity.h" | 7 #include "athena/activity/public/activity.h" |
| 8 #include "athena/activity/public/activity_factory.h" | 8 #include "athena/activity/public/activity_factory.h" |
| 9 #include "athena/extensions/shell/athena_shell_scheme_classifier.h" | 9 #include "athena/extensions/shell/athena_shell_scheme_classifier.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 virtual const AutocompleteSchemeClassifier& SchemeClassifier() override { | 84 virtual const AutocompleteSchemeClassifier& SchemeClassifier() override { |
| 85 return scheme_classifier_; | 85 return scheme_classifier_; |
| 86 } | 86 } |
| 87 virtual void Classify( | 87 virtual void Classify( |
| 88 const base::string16& text, | 88 const base::string16& text, |
| 89 bool prefer_keyword, | 89 bool prefer_keyword, |
| 90 bool allow_exact_keyword_match, | 90 bool allow_exact_keyword_match, |
| 91 metrics::OmniboxEventProto::PageClassification page_classification, | 91 metrics::OmniboxEventProto::PageClassification page_classification, |
| 92 AutocompleteMatch* match, | 92 AutocompleteMatch* match, |
| 93 GURL* alternate_nav_url) override {} | 93 GURL* alternate_nav_url) override {} |
| 94 virtual history::URLDatabase* InMemoryDatabase() override { return NULL; } | 94 virtual history::URLDatabase* InMemoryDatabase() override { return nullptr; } |
| 95 virtual void DeleteMatchingURLsForKeywordFromHistory( | 95 virtual void DeleteMatchingURLsForKeywordFromHistory( |
| 96 history::KeywordID keyword_id, | 96 history::KeywordID keyword_id, |
| 97 const base::string16& term) override {} | 97 const base::string16& term) override {} |
| 98 virtual bool TabSyncEnabledAndUnencrypted() override { return false; } | 98 virtual bool TabSyncEnabledAndUnencrypted() override { return false; } |
| 99 virtual void PrefetchImage(const GURL& url) override {} | 99 virtual void PrefetchImage(const GURL& url) override {} |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 content::BrowserContext* browser_context_; | 102 content::BrowserContext* browser_context_; |
| 103 AthenaShellSchemeClassifier scheme_classifier_; | 103 AthenaShellSchemeClassifier scheme_classifier_; |
| 104 | 104 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 DISALLOW_COPY_AND_ASSIGN(UrlSearchResult); | 202 DISALLOW_COPY_AND_ASSIGN(UrlSearchResult); |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 } // namespace | 205 } // namespace |
| 206 | 206 |
| 207 UrlSearchProvider::UrlSearchProvider(content::BrowserContext* browser_context) | 207 UrlSearchProvider::UrlSearchProvider(content::BrowserContext* browser_context) |
| 208 : browser_context_(browser_context), | 208 : browser_context_(browser_context), |
| 209 // TODO(mukai): introduce the real parameters when it's necessary. | 209 // TODO(mukai): introduce the real parameters when it's necessary. |
| 210 template_url_service_(new TemplateURLService( | 210 template_url_service_(new TemplateURLService( |
| 211 NULL /* prefs */, | 211 nullptr /* prefs */, |
| 212 scoped_ptr<SearchTermsData>(new AthenaSearchTermsData()), | 212 scoped_ptr<SearchTermsData>(new AthenaSearchTermsData()), |
| 213 NULL /* KeywordWebDataService */, | 213 nullptr /* KeywordWebDataService */, |
| 214 scoped_ptr<TemplateURLServiceClient>( | 214 scoped_ptr<TemplateURLServiceClient>( |
| 215 new AthenaTemplateURLServiceClient()), | 215 new AthenaTemplateURLServiceClient()), |
| 216 NULL /*GoogleURLTracker */, | 216 nullptr /*GoogleURLTracker */, |
| 217 NULL /* RapporService */, | 217 nullptr /* RapporService */, |
| 218 base::Closure() /* dsp_change_callback */)), | 218 base::Closure() /* dsp_change_callback */)), |
| 219 provider_(new ::SearchProvider( | 219 provider_(new ::SearchProvider( |
| 220 this, | 220 this, |
| 221 template_url_service_.get(), | 221 template_url_service_.get(), |
| 222 scoped_ptr<AutocompleteProviderClient>( | 222 scoped_ptr<AutocompleteProviderClient>( |
| 223 new AthenaAutocompleteProviderClient(browser_context_)))) { | 223 new AthenaAutocompleteProviderClient(browser_context_)))) { |
| 224 template_url_service_->Load(); | 224 template_url_service_->Load(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 UrlSearchProvider::~UrlSearchProvider() { | 227 UrlSearchProvider::~UrlSearchProvider() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 241 AthenaShellSchemeClassifier()); | 241 AthenaShellSchemeClassifier()); |
| 242 | 242 |
| 243 // Clearing results here may cause unexpected results. | 243 // Clearing results here may cause unexpected results. |
| 244 // TODO(mukai): fix this by fixing crbug.com/415500 | 244 // TODO(mukai): fix this by fixing crbug.com/415500 |
| 245 if (!minimal_changes) | 245 if (!minimal_changes) |
| 246 ClearResults(); | 246 ClearResults(); |
| 247 | 247 |
| 248 if (input_.type() == metrics::OmniboxInputType::URL) { | 248 if (input_.type() == metrics::OmniboxInputType::URL) { |
| 249 // TODO(hashimoto): Componentize HistoryURLProvider and remove this code. | 249 // TODO(hashimoto): Componentize HistoryURLProvider and remove this code. |
| 250 AutocompleteMatch what_you_typed_match( | 250 AutocompleteMatch what_you_typed_match( |
| 251 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 251 nullptr, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
| 252 what_you_typed_match.destination_url = input_.canonicalized_url(); | 252 what_you_typed_match.destination_url = input_.canonicalized_url(); |
| 253 what_you_typed_match.contents = input_.text(); | 253 what_you_typed_match.contents = input_.text(); |
| 254 what_you_typed_match.relevance = kScoreForWhatYouTypedResult; | 254 what_you_typed_match.relevance = kScoreForWhatYouTypedResult; |
| 255 Add(scoped_ptr<app_list::SearchResult>( | 255 Add(scoped_ptr<app_list::SearchResult>( |
| 256 new UrlSearchResult(browser_context_, what_you_typed_match))); | 256 new UrlSearchResult(browser_context_, what_you_typed_match))); |
| 257 } | 257 } |
| 258 | 258 |
| 259 provider_->Start(input_, minimal_changes); | 259 provider_->Start(input_, minimal_changes); |
| 260 } | 260 } |
| 261 | 261 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 272 ++it) { | 272 ++it) { |
| 273 if (!it->destination_url.is_valid()) | 273 if (!it->destination_url.is_valid()) |
| 274 continue; | 274 continue; |
| 275 | 275 |
| 276 Add(scoped_ptr<app_list::SearchResult>( | 276 Add(scoped_ptr<app_list::SearchResult>( |
| 277 new UrlSearchResult(browser_context_, *it))); | 277 new UrlSearchResult(browser_context_, *it))); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace athena | 281 } // namespace athena |
| OLD | NEW |