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

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

Issue 280003003: Add SetClient method implementation to InterfaceImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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) 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/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 mojo::Array<AutocompleteMatchMojo>::From(input->matches())); 105 mojo::Array<AutocompleteMatchMojo>::From(input->matches()));
106 return builder.Finish(); 106 return builder.Finish();
107 } 107 }
108 108
109 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION(); 109 MOJO_ALLOW_IMPLICIT_TYPE_CONVERSION();
110 }; 110 };
111 111
112 } // namespace mojo 112 } // namespace mojo
113 113
114 OmniboxUIHandler::OmniboxUIHandler(Profile* profile) 114 OmniboxUIHandler::OmniboxUIHandler(Profile* profile)
115 : page_(NULL), 115 : profile_(profile) {
116 profile_(profile) {
117 ResetController(); 116 ResetController();
118 } 117 }
119 118
120 OmniboxUIHandler::~OmniboxUIHandler() {} 119 OmniboxUIHandler::~OmniboxUIHandler() {}
121 120
122 void OmniboxUIHandler::OnResultChanged(bool default_match_changed) { 121 void OmniboxUIHandler::OnResultChanged(bool default_match_changed) {
123 mojo::AllocationScope scope; 122 mojo::AllocationScope scope;
124 OmniboxResultMojo::Builder builder; 123 OmniboxResultMojo::Builder builder;
125 builder.set_done(controller_->done()); 124 builder.set_done(controller_->done());
126 builder.set_time_since_omnibox_started_ms( 125 builder.set_time_since_omnibox_started_ms(
(...skipping 11 matching lines...) Expand all
138 // Copy to an ACMatches to make conversion easier. Since this isn't 137 // Copy to an ACMatches to make conversion easier. Since this isn't
139 // performance critical we don't worry about the cost here. 138 // performance critical we don't worry about the cost here.
140 ACMatches matches(controller_->result().begin(), 139 ACMatches matches(controller_->result().begin(),
141 controller_->result().end()); 140 controller_->result().end());
142 builder.set_combined_results( 141 builder.set_combined_results(
143 mojo::Array<AutocompleteMatchMojo>::From(matches)); 142 mojo::Array<AutocompleteMatchMojo>::From(matches));
144 } 143 }
145 builder.set_results_by_provider( 144 builder.set_results_by_provider(
146 mojo::Array<AutocompleteResultsForProviderMojo>::From( 145 mojo::Array<AutocompleteResultsForProviderMojo>::From(
147 *controller_->providers())); 146 *controller_->providers()));
148 page_->HandleNewAutocompleteResult(builder.Finish()); 147 client()->HandleNewAutocompleteResult(builder.Finish());
149 } 148 }
150 149
151 bool OmniboxUIHandler::LookupIsTypedHost(const base::string16& host, 150 bool OmniboxUIHandler::LookupIsTypedHost(const base::string16& host,
152 bool* is_typed_host) const { 151 bool* is_typed_host) const {
153 HistoryService* const history_service = 152 HistoryService* const history_service =
154 HistoryServiceFactory::GetForProfile(profile_, 153 HistoryServiceFactory::GetForProfile(profile_,
155 Profile::EXPLICIT_ACCESS); 154 Profile::EXPLICIT_ACCESS);
156 if (!history_service) 155 if (!history_service)
157 return false; 156 return false;
158 history::URLDatabase* url_db = history_service->InMemoryDatabase(); 157 history::URLDatabase* url_db = history_service->InMemoryDatabase();
159 if (!url_db) 158 if (!url_db)
160 return false; 159 return false;
161 *is_typed_host = url_db->IsTypedHost(base::UTF16ToUTF8(host)); 160 *is_typed_host = url_db->IsTypedHost(base::UTF16ToUTF8(host));
162 return true; 161 return true;
163 } 162 }
164 163
165 void OmniboxUIHandler::SetClient(OmniboxPage* page) {
166 page_ = page;
167 }
168
169 void OmniboxUIHandler::StartOmniboxQuery(const mojo::String& input_string, 164 void OmniboxUIHandler::StartOmniboxQuery(const mojo::String& input_string,
170 int32_t cursor_position, 165 int32_t cursor_position,
171 bool prevent_inline_autocomplete, 166 bool prevent_inline_autocomplete,
172 bool prefer_keyword, 167 bool prefer_keyword,
173 int32_t page_classification) { 168 int32_t page_classification) {
174 // Reset the controller. If we don't do this, then the 169 // Reset the controller. If we don't do this, then the
175 // AutocompleteController might inappropriately set its |minimal_changes| 170 // AutocompleteController might inappropriately set its |minimal_changes|
176 // variable (or something else) and some providers will short-circuit 171 // variable (or something else) and some providers will short-circuit
177 // important logic and return stale results. In short, we want the 172 // important logic and return stale results. In short, we want the
178 // actual results to not depend on the state of the previous request. 173 // actual results to not depend on the state of the previous request.
(...skipping 10 matching lines...) Expand all
189 prefer_keyword, 184 prefer_keyword,
190 true, // allow exact keyword matches 185 true, // allow exact keyword matches
191 true); 186 true);
192 controller_->Start(input_); // want all matches 187 controller_->Start(input_); // want all matches
193 } 188 }
194 189
195 void OmniboxUIHandler::ResetController() { 190 void OmniboxUIHandler::ResetController() {
196 controller_.reset(new AutocompleteController(profile_, this, 191 controller_.reset(new AutocompleteController(profile_, this,
197 AutocompleteClassifier::kDefaultOmniboxProviders)); 192 AutocompleteClassifier::kDefaultOmniboxProviders));
198 } 193 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/omnibox/omnibox_ui_handler.h ('k') | content/browser/mojo/mojo_application_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698