| 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/autocomplete/history_quick_provider.h" | 5 #include "chrome/browser/autocomplete/history_quick_provider.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "content/common/content_notification_types.h" | 25 #include "content/common/content_notification_types.h" |
| 26 #include "content/common/notification_source.h" | 26 #include "content/common/notification_source.h" |
| 27 #include "googleurl/src/url_util.h" | 27 #include "googleurl/src/url_util.h" |
| 28 #include "net/base/escape.h" | 28 #include "net/base/escape.h" |
| 29 #include "net/base/net_util.h" | 29 #include "net/base/net_util.h" |
| 30 | 30 |
| 31 using history::InMemoryURLIndex; | 31 using history::InMemoryURLIndex; |
| 32 using history::ScoredHistoryMatch; | 32 using history::ScoredHistoryMatch; |
| 33 using history::ScoredHistoryMatches; | 33 using history::ScoredHistoryMatches; |
| 34 | 34 |
| 35 bool HistoryQuickProvider::disabled_ = false; |
| 36 |
| 35 HistoryQuickProvider::HistoryQuickProvider(ACProviderListener* listener, | 37 HistoryQuickProvider::HistoryQuickProvider(ACProviderListener* listener, |
| 36 Profile* profile) | 38 Profile* profile) |
| 37 : HistoryProvider(listener, profile, "HistoryQuickProvider"), | 39 : HistoryProvider(listener, profile, "HistoryQuickProvider"), |
| 38 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) {} | 40 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) {} |
| 39 | 41 |
| 40 HistoryQuickProvider::~HistoryQuickProvider() {} | 42 HistoryQuickProvider::~HistoryQuickProvider() {} |
| 41 | 43 |
| 42 void HistoryQuickProvider::Start(const AutocompleteInput& input, | 44 void HistoryQuickProvider::Start(const AutocompleteInput& input, |
| 43 bool minimal_changes) { | 45 bool minimal_changes) { |
| 44 matches_.clear(); | 46 matches_.clear(); |
| 47 if (disabled_) |
| 48 return; |
| 45 | 49 |
| 46 // Don't bother with INVALID and FORCED_QUERY. Also pass when looking for | 50 // Don't bother with INVALID and FORCED_QUERY. Also pass when looking for |
| 47 // BEST_MATCH and there is no inline autocompletion because none of the HQP | 51 // BEST_MATCH and there is no inline autocompletion because none of the HQP |
| 48 // matches can score highly enough to qualify. | 52 // matches can score highly enough to qualify. |
| 49 if ((input.type() == AutocompleteInput::INVALID) || | 53 if ((input.type() == AutocompleteInput::INVALID) || |
| 50 (input.type() == AutocompleteInput::FORCED_QUERY) || | 54 (input.type() == AutocompleteInput::FORCED_QUERY) || |
| 51 (input.matches_requested() == AutocompleteInput::BEST_MATCH && | 55 (input.matches_requested() == AutocompleteInput::BEST_MATCH && |
| 52 input.prevent_inline_autocomplete())) | 56 input.prevent_inline_autocomplete())) |
| 53 return; | 57 return; |
| 54 | 58 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 do { | 246 do { |
| 243 offset += matches[i].length; | 247 offset += matches[i].length; |
| 244 ++i; | 248 ++i; |
| 245 } while ((i < match_count) && (offset == matches[i].offset)); | 249 } while ((i < match_count) && (offset == matches[i].offset)); |
| 246 if (offset < text_length) | 250 if (offset < text_length) |
| 247 spans.push_back(ACMatchClassification(offset, url_style)); | 251 spans.push_back(ACMatchClassification(offset, url_style)); |
| 248 } | 252 } |
| 249 | 253 |
| 250 return spans; | 254 return spans; |
| 251 } | 255 } |
| OLD | NEW |