summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 00:19:18 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 00:19:18 +0000
commit66ee443252fd759c5e20cb93be1e90a732da0ebe (patch)
tree5ee39c6ee0c62c8feba5103836a36d28203b7b54 /chrome/browser/autocomplete/autocomplete.cc
parentcbadedd7a2cdc20a745ff8b51922b2533169f7b0 (diff)
downloadchromium_src-66ee443252fd759c5e20cb93be1e90a732da0ebe.zip
chromium_src-66ee443252fd759c5e20cb93be1e90a732da0ebe.tar.gz
chromium_src-66ee443252fd759c5e20cb93be1e90a732da0ebe.tar.bz2
Show the location bar icon (almost) all the time, and have its contents match what the user is doing.
There are a couple major moving parts here: * Change AutocompletePopupModel::URLsForCurrentText() to InfoForCurrentText() and have it return an AutocompleteMatch, which callers can use to parse out whatever they want. I needed to get at the match type for the current text and found the proliferation of arguments here ridiculous. This had major ripple effects throughout the codebase, including changing the name and location of SearchVersusNavigateClassifier as it no longer had an "is_search" parameter directly, so the name became misleading and too narrow. I also ended up adding a null constructor for AutocompleteMatch because it was too cumbersome otherwise. * Change the name of the "SecurityImageView" (or similar) to reflect its broader purpose, and plumb it to the edit to get an icon instead of to the toolbar model. * Add an AutocompleteMatch::Type to icon mapping function, and use it not only in the new code but also to simplify showing the popup contents. BUG=27570,39725 TEST=An icon should appear next to the address at all times. It should be a globe on non-secure pages, a magnifying glass on the NTP, and a match for whatever the user is typing as he types. Review URL: http://codereview.chromium.org/1457002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43025 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc64
1 files changed, 47 insertions, 17 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index 2167ea2..db1655b 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -27,6 +27,7 @@
#include "googleurl/src/url_canon_ip.h"
#include "googleurl/src/url_util.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
#include "net/base/net_util.h"
#include "net/base/registry_controlled_domain.h"
#include "net/url_request/url_request.h"
@@ -367,6 +368,18 @@ void AutocompleteInput::Clear() {
// AutocompleteMatch ----------------------------------------------------------
+AutocompleteMatch::AutocompleteMatch()
+ : provider(NULL),
+ relevance(0),
+ deletable(false),
+ inline_autocomplete_offset(std::wstring::npos),
+ transition(PageTransition::GENERATED),
+ is_history_what_you_typed_match(false),
+ type(SEARCH_WHAT_YOU_TYPED),
+ template_url(NULL),
+ starred(false) {
+}
+
AutocompleteMatch::AutocompleteMatch(AutocompleteProvider* provider,
int relevance,
bool deletable,
@@ -384,23 +397,40 @@ AutocompleteMatch::AutocompleteMatch(AutocompleteProvider* provider,
// static
std::string AutocompleteMatch::TypeToString(Type type) {
- switch (type) {
- case URL_WHAT_YOU_TYPED: return "url-what-you-typed";
- case HISTORY_URL: return "history-url";
- case HISTORY_TITLE: return "history-title";
- case HISTORY_BODY: return "history-body";
- case HISTORY_KEYWORD: return "history-keyword";
- case NAVSUGGEST: return "navsuggest";
- case SEARCH_WHAT_YOU_TYPED: return "search-what-you-typed";
- case SEARCH_HISTORY: return "search-history";
- case SEARCH_SUGGEST: return "search-suggest";
- case SEARCH_OTHER_ENGINE: return "search-other-engine";
- case OPEN_HISTORY_PAGE: return "open-history-page";
+ const char* strings[NUM_TYPES] = {
+ "url-what-you-typed",
+ "history-url",
+ "history-title",
+ "history-body",
+ "history-keyword",
+ "navsuggest",
+ "search-what-you-typed",
+ "search-history",
+ "search-suggest",
+ "search-other-engine",
+ "open-history-page",
+ };
+ DCHECK(arraysize(strings) == NUM_TYPES);
+ return strings[type];
+}
- default:
- NOTREACHED();
- return std::string();
- }
+// static
+int AutocompleteMatch::TypeToIcon(Type type) {
+ int icons[NUM_TYPES] = {
+ IDR_O2_GLOBE,
+ IDR_O2_GLOBE,
+ IDR_O2_HISTORY,
+ IDR_O2_HISTORY,
+ IDR_O2_HISTORY,
+ IDR_O2_GLOBE,
+ IDR_O2_SEARCH,
+ IDR_O2_SEARCH,
+ IDR_O2_SEARCH,
+ IDR_O2_SEARCH,
+ IDR_O2_MORE,
+ };
+ DCHECK(arraysize(icons) == NUM_TYPES);
+ return icons[type];
}
// static