| 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/main/url_search_provider.h" | 5 #include "athena/main/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/content/public/scheme_classifier_factory.h" | 9 #include "athena/content/public/scheme_classifier_factory.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 // This constant was copied from HistoryURLProvider. | 29 // This constant was copied from HistoryURLProvider. |
| 30 // TODO(hashimoto): Componentize HistoryURLProvider and delete this. | 30 // TODO(hashimoto): Componentize HistoryURLProvider and delete this. |
| 31 const int kScoreForWhatYouTypedResult = 1203; | 31 const int kScoreForWhatYouTypedResult = 1203; |
| 32 | 32 |
| 33 // The SearchTermsData implementation for Athena. | 33 // The SearchTermsData implementation for Athena. |
| 34 class AthenaSearchTermsData : public SearchTermsData { | 34 class AthenaSearchTermsData : public SearchTermsData { |
| 35 public: | 35 public: |
| 36 // SearchTermsData: | 36 // SearchTermsData: |
| 37 virtual std::string GetSuggestClient() const OVERRIDE { | 37 virtual std::string GetSuggestClient() const override { |
| 38 return "chrome"; | 38 return "chrome"; |
| 39 } | 39 } |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 // The templateURLServiceClient for Athena. Mainly for the interaction with | 42 // The templateURLServiceClient for Athena. Mainly for the interaction with |
| 43 // history module (see chrome/browser/search_engines for Chrome implementation). | 43 // history module (see chrome/browser/search_engines for Chrome implementation). |
| 44 // TODO(mukai): Implement the contents of this class when it's necessary. | 44 // TODO(mukai): Implement the contents of this class when it's necessary. |
| 45 class AthenaTemplateURLServiceClient : public TemplateURLServiceClient { | 45 class AthenaTemplateURLServiceClient : public TemplateURLServiceClient { |
| 46 public: | 46 public: |
| 47 AthenaTemplateURLServiceClient() {} | 47 AthenaTemplateURLServiceClient() {} |
| 48 virtual ~AthenaTemplateURLServiceClient() {} | 48 virtual ~AthenaTemplateURLServiceClient() {} |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 // TemplateURLServiceClient: | 51 // TemplateURLServiceClient: |
| 52 virtual void SetOwner(TemplateURLService* owner) OVERRIDE {} | 52 virtual void SetOwner(TemplateURLService* owner) override {} |
| 53 virtual void DeleteAllSearchTermsForKeyword(TemplateURLID id) OVERRIDE {} | 53 virtual void DeleteAllSearchTermsForKeyword(TemplateURLID id) override {} |
| 54 virtual void SetKeywordSearchTermsForURL( | 54 virtual void SetKeywordSearchTermsForURL( |
| 55 const GURL& url, | 55 const GURL& url, |
| 56 TemplateURLID id, | 56 TemplateURLID id, |
| 57 const base::string16& term) OVERRIDE {} | 57 const base::string16& term) override {} |
| 58 virtual void AddKeywordGeneratedVisit(const GURL& url) OVERRIDE {} | 58 virtual void AddKeywordGeneratedVisit(const GURL& url) override {} |
| 59 virtual void RestoreExtensionInfoIfNecessary( | 59 virtual void RestoreExtensionInfoIfNecessary( |
| 60 TemplateURL* template_url) OVERRIDE {} | 60 TemplateURL* template_url) override {} |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(AthenaTemplateURLServiceClient); | 62 DISALLOW_COPY_AND_ASSIGN(AthenaTemplateURLServiceClient); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // The AutocompleteProviderClient for Athena. | 65 // The AutocompleteProviderClient for Athena. |
| 66 class AthenaAutocompleteProviderClient : public AutocompleteProviderClient { | 66 class AthenaAutocompleteProviderClient : public AutocompleteProviderClient { |
| 67 public: | 67 public: |
| 68 explicit AthenaAutocompleteProviderClient( | 68 explicit AthenaAutocompleteProviderClient( |
| 69 content::BrowserContext* browser_context) | 69 content::BrowserContext* browser_context) |
| 70 : browser_context_(browser_context), | 70 : browser_context_(browser_context), |
| 71 scheme_classifier_(CreateSchemeClassifier(browser_context)) {} | 71 scheme_classifier_(CreateSchemeClassifier(browser_context)) {} |
| 72 virtual ~AthenaAutocompleteProviderClient() {} | 72 virtual ~AthenaAutocompleteProviderClient() {} |
| 73 | 73 |
| 74 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE { | 74 virtual net::URLRequestContextGetter* RequestContext() override { |
| 75 return browser_context_->GetRequestContext(); | 75 return browser_context_->GetRequestContext(); |
| 76 } | 76 } |
| 77 virtual bool IsOffTheRecord() OVERRIDE { | 77 virtual bool IsOffTheRecord() override { |
| 78 return browser_context_->IsOffTheRecord(); | 78 return browser_context_->IsOffTheRecord(); |
| 79 } | 79 } |
| 80 virtual std::string AcceptLanguages() OVERRIDE { | 80 virtual std::string AcceptLanguages() override { |
| 81 // TODO(hashimoto): Return the value stored in the prefs. | 81 // TODO(hashimoto): Return the value stored in the prefs. |
| 82 return "en-US"; | 82 return "en-US"; |
| 83 } | 83 } |
| 84 virtual bool SearchSuggestEnabled() OVERRIDE { return true; } | 84 virtual bool SearchSuggestEnabled() override { return true; } |
| 85 virtual bool ShowBookmarkBar() OVERRIDE { return false; } | 85 virtual bool ShowBookmarkBar() override { return false; } |
| 86 virtual const AutocompleteSchemeClassifier& SchemeClassifier() OVERRIDE { | 86 virtual const AutocompleteSchemeClassifier& SchemeClassifier() override { |
| 87 return *scheme_classifier_; | 87 return *scheme_classifier_; |
| 88 } | 88 } |
| 89 virtual void Classify( | 89 virtual void Classify( |
| 90 const base::string16& text, | 90 const base::string16& text, |
| 91 bool prefer_keyword, | 91 bool prefer_keyword, |
| 92 bool allow_exact_keyword_match, | 92 bool allow_exact_keyword_match, |
| 93 metrics::OmniboxEventProto::PageClassification page_classification, | 93 metrics::OmniboxEventProto::PageClassification page_classification, |
| 94 AutocompleteMatch* match, | 94 AutocompleteMatch* match, |
| 95 GURL* alternate_nav_url) OVERRIDE {} | 95 GURL* alternate_nav_url) override {} |
| 96 virtual history::URLDatabase* InMemoryDatabase() OVERRIDE { return NULL; } | 96 virtual history::URLDatabase* InMemoryDatabase() override { return NULL; } |
| 97 virtual void DeleteMatchingURLsForKeywordFromHistory( | 97 virtual void DeleteMatchingURLsForKeywordFromHistory( |
| 98 history::KeywordID keyword_id, | 98 history::KeywordID keyword_id, |
| 99 const base::string16& term) OVERRIDE {} | 99 const base::string16& term) override {} |
| 100 virtual bool TabSyncEnabledAndUnencrypted() OVERRIDE { return false; } | 100 virtual bool TabSyncEnabledAndUnencrypted() override { return false; } |
| 101 virtual void PrefetchImage(const GURL& url) OVERRIDE {} | 101 virtual void PrefetchImage(const GURL& url) override {} |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 content::BrowserContext* browser_context_; | 104 content::BrowserContext* browser_context_; |
| 105 scoped_ptr<AutocompleteSchemeClassifier> scheme_classifier_; | 105 scoped_ptr<AutocompleteSchemeClassifier> scheme_classifier_; |
| 106 | 106 |
| 107 DISALLOW_COPY_AND_ASSIGN(AthenaAutocompleteProviderClient); | 107 DISALLOW_COPY_AND_ASSIGN(AthenaAutocompleteProviderClient); |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 int ACMatchStyleToTagStyle(int styles) { | 110 int ACMatchStyleToTagStyle(int styles) { |
| 111 int tag_styles = 0; | 111 int tag_styles = 0; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 set_relevance(match_.relevance / 1500.0); | 164 set_relevance(match_.relevance / 1500.0); |
| 165 | 165 |
| 166 UpdateIcon(); | 166 UpdateIcon(); |
| 167 UpdateTitleAndDetails(); | 167 UpdateTitleAndDetails(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 virtual ~UrlSearchResult() {} | 170 virtual ~UrlSearchResult() {} |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 // Overriddenn from app_list::SearchResult: | 173 // Overriddenn from app_list::SearchResult: |
| 174 virtual void Open(int event_flags) OVERRIDE { | 174 virtual void Open(int event_flags) override { |
| 175 Activity* activity = ActivityFactory::Get()->CreateWebActivity( | 175 Activity* activity = ActivityFactory::Get()->CreateWebActivity( |
| 176 browser_context_, base::string16(), match_.destination_url); | 176 browser_context_, base::string16(), match_.destination_url); |
| 177 Activity::Show(activity); | 177 Activity::Show(activity); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void UpdateIcon() { | 180 void UpdateIcon() { |
| 181 SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 181 SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 182 AutocompleteMatch::TypeToIcon(match_.type))); | 182 AutocompleteMatch::TypeToIcon(match_.type))); |
| 183 } | 183 } |
| 184 | 184 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 ++it) { | 277 ++it) { |
| 278 if (!it->destination_url.is_valid()) | 278 if (!it->destination_url.is_valid()) |
| 279 continue; | 279 continue; |
| 280 | 280 |
| 281 Add(scoped_ptr<app_list::SearchResult>(new UrlSearchResult( | 281 Add(scoped_ptr<app_list::SearchResult>(new UrlSearchResult( |
| 282 browser_context_, *it))); | 282 browser_context_, *it))); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 } // namespace athena | 286 } // namespace athena |
| OLD | NEW |