blob: 45635e3364c7e48fe3c2ab0c8cd2d72fa83d2cd2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// 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.
#include "chrome/browser/autocomplete/autocomplete_classifier.h"
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "googleurl/src/gurl.h"
AutocompleteClassifier::AutocompleteClassifier(Profile* profile)
: controller_(new AutocompleteController(profile)) {
}
AutocompleteClassifier::~AutocompleteClassifier() {
}
void AutocompleteClassifier::Classify(const std::wstring& text,
const std::wstring& desired_tld,
bool allow_exact_keyword_match,
AutocompleteMatch* match,
GURL* alternate_nav_url) {
controller_->Start(text, desired_tld, true, false, allow_exact_keyword_match,
true);
DCHECK(controller_->done());
const AutocompleteResult& result = controller_->result();
if (result.empty()) {
if (alternate_nav_url)
*alternate_nav_url = GURL();
return;
}
DCHECK(result.default_match() != result.end());
*match = *result.default_match();
if (alternate_nav_url)
*alternate_nav_url = result.alternate_nav_url();
}
|