| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 133     for (AutocompleteMatch::AdditionalInfo::const_iterator j = | 133     for (AutocompleteMatch::AdditionalInfo::const_iterator j = | 
| 134          it->additional_info.begin(); j != it->additional_info.end(); ++j) { | 134          it->additional_info.begin(); j != it->additional_info.end(); ++j) { | 
| 135       output->SetString(item_prefix + ".additional_info." + j->first, | 135       output->SetString(item_prefix + ".additional_info." + j->first, | 
| 136                         j->second); | 136                         j->second); | 
| 137     } | 137     } | 
| 138   } | 138   } | 
| 139   output->SetInteger(prefix + ".num_items", i); | 139   output->SetInteger(prefix + ".num_items", i); | 
| 140 } | 140 } | 
| 141 | 141 | 
| 142 void OmniboxUIHandler::StartOmniboxQuery( | 142 void OmniboxUIHandler::StartOmniboxQuery( | 
| 143     const base::ListValue* three_element_input_string) { | 143     const base::ListValue* four_element_input_string) { | 
| 144   DCHECK_EQ(3u, three_element_input_string->GetSize()); | 144   DCHECK_EQ(4u, four_element_input_string->GetSize()); | 
| 145   string16 input_string; | 145   string16 input_string; | 
| 146   bool return_val = three_element_input_string->GetString(0, &input_string); | 146   bool return_val = four_element_input_string->GetString(0, &input_string); | 
| 147   DCHECK(return_val); | 147   DCHECK(return_val); | 
|  | 148   int cursor_position_int; | 
|  | 149   return_val = four_element_input_string->GetInteger(1, &cursor_position_int); | 
|  | 150   DCHECK(return_val); | 
|  | 151   size_t cursor_position = cursor_position_int; | 
| 148   bool prevent_inline_autocomplete; | 152   bool prevent_inline_autocomplete; | 
| 149   return_val = | 153   return_val = | 
| 150       three_element_input_string->GetBoolean(1, &prevent_inline_autocomplete); | 154       four_element_input_string->GetBoolean(2, &prevent_inline_autocomplete); | 
| 151   DCHECK(return_val); | 155   DCHECK(return_val); | 
| 152   int cursor_position_int; | 156   bool prefer_keyword; | 
| 153   return_val = three_element_input_string->GetInteger(2, &cursor_position_int); | 157   return_val = four_element_input_string->GetBoolean(3, &prefer_keyword); | 
| 154   DCHECK(return_val); | 158   DCHECK(return_val); | 
| 155   size_t cursor_position = cursor_position_int; |  | 
| 156   string16 empty_string; | 159   string16 empty_string; | 
| 157   // Reset the controller.  If we don't do this, then the | 160   // Reset the controller.  If we don't do this, then the | 
| 158   // AutocompleteController might inappropriately set its |minimal_changes| | 161   // AutocompleteController might inappropriately set its |minimal_changes| | 
| 159   // variable (or something else) and some providers will short-circuit | 162   // variable (or something else) and some providers will short-circuit | 
| 160   // important logic and return stale results.  In short, we want the | 163   // important logic and return stale results.  In short, we want the | 
| 161   // actual results to not depend on the state of the previous request. | 164   // actual results to not depend on the state of the previous request. | 
| 162   ResetController(); | 165   ResetController(); | 
| 163   time_omnibox_started_ = base::Time::Now(); | 166   time_omnibox_started_ = base::Time::Now(); | 
| 164   controller_->Start(AutocompleteInput( | 167   controller_->Start(AutocompleteInput( | 
| 165       input_string, | 168       input_string, | 
| 166       cursor_position, | 169       cursor_position, | 
| 167       empty_string,  // user's desired tld (top-level domain) | 170       empty_string,  // user's desired tld (top-level domain) | 
| 168       prevent_inline_autocomplete, | 171       prevent_inline_autocomplete, | 
| 169       false,  // no preferred keyword provider | 172       prefer_keyword, | 
| 170       true,  // allow exact keyword matches | 173       true,  // allow exact keyword matches | 
| 171       AutocompleteInput::ALL_MATCHES));  // want all matches | 174       AutocompleteInput::ALL_MATCHES));  // want all matches | 
| 172 } | 175 } | 
| 173 | 176 | 
| 174 void OmniboxUIHandler::ResetController() { | 177 void OmniboxUIHandler::ResetController() { | 
| 175   controller_.reset(new AutocompleteController(profile_, this, | 178   controller_.reset(new AutocompleteController(profile_, this, | 
| 176       chrome::search::IsInstantExtendedAPIEnabled(profile_) ? | 179       chrome::search::IsInstantExtendedAPIEnabled(profile_) ? | 
| 177           AutocompleteClassifier::kInstantExtendedOmniboxProviders : | 180           AutocompleteClassifier::kInstantExtendedOmniboxProviders : | 
| 178           AutocompleteClassifier::kDefaultOmniboxProviders)); | 181           AutocompleteClassifier::kDefaultOmniboxProviders)); | 
| 179 } | 182 } | 
| OLD | NEW | 
|---|