blob: b32b92bad5a4d721cef8aa19480810219d72035f (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright (c) 2009 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/search_versus_navigate_classifier.h"
#include "chrome/browser/autocomplete/autocomplete.h"
#include "googleurl/src/gurl.h"
SearchVersusNavigateClassifier::SearchVersusNavigateClassifier(Profile* profile)
: controller_(new AutocompleteController(profile)) {
}
SearchVersusNavigateClassifier::~SearchVersusNavigateClassifier() {
}
void SearchVersusNavigateClassifier::Classify(const std::wstring& text,
const std::wstring& desired_tld,
bool* is_search,
GURL* destination_url,
PageTransition::Type* transition,
bool* is_history_what_you_typed_match,
GURL* alternate_nav_url) {
controller_->Start(text, desired_tld, true, false, true);
DCHECK(controller_->done());
const AutocompleteResult& result = controller_->result();
if (result.empty()) {
if (is_search)
*is_search = false;
if (destination_url)
*destination_url = GURL();
if (transition)
*transition = PageTransition::TYPED;
if (is_history_what_you_typed_match)
*is_history_what_you_typed_match = false;
if (alternate_nav_url)
*alternate_nav_url = GURL();
return;
}
const AutocompleteResult::const_iterator match(result.default_match());
DCHECK(match != result.end());
// If this is a search, the page transition will be GENERATED rather than
// TYPED.
if (is_search)
*is_search = (match->transition != PageTransition::TYPED);
if (destination_url)
*destination_url = match->destination_url;
if (transition)
*transition = match->transition;
if (is_history_what_you_typed_match)
*is_history_what_you_typed_match = match->is_history_what_you_typed_match;
if (alternate_nav_url)
*alternate_nav_url = result.alternate_nav_url();
}
|