summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete.h19
-rw-r--r--chrome/browser/autocomplete/autocomplete_accessibility.cc2
-rw-r--r--chrome/browser/autocomplete/autocomplete_accessibility.h2
-rw-r--r--[-rwxr-xr-x]chrome/browser/autocomplete/autocomplete_edit.h3
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup.h1
-rw-r--r--chrome/browser/autocomplete/autocomplete_unittest.cc1
-rw-r--r--chrome/browser/autocomplete/edit_drop_target.cc1
-rw-r--r--chrome/browser/autocomplete/edit_drop_target.h1
-rw-r--r--chrome/browser/autocomplete/history_contents_provider.h6
-rw-r--r--chrome/browser/autocomplete/history_url_provider.h7
-rw-r--r--chrome/browser/autocomplete/keyword_provider.cc9
-rw-r--r--chrome/browser/autocomplete/keyword_provider.h25
-rw-r--r--chrome/browser/autocomplete/keyword_provider_unittest.cc1
-rw-r--r--chrome/browser/autocomplete/search_provider.cc35
-rw-r--r--chrome/browser/autocomplete/search_provider.h26
15 files changed, 62 insertions, 77 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h
index d047b62..6f84f02 100644
--- a/chrome/browser/autocomplete/autocomplete.h
+++ b/chrome/browser/autocomplete/autocomplete.h
@@ -5,9 +5,9 @@
#ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_
#define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_
-#include <map>
#include <string>
#include <vector>
+
#include "base/logging.h"
#include "base/ref_counted.h"
#include "base/timer.h"
@@ -140,13 +140,13 @@ typedef std::vector<AutocompleteProvider*> ACProviders;
class AutocompleteInput {
public:
enum Type {
- INVALID, // Empty input
- UNKNOWN, // Valid input whose type cannot be determined
- REQUESTED_URL, // Input autodetected as UNKNOWN, which the user wants to
- // treat as an URL by specifying a desired_tld
- URL, // Input autodetected as a URL
- QUERY, // Input autodetected as a query
- FORCED_QUERY, // Input forced to be a query by an initial '?'
+ INVALID, // Empty input
+ UNKNOWN, // Valid input whose type cannot be determined
+ REQUESTED_URL, // Input autodetected as UNKNOWN, which the user wants to
+ // treat as an URL by specifying a desired_tld
+ URL, // Input autodetected as a URL
+ QUERY, // Input autodetected as a query
+ FORCED_QUERY, // Input forced to be a query by an initial '?'
};
AutocompleteInput()
@@ -155,7 +155,7 @@ class AutocompleteInput {
prefer_keyword_(false),
synchronous_only_(false) {
}
-
+
AutocompleteInput(const std::wstring& text,
const std::wstring& desired_tld,
bool prevent_inline_autocomplete,
@@ -733,7 +733,6 @@ class AutocompleteController : public ACProviderListener {
// Copies |latest_result_| to |result_| and notifies observers of updates.
void CommitResult();
-
// Returns the matches from |provider| whose destination urls are not in
// |latest_result_|.
ACMatches GetMatchesNotInLatestResult(
diff --git a/chrome/browser/autocomplete/autocomplete_accessibility.cc b/chrome/browser/autocomplete/autocomplete_accessibility.cc
index 71a0166..5d61fab 100644
--- a/chrome/browser/autocomplete/autocomplete_accessibility.cc
+++ b/chrome/browser/autocomplete/autocomplete_accessibility.cc
@@ -263,5 +263,3 @@ STDMETHODIMP AutocompleteAccessibility::put_accValue(VARIANT var_id,
// Deprecated.
return DISP_E_MEMBERNOTFOUND;
}
-
-
diff --git a/chrome/browser/autocomplete/autocomplete_accessibility.h b/chrome/browser/autocomplete/autocomplete_accessibility.h
index 3bddf15..cd5f970 100644
--- a/chrome/browser/autocomplete/autocomplete_accessibility.h
+++ b/chrome/browser/autocomplete/autocomplete_accessibility.h
@@ -110,5 +110,3 @@ class ATL_NO_VTABLE AutocompleteAccessibility
DISALLOW_EVIL_CONSTRUCTORS(AutocompleteAccessibility);
};
#endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_ACCESSIBILITY_H_
-
-
diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h
index 5fd07d9..d343e91 100755..100644
--- a/chrome/browser/autocomplete/autocomplete_edit.h
+++ b/chrome/browser/autocomplete/autocomplete_edit.h
@@ -10,7 +10,7 @@
#include <atlcrack.h>
#include <atlctrls.h>
#include <atlmisc.h>
-#include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl
+#include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl.
#include "base/scoped_ptr.h"
#include "chrome/browser/autocomplete/autocomplete.h"
@@ -920,4 +920,3 @@ struct AutocompleteEditState {
};
#endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_
-
diff --git a/chrome/browser/autocomplete/autocomplete_popup.h b/chrome/browser/autocomplete/autocomplete_popup.h
index 6f7808a..980198c 100644
--- a/chrome/browser/autocomplete/autocomplete_popup.h
+++ b/chrome/browser/autocomplete/autocomplete_popup.h
@@ -361,4 +361,3 @@ class AutocompletePopupModel : public NotificationObserver {
};
#endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_H_
-
diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc
index 7e9800c..53605f7 100644
--- a/chrome/browser/autocomplete/autocomplete_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_unittest.cc
@@ -273,4 +273,3 @@ TEST(AutocompleteMatch, MoreRelevant) {
AutocompleteMatch::MoreRelevant(m1, m2));
}
}
-
diff --git a/chrome/browser/autocomplete/edit_drop_target.cc b/chrome/browser/autocomplete/edit_drop_target.cc
index 64f824d..abe1566 100644
--- a/chrome/browser/autocomplete/edit_drop_target.cc
+++ b/chrome/browser/autocomplete/edit_drop_target.cc
@@ -150,4 +150,3 @@ void EditDropTarget::ResetDropHighlights() {
if (drag_has_string_)
edit_->SetDropHighlightPosition(-1);
}
-
diff --git a/chrome/browser/autocomplete/edit_drop_target.h b/chrome/browser/autocomplete/edit_drop_target.h
index 4cd2f00..c032544 100644
--- a/chrome/browser/autocomplete/edit_drop_target.h
+++ b/chrome/browser/autocomplete/edit_drop_target.h
@@ -56,4 +56,3 @@ class EditDropTarget : public BaseDropTarget {
};
#endif // CHROME_BROWSER_AUTOCOMPLETE_EDIT_DROP_TARGET_H_
-
diff --git a/chrome/browser/autocomplete/history_contents_provider.h b/chrome/browser/autocomplete/history_contents_provider.h
index ff7cd3d..7cb72dd 100644
--- a/chrome/browser/autocomplete/history_contents_provider.h
+++ b/chrome/browser/autocomplete/history_contents_provider.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H__
-#define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H__
+#ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_
+#define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
@@ -93,4 +93,4 @@ class HistoryContentsProvider : public AutocompleteProvider {
DISALLOW_EVIL_CONSTRUCTORS(HistoryContentsProvider);
};
-#endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H__
+#endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_
diff --git a/chrome/browser/autocomplete/history_url_provider.h b/chrome/browser/autocomplete/history_url_provider.h
index 92ee730..0c1260a 100644
--- a/chrome/browser/autocomplete/history_url_provider.h
+++ b/chrome/browser/autocomplete/history_url_provider.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H__
-#define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H__
+#ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
+#define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
#include <map>
#include <vector>
@@ -390,5 +390,4 @@ class HistoryURLProvider : public AutocompleteProvider {
HistoryURLProviderParams* params_;
};
-#endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H__
-
+#endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_URL_PROVIDER_H_
diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc
index c267956..92ee1de 100644
--- a/chrome/browser/autocomplete/keyword_provider.cc
+++ b/chrome/browser/autocomplete/keyword_provider.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/autocomplete/keyword_provider.h"
#include <algorithm>
+#include <vector>
#include "base/string_util.h"
#include "chrome/browser/profile.h"
@@ -40,7 +41,10 @@ KeywordProvider::KeywordProvider(ACProviderListener* listener,
}
-class KeywordProvider::CompareQuality {
+namespace {
+
+// Helper functor for Start(), for sorting keyword matches by quality.
+class CompareQuality {
public:
// A keyword is of higher quality when a greater fraction of it has been
// typed, that is, when it is shorter.
@@ -55,6 +59,8 @@ class KeywordProvider::CompareQuality {
}
};
+} // namespace
+
void KeywordProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
matches_.clear();
@@ -276,4 +282,3 @@ AutocompleteMatch KeywordProvider::CreateAutocompleteMatch(
return result;
}
-
diff --git a/chrome/browser/autocomplete/keyword_provider.h b/chrome/browser/autocomplete/keyword_provider.h
index dab7ad3..4c8acc7 100644
--- a/chrome/browser/autocomplete/keyword_provider.h
+++ b/chrome/browser/autocomplete/keyword_provider.h
@@ -2,30 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// This file contains the keyword autocomplete provider. The keyword provider is
-// responsible for remembering/suggesting user "search keyword queries" (e.g.
-// "imdb Godzilla") and then fixing them up into valid URLs. An instance of it
-// gets created and managed by the autocomplete controller. KeywordProvider
-// uses a TemplateURLModel to find the set of keywords.
+// This file contains the keyword autocomplete provider. The keyword provider
+// is responsible for remembering/suggesting user "search keyword queries"
+// (e.g. "imdb Godzilla") and then fixing them up into valid URLs. An
+// instance of it gets created and managed by the autocomplete controller.
+// KeywordProvider uses a TemplateURLModel to find the set of keywords.
//
// For more information on the autocomplete system in general, including how
// the autocomplete controller and autocomplete providers work, see
// chrome/browser/autocomplete.h.
-#ifndef CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H__
-#define CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H__
+#ifndef CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_
+#define CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_
-#include <map>
#include <string>
-#include <vector>
+
#include "chrome/browser/autocomplete/autocomplete.h"
class Profile;
class TemplateURL;
class TemplateURLModel;
-/****************************** KeywordProvider ******************************/
-
// Autocomplete provider for keyword input.
//
// After construction, the autocomplete controller repeatedly calls Start()
@@ -65,9 +62,6 @@ class KeywordProvider : public AutocompleteProvider {
bool minimal_changes);
private:
- // Helper functor for Start(), for sorting keyword matches by quality.
- class CompareQuality;
-
// Extracts the next whitespace-delimited token from input and returns it.
// Sets |remaining_input| to everything after the first token (skipping over
// intervening whitespace).
@@ -104,5 +98,4 @@ class KeywordProvider : public AutocompleteProvider {
DISALLOW_EVIL_CONSTRUCTORS(KeywordProvider);
};
-#endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H__
-
+#endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_
diff --git a/chrome/browser/autocomplete/keyword_provider_unittest.cc b/chrome/browser/autocomplete/keyword_provider_unittest.cc
index a650701..941c96b 100644
--- a/chrome/browser/autocomplete/keyword_provider_unittest.cc
+++ b/chrome/browser/autocomplete/keyword_provider_unittest.cc
@@ -192,4 +192,3 @@ TEST_F(KeywordProviderTest, RemoveKeyword) {
model_->Remove(model_->GetTemplateURLForKeyword(L"aaaa"));
ASSERT_TRUE(model_->GetTemplateURLForKeyword(L"aaaa") == NULL);
}
-
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 1b51449..23d4407c 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -25,20 +25,17 @@
using base::Time;
using base::TimeDelta;
-const int SearchProvider::kQueryDelayMs = 200;
-
void SearchProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
matches_.clear();
- // Can't return search/suggest results for bogus input or if there is no
- // profile.
+ // Can't return search/suggest results for bogus input or without a profile.
if (!profile_ || (input.type() == AutocompleteInput::INVALID)) {
Stop();
return;
}
- // Can't search with no default provider.
+ // Can't search without a default provider.
const TemplateURL* const current_default_provider =
profile_->GetTemplateURLModel()->GetDefaultSearchProvider();
// TODO(pkasting): http://b/1155786 Eventually we should not need all these
@@ -118,9 +115,9 @@ void SearchProvider::OnURLFetchComplete(const URLFetcher* source,
const net::HttpResponseHeaders* const response_headers =
source->response_headers();
std::string json_data(data);
- // JSON is supposed to be in UTF-8, but some suggest service
- // providers send JSON files in non-UTF-8 encodings, but they're
- // usually correctly specified in Content-Type header field.
+ // JSON is supposed to be UTF-8, but some suggest service providers send JSON
+ // files in non-UTF-8 encodings. The actual encoding is usually specified in
+ // the Content-Type header field.
if (response_headers) {
std::string charset;
if (response_headers->GetCharset(&charset)) {
@@ -170,6 +167,11 @@ void SearchProvider::StartOrStopHistoryQuery(bool minimal_changes) {
}
void SearchProvider::StartOrStopSuggestQuery(bool minimal_changes) {
+ // Don't send any queries to the server until some time has elapsed after
+ // the last keypress, to avoid flooding the server with requests we are
+ // likely to end up throwing away anyway.
+ static const int kQueryDelayMs = 200;
+
if (!IsQuerySuitableForSuggest()) {
StopSuggest();
return;
@@ -391,13 +393,12 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() {
UpdateStarredStateOfMatches();
- // We're done when both asynchronous subcomponents have finished.
- // We can't use CancelableRequestConsumer.HasPendingRequests() for
- // history requests here. A pending request is not cleared until after the
- // completion callback has returned, but we've reached here from inside that
- // callback. HasPendingRequests() would therefore return true, and if this is
- // the last thing left to calculate for this query, we'll never mark the query
- // "done".
+ // We're done when both asynchronous subcomponents have finished. We can't
+ // use CancelableRequestConsumer.HasPendingRequests() for history requests
+ // here. A pending request is not cleared until after the completion
+ // callback has returned, but we've reached here from inside that callback.
+ // HasPendingRequests() would therefore return true, and if this is the last
+ // thing left to calculate for this query, we'll never mark the query "done".
done_ = !history_request_pending_ &&
!suggest_results_pending_;
}
@@ -433,8 +434,8 @@ int SearchProvider::CalculateRelevanceForHistory(const Time& time) const {
const double elapsed_time = std::max((Time::Now() - time).InSecondsF(), 0.);
const int score_discount = static_cast<int>(6.5 * pow(elapsed_time, 0.3));
- // Don't let scores go below 0. Negative relevance scores are meaningful in a
- // different way.
+ // Don't let scores go below 0. Negative relevance scores are meaningful in
+ // a different way.
int base_score;
switch (input_.type()) {
case AutocompleteInput::UNKNOWN:
diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h
index bda313d..45fd1b3 100644
--- a/chrome/browser/autocomplete/search_provider.h
+++ b/chrome/browser/autocomplete/search_provider.h
@@ -12,8 +12,12 @@
// the autocomplete controller and autocomplete providers work, see
// chrome/browser/autocomplete.h.
-#ifndef CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H__
-#define CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H__
+#ifndef CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_
+#define CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_
+
+#include <map>
+#include <string>
+#include <vector>
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/history/history.h"
@@ -140,21 +144,15 @@ class SearchProvider : public AutocompleteProvider,
// TODO(kochi): this is duplicate from history_autocomplete
static size_t TrimHttpPrefix(std::wstring* url);
- // Don't send any queries to the server until some time has elapsed after
- // the last keypress, to avoid flooding the server with requests we are
- // likely to end up throwing away anyway.
- static const int kQueryDelayMs;
-
// The user's input.
AutocompleteInput input_;
- TemplateURL default_provider_; // Cached across the life of a query so we
- // behave consistently even if the user
- // changes their default while the query is
- // running.
+ // Cached across the life of a query so we behave consistently even if the
+ // user changes their default while the query is running.
+ TemplateURL default_provider_;
+
+ // TODO(pkasting): http://b/1162970 We shouldn't need this.
const TemplateURL* last_default_provider_;
- // TODO(pkasting): http://b/1162970 We
- // shouldn't need this.
// An object we can use to cancel history requests.
CancelableRequestConsumer history_request_consumer_;
@@ -192,4 +190,4 @@ class SearchProvider : public AutocompleteProvider,
DISALLOW_EVIL_CONSTRUCTORS(SearchProvider);
};
-#endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H__
+#endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_