| OLD | NEW |
| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 builder.set_results( | 104 builder.set_results( |
| 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(ScopedOmniboxPageHandle handle, | 114 OmniboxUIHandler::OmniboxUIHandler(Profile* profile) |
| 115 Profile* profile) | 115 : page_(NULL), |
| 116 : page_(handle.Pass(), this), | |
| 117 profile_(profile) { | 116 profile_(profile) { |
| 118 ResetController(); | 117 ResetController(); |
| 119 } | 118 } |
| 120 | 119 |
| 121 OmniboxUIHandler::~OmniboxUIHandler() {} | 120 OmniboxUIHandler::~OmniboxUIHandler() {} |
| 122 | 121 |
| 123 void OmniboxUIHandler::OnResultChanged(bool default_match_changed) { | 122 void OmniboxUIHandler::OnResultChanged(bool default_match_changed) { |
| 124 mojo::AllocationScope scope; | 123 mojo::AllocationScope scope; |
| 125 OmniboxResultMojo::Builder builder; | 124 OmniboxResultMojo::Builder builder; |
| 126 builder.set_done(controller_->done()); | 125 builder.set_done(controller_->done()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 156 Profile::EXPLICIT_ACCESS); | 155 Profile::EXPLICIT_ACCESS); |
| 157 if (!history_service) | 156 if (!history_service) |
| 158 return false; | 157 return false; |
| 159 history::URLDatabase* url_db = history_service->InMemoryDatabase(); | 158 history::URLDatabase* url_db = history_service->InMemoryDatabase(); |
| 160 if (!url_db) | 159 if (!url_db) |
| 161 return false; | 160 return false; |
| 162 *is_typed_host = url_db->IsTypedHost(base::UTF16ToUTF8(host)); | 161 *is_typed_host = url_db->IsTypedHost(base::UTF16ToUTF8(host)); |
| 163 return true; | 162 return true; |
| 164 } | 163 } |
| 165 | 164 |
| 165 void OmniboxUIHandler::SetClient(OmniboxPage* page) { |
| 166 page_ = page; |
| 167 } |
| 168 |
| 166 void OmniboxUIHandler::StartOmniboxQuery(const mojo::String& input_string, | 169 void OmniboxUIHandler::StartOmniboxQuery(const mojo::String& input_string, |
| 167 int32_t cursor_position, | 170 int32_t cursor_position, |
| 168 bool prevent_inline_autocomplete, | 171 bool prevent_inline_autocomplete, |
| 169 bool prefer_keyword, | 172 bool prefer_keyword, |
| 170 int32_t page_classification) { | 173 int32_t page_classification) { |
| 171 // Reset the controller. If we don't do this, then the | 174 // Reset the controller. If we don't do this, then the |
| 172 // AutocompleteController might inappropriately set its |minimal_changes| | 175 // AutocompleteController might inappropriately set its |minimal_changes| |
| 173 // variable (or something else) and some providers will short-circuit | 176 // variable (or something else) and some providers will short-circuit |
| 174 // important logic and return stale results. In short, we want the | 177 // important logic and return stale results. In short, we want the |
| 175 // actual results to not depend on the state of the previous request. | 178 // actual results to not depend on the state of the previous request. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 186 prefer_keyword, | 189 prefer_keyword, |
| 187 true, // allow exact keyword matches | 190 true, // allow exact keyword matches |
| 188 true); | 191 true); |
| 189 controller_->Start(input_); // want all matches | 192 controller_->Start(input_); // want all matches |
| 190 } | 193 } |
| 191 | 194 |
| 192 void OmniboxUIHandler::ResetController() { | 195 void OmniboxUIHandler::ResetController() { |
| 193 controller_.reset(new AutocompleteController(profile_, this, | 196 controller_.reset(new AutocompleteController(profile_, this, |
| 194 AutocompleteClassifier::kDefaultOmniboxProviders)); | 197 AutocompleteClassifier::kDefaultOmniboxProviders)); |
| 195 } | 198 } |
| OLD | NEW |