Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: chrome/browser/autocomplete/autocomplete_classifier.cc

Issue 6995032: Fix a browser crash involving omnibox extension keywords. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: latest Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 5 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "chrome/browser/autocomplete/autocomplete.h" 8 #include "chrome/browser/autocomplete/autocomplete.h"
9 #include "chrome/browser/autocomplete/autocomplete_match.h" 9 #include "chrome/browser/autocomplete/autocomplete_match.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
11 11
12 AutocompleteClassifier::AutocompleteClassifier(Profile* profile) 12 AutocompleteClassifier::AutocompleteClassifier(Profile* profile)
13 : controller_(new AutocompleteController(profile, NULL)), 13 : controller_(new AutocompleteController(profile, NULL)),
14 inside_classify_(false) { 14 inside_classify_(false) {
15 } 15 }
16 16
17 AutocompleteClassifier::~AutocompleteClassifier() { 17 AutocompleteClassifier::~AutocompleteClassifier() {
18 } 18 }
19 19
20 void AutocompleteClassifier::Classify(const string16& text, 20 void AutocompleteClassifier::Classify(const string16& text,
21 const string16& desired_tld, 21 const string16& desired_tld,
22 bool prefer_keyword,
22 bool allow_exact_keyword_match, 23 bool allow_exact_keyword_match,
23 AutocompleteMatch* match, 24 AutocompleteMatch* match,
24 GURL* alternate_nav_url) { 25 GURL* alternate_nav_url) {
25 DCHECK(!inside_classify_); 26 DCHECK(!inside_classify_);
26 AutoReset<bool> reset(&inside_classify_, true); 27 AutoReset<bool> reset(&inside_classify_, true);
27 controller_->Start(text, desired_tld, true, false, allow_exact_keyword_match, 28 controller_->Start(text, desired_tld, true, prefer_keyword,
28 AutocompleteInput::BEST_MATCH); 29 allow_exact_keyword_match, AutocompleteInput::BEST_MATCH);
29 DCHECK(controller_->done()); 30 DCHECK(controller_->done());
30 const AutocompleteResult& result = controller_->result(); 31 const AutocompleteResult& result = controller_->result();
31 if (result.empty()) { 32 if (result.empty()) {
32 if (alternate_nav_url) 33 if (alternate_nav_url)
33 *alternate_nav_url = GURL(); 34 *alternate_nav_url = GURL();
34 return; 35 return;
35 } 36 }
36 37
37 DCHECK(result.default_match() != result.end()); 38 DCHECK(result.default_match() != result.end());
38 *match = *result.default_match(); 39 *match = *result.default_match();
39 if (alternate_nav_url) 40 if (alternate_nav_url)
40 *alternate_nav_url = result.alternate_nav_url(); 41 *alternate_nav_url = result.alternate_nav_url();
41 } 42 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_classifier.h ('k') | chrome/browser/autocomplete/autocomplete_edit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698