summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 19:32:15 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 19:32:15 +0000
commit1d73faa8d5eea35b1141779e5310a9ababdd798a (patch)
treed6d2373c4a3fcc3c65d7ccae8e5bfe61963d129f /chrome/browser/autocomplete
parent553dba6dd707ee02e609910462d2b7977f284af2 (diff)
downloadchromium_src-1d73faa8d5eea35b1141779e5310a9ababdd798a.zip
chromium_src-1d73faa8d5eea35b1141779e5310a9ababdd798a.tar.gz
chromium_src-1d73faa8d5eea35b1141779e5310a9ababdd798a.tar.bz2
Make autocomplete.cc and dependencies compile on Posix.
Review URL: http://codereview.chromium.org/28061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10277 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc22
-rw-r--r--chrome/browser/autocomplete/history_contents_provider.h2
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc27
-rw-r--r--chrome/browser/autocomplete/search_provider.cc10
4 files changed, 45 insertions, 16 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index a735947..bbd4509 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
#include "chrome/browser/autocomplete/autocomplete.h"
#include <algorithm>
@@ -12,8 +14,6 @@
#include "chrome/browser/autocomplete/keyword_provider.h"
#include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "chrome/browser/external_protocol_handler.h"
-#include "chrome/browser/history_tab_ui.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profile.h"
#include "chrome/common/gfx/text_elider.h"
@@ -26,6 +26,15 @@
#include "grit/generated_resources.h"
#include "net/base/net_util.h"
#include "net/base/registry_controlled_domain.h"
+#include "net/url_request/url_request.h"
+
+// TODO(port): Port this file.
+#if defined(OS_WIN)
+#include "chrome/browser/external_protocol_handler.h"
+#include "chrome/browser/history_tab_ui.h"
+#else
+#include "chrome/common/temp_scaffolding_stubs.h"
+#endif
using base::TimeDelta;
@@ -176,7 +185,8 @@ AutocompleteInput::Type AutocompleteInput::Parse(const std::wstring& text,
// more likely a search (for the answer to a math problem) than a URL.
url_parse::Component components[4];
const bool found_ipv4 =
- url_canon::FindIPv4Components(text.c_str(), parts->host, components);
+ url_canon::FindIPv4Components(WideToUTF8(text).c_str(),
+ parts->host, components);
DCHECK(found_ipv4);
for (size_t i = 0; i < arraysize(components); ++i) {
if (!components[i].is_nonempty())
@@ -418,9 +428,15 @@ void AutocompleteProvider::SetProfile(Profile* profile) {
std::wstring AutocompleteProvider::StringForURLDisplay(
const GURL& url,
bool check_accept_lang) {
+#if !defined(OS_MACOSX)
return gfx::ElideUrl(url, ChromeFont(), 0, check_accept_lang && profile_ ?
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) :
std::wstring());
+#else
+ // TODO(port): need gfx::ElideUrl and ChromeFont
+ NOTIMPLEMENTED();
+ return std::wstring();
+#endif
}
void AutocompleteProvider::UpdateStarredStateOfMatches() {
diff --git a/chrome/browser/autocomplete/history_contents_provider.h b/chrome/browser/autocomplete/history_contents_provider.h
index ea02ff2..ff7cd3d 100644
--- a/chrome/browser/autocomplete/history_contents_provider.h
+++ b/chrome/browser/autocomplete/history_contents_provider.h
@@ -37,7 +37,7 @@ class HistoryContentsProvider : public AutocompleteProvider {
// The maximum match count we'll report. If the db_match_count is greater
// than this, it will be clamped to this result.
- static const int kMaxMatchCount = 50;
+ static const size_t kMaxMatchCount = 50;
private:
void QueryComplete(HistoryService::Handle handle,
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index 309aa31..539eac78 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
#include "chrome/browser/autocomplete/history_url_provider.h"
#include <algorithm>
@@ -225,8 +227,8 @@ void HistoryURLProvider::SuggestExactInput(const AutocompleteInput& input,
// suggestion, since it can't be navigated to. We also need this so other
// history suggestions don't duplicate the same effective URL as this.
// TODO(brettw) make autocomplete use GURL!
- GURL canonicalized_url(URLFixerUpper::FixupURL(input.text(),
- input.desired_tld()));
+ GURL canonicalized_url(URLFixerUpper::FixupURL(WideToUTF8(input.text()),
+ WideToUTF8(input.desired_tld())));
if (!canonicalized_url.is_valid() ||
(canonicalized_url.IsStandard() &&
!canonicalized_url.SchemeIsFile() && canonicalized_url.host().empty()))
@@ -288,8 +290,9 @@ bool HistoryURLProvider::FixupExactSuggestion(history::URLDatabase* db,
// This code should match what SuggestExactInput() would do with no
// desired_tld().
// TODO(brettw) make autocomplete use GURL!
- GURL destination_url(URLFixerUpper::FixupURL(params->input.text(),
- std::wstring()));
+ GURL destination_url(
+ URLFixerUpper::FixupURL(WideToUTF8(params->input.text()),
+ std::string()));
if (!db->GetRowForURL(destination_url, &info))
return false;
} else {
@@ -333,7 +336,8 @@ bool HistoryURLProvider::PromoteMatchForInlineAutocomplete(
// static
std::wstring HistoryURLProvider::FixupUserInput(const std::wstring& input) {
// Fixup and canonicalize user input.
- const GURL canonical_gurl(URLFixerUpper::FixupURL(input, std::wstring()));
+ const GURL canonical_gurl(URLFixerUpper::FixupURL(WideToUTF8(input),
+ std::string()));
std::wstring output(UTF8ToWide(canonical_gurl.possibly_invalid_spec()));
if (output.empty())
return input; // This probably won't happen, but there are no guarantees.
@@ -342,7 +346,7 @@ std::wstring HistoryURLProvider::FixupUserInput(const std::wstring& input) {
// upper only prepends the "http" scheme, that's all we need to check for.
url_parse::Component scheme;
if (canonical_gurl.SchemeIs("http") &&
- !url_util::FindAndCompareScheme(input, "http", &scheme))
+ !url_util::FindAndCompareScheme(WideToUTF8(input), "http", &scheme))
TrimHttpPrefix(&output);
// Make the number of trailing slashes on the output exactly match the input.
@@ -377,7 +381,7 @@ std::wstring HistoryURLProvider::FixupUserInput(const std::wstring& input) {
// static
size_t HistoryURLProvider::TrimHttpPrefix(std::wstring* url) {
url_parse::Component scheme;
- if (!url_util::FindAndCompareScheme(*url, "http", &scheme))
+ if (!url_util::FindAndCompareScheme(WideToUTF8(*url), "http", &scheme))
return 0; // Not "http".
// Erase scheme plus up to two slashes.
@@ -589,8 +593,8 @@ void HistoryURLProvider::RunAutocompletePasses(const AutocompleteInput& input,
// Create a match for exactly what the user typed. This will always be one
// of the top two results we return.
- const bool trim_http = !url_util::FindAndCompareScheme(input.text(),
- "http", NULL);
+ const bool trim_http = !url_util::FindAndCompareScheme(
+ WideToUTF8(input.text()), "http", NULL);
SuggestExactInput(input, trim_http);
// We'll need the history service to run both passes, so try to obtain it.
@@ -798,8 +802,13 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch(
CalculateRelevance(params->input.type(), match_type, match_number),
!!info.visit_count(), AutocompleteMatch::HISTORY_URL);
match.destination_url = info.url();
+#if !defined(OS_MACOSX)
match.fill_into_edit = gfx::ElideUrl(info.url(), ChromeFont(), 0,
match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages);
+#else
+ // TODO(port): ChromeFont() and gfx::ElideUrl not implemented on mac.
+ NOTIMPLEMENTED();
+#endif
if (!params->input.prevent_inline_autocomplete()) {
match.inline_autocomplete_offset =
history_match.input_location + params->input.text().length();
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 8e39bd0..8c9a8e3 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "build/build_config.h"
+
#include "chrome/browser/autocomplete/search_provider.h"
#include "base/message_loop.h"
@@ -325,7 +327,8 @@ bool SearchProvider::ParseSuggestResults(Value* root_val) {
site_val->GetAsString(&site_name)) {
// We can't blindly trust the URL coming from the server to be valid.
GURL result_url =
- GURL(URLFixerUpper::FixupURL(suggestion_str, std::wstring()));
+ GURL(URLFixerUpper::FixupURL(WideToUTF8(suggestion_str),
+ std::string()));
if (result_url.is_valid()) {
navigation_results_.push_back(NavigationResult(result_url,
site_name));
@@ -577,7 +580,8 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
match.contents = StringForURLDisplay(navigation.url, true);
// TODO(kochi): Consider moving HistoryURLProvider::TrimHttpPrefix() to some
// public utility function.
- if (!url_util::FindAndCompareScheme(input_.text(), "http", NULL))
+ if (!url_util::FindAndCompareScheme(WideToUTF8(input_.text()),
+ "http", NULL))
TrimHttpPrefix(&match.contents);
AutocompleteMatch::ClassifyMatchInString(input_.text(), match.contents,
ACMatchClassification::URL,
@@ -604,7 +608,7 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
// static
size_t SearchProvider::TrimHttpPrefix(std::wstring* url) {
url_parse::Component scheme;
- if (!url_util::FindAndCompareScheme(*url, "http", &scheme))
+ if (!url_util::FindAndCompareScheme(WideToUTF8(*url), "http", &scheme))
return 0; // Not "http".
// Erase scheme plus up to two slashes.