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

Side by Side Diff: chrome/browser/ui/webui/omnibox/omnibox_ui_handler.cc

Issue 10909130: autocomplete: Add AutocompleteProvider::Type enum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add !! for windows Created 8 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/omnibox/omnibox_ui_handler.h" 5 #include "chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
14 #include "chrome/browser/autocomplete/autocomplete_controller.h" 15 #include "chrome/browser/autocomplete/autocomplete_controller.h"
15 #include "chrome/browser/autocomplete/autocomplete_input.h" 16 #include "chrome/browser/autocomplete/autocomplete_input.h"
16 #include "chrome/browser/autocomplete/autocomplete_match.h" 17 #include "chrome/browser/autocomplete/autocomplete_match.h"
17 #include "chrome/browser/autocomplete/autocomplete_provider.h" 18 #include "chrome/browser/autocomplete/autocomplete_provider.h"
18 #include "chrome/browser/search_engines/template_url.h" 19 #include "chrome/browser/search_engines/template_url.h"
19 #include "content/public/browser/web_ui.h" 20 #include "content/public/browser/web_ui.h"
20 21
21 OmniboxUIHandler::OmniboxUIHandler(Profile* profile ) { 22 OmniboxUIHandler::OmniboxUIHandler(Profile* profile ) {
22 controller_.reset(new AutocompleteController(profile, this)); 23 controller_.reset(new AutocompleteController(profile, this,
24 AutocompleteClassifier::kDefaultOmniboxProviders));
23 } 25 }
24 26
25 OmniboxUIHandler::~OmniboxUIHandler() {} 27 OmniboxUIHandler::~OmniboxUIHandler() {}
26 28
27 void OmniboxUIHandler::RegisterMessages() { 29 void OmniboxUIHandler::RegisterMessages() {
28 web_ui()->RegisterMessageCallback("startOmniboxQuery", 30 web_ui()->RegisterMessageCallback("startOmniboxQuery",
29 base::Bind(&OmniboxUIHandler::StartOmniboxQuery, 31 base::Bind(&OmniboxUIHandler::StartOmniboxQuery,
30 base::Unretained(this))); 32 base::Unretained(this)));
31 } 33 }
32 34
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // Fill in general information. 72 // Fill in general information.
71 result_to_output.SetBoolean("done", controller_->done()); 73 result_to_output.SetBoolean("done", controller_->done());
72 result_to_output.SetInteger("time_since_omnibox_started_ms", 74 result_to_output.SetInteger("time_since_omnibox_started_ms",
73 (base::Time::Now() - time_omnibox_started_).InMilliseconds()); 75 (base::Time::Now() - time_omnibox_started_).InMilliseconds());
74 // Fill in the merged/combined results the controller has provided. 76 // Fill in the merged/combined results the controller has provided.
75 AddResultToDictionary("combined_results", controller_->result().begin(), 77 AddResultToDictionary("combined_results", controller_->result().begin(),
76 controller_->result().end(), &result_to_output); 78 controller_->result().end(), &result_to_output);
77 // Fill results from each individual provider as well. 79 // Fill results from each individual provider as well.
78 for (ACProviders::const_iterator it(controller_->providers()->begin()); 80 for (ACProviders::const_iterator it(controller_->providers()->begin());
79 it != controller_->providers()->end(); ++it) { 81 it != controller_->providers()->end(); ++it) {
80 AddResultToDictionary(std::string("results_by_provider.") + (*it)->name(), 82 AddResultToDictionary(
83 std::string("results_by_provider.") + (*it)->GetName(),
81 (*it)->matches().begin(), (*it)->matches().end(), &result_to_output); 84 (*it)->matches().begin(), (*it)->matches().end(), &result_to_output);
82 } 85 }
83 // Add done; send the results. 86 // Add done; send the results.
84 web_ui()->CallJavascriptFunction("omniboxDebug.handleNewAutocompleteResult", 87 web_ui()->CallJavascriptFunction("omniboxDebug.handleNewAutocompleteResult",
85 result_to_output); 88 result_to_output);
86 } 89 }
87 90
88 // For details on the format of the DictionaryValue that this function 91 // For details on the format of the DictionaryValue that this function
89 // populates, see the comments by OnResultChanged(). 92 // populates, see the comments by OnResultChanged().
90 void OmniboxUIHandler::AddResultToDictionary(const std::string& prefix, 93 void OmniboxUIHandler::AddResultToDictionary(const std::string& prefix,
91 ACMatches::const_iterator it, 94 ACMatches::const_iterator it,
92 ACMatches::const_iterator end, 95 ACMatches::const_iterator end,
93 base::DictionaryValue* output) { 96 base::DictionaryValue* output) {
94 int i = 0; 97 int i = 0;
95 for (; it != end; ++it, ++i) { 98 for (; it != end; ++it, ++i) {
96 std::string item_prefix(prefix + StringPrintf(".item_%d", i)); 99 std::string item_prefix(prefix + StringPrintf(".item_%d", i));
97 if (it->provider != NULL) { 100 if (it->provider != NULL) {
98 output->SetString(item_prefix + ".provider_name", it->provider->name()); 101 output->SetString(item_prefix + ".provider_name",
102 it->provider->GetName());
99 output->SetBoolean(item_prefix + ".provider_done", it->provider->done()); 103 output->SetBoolean(item_prefix + ".provider_done", it->provider->done());
100 } 104 }
101 output->SetInteger(item_prefix + ".relevance", it->relevance); 105 output->SetInteger(item_prefix + ".relevance", it->relevance);
102 output->SetBoolean(item_prefix + ".deletable", it->deletable); 106 output->SetBoolean(item_prefix + ".deletable", it->deletable);
103 output->SetString(item_prefix + ".fill_into_edit", it->fill_into_edit); 107 output->SetString(item_prefix + ".fill_into_edit", it->fill_into_edit);
104 output->SetInteger(item_prefix + ".inline_autocomplete_offset", 108 output->SetInteger(item_prefix + ".inline_autocomplete_offset",
105 it->inline_autocomplete_offset); 109 it->inline_autocomplete_offset);
106 output->SetString(item_prefix + ".destination_url", 110 output->SetString(item_prefix + ".destination_url",
107 it->destination_url.spec()); 111 it->destination_url.spec());
108 output->SetString(item_prefix + ".contents", it->contents); 112 output->SetString(item_prefix + ".contents", it->contents);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // query before it starts the new one. By the way, in this call to 148 // query before it starts the new one. By the way, in this call to
145 // Start(), we use the default/typical values for all parameters. 149 // Start(), we use the default/typical values for all parameters.
146 time_omnibox_started_ = base::Time::Now(); 150 time_omnibox_started_ = base::Time::Now();
147 controller_->Start(input_string, 151 controller_->Start(input_string,
148 empty_string, // user's desired tld (top-level domain) 152 empty_string, // user's desired tld (top-level domain)
149 false, // don't prevent inline autocompletion 153 false, // don't prevent inline autocompletion
150 false, // no preferred keyword provider 154 false, // no preferred keyword provider
151 true, // allow exact keyword matches 155 true, // allow exact keyword matches
152 AutocompleteInput::ALL_MATCHES); // want all matches 156 AutocompleteInput::ALL_MATCHES); // want all matches
153 } 157 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.cc ('k') | chrome/browser/ui/webui/options/home_page_overlay_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698