| OLD | NEW |
| 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/ui/webui/options/browser_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 void BrowserOptionsHandler::EnableInstant(const ListValue* args) { | 455 void BrowserOptionsHandler::EnableInstant(const ListValue* args) { |
| 456 InstantController::Enable(Profile::FromWebUI(web_ui_)); | 456 InstantController::Enable(Profile::FromWebUI(web_ui_)); |
| 457 } | 457 } |
| 458 | 458 |
| 459 void BrowserOptionsHandler::DisableInstant(const ListValue* args) { | 459 void BrowserOptionsHandler::DisableInstant(const ListValue* args) { |
| 460 InstantController::Disable(Profile::FromWebUI(web_ui_)); | 460 InstantController::Disable(Profile::FromWebUI(web_ui_)); |
| 461 } | 461 } |
| 462 | 462 |
| 463 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { | 463 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { |
| 464 base::FundamentalValue enabled( | 464 base::FundamentalValue enabled( |
| 465 InstantFieldTrial::IsExperimentGroup(Profile::FromWebUI(web_ui_))); | 465 InstantFieldTrial::IsInstantExperiment(Profile::FromWebUI(web_ui_))); |
| 466 web_ui_->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", | 466 web_ui_->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", |
| 467 enabled); | 467 enabled); |
| 468 } | 468 } |
| 469 | 469 |
| 470 void BrowserOptionsHandler::OnResultChanged(bool default_match_changed) { | 470 void BrowserOptionsHandler::OnResultChanged(bool default_match_changed) { |
| 471 const AutocompleteResult& result = autocomplete_controller_->result(); | 471 const AutocompleteResult& result = autocomplete_controller_->result(); |
| 472 ListValue suggestions; | 472 ListValue suggestions; |
| 473 for (size_t i = 0; i < result.size(); ++i) { | 473 for (size_t i = 0; i < result.size(); ++i) { |
| 474 const AutocompleteMatch& match = result.match_at(i); | 474 const AutocompleteMatch& match = result.match_at(i); |
| 475 AutocompleteMatch::Type type = match.type; | 475 AutocompleteMatch::Type type = match.type; |
| 476 if (type != AutocompleteMatch::HISTORY_URL && | 476 if (type != AutocompleteMatch::HISTORY_URL && |
| 477 type != AutocompleteMatch::HISTORY_TITLE && | 477 type != AutocompleteMatch::HISTORY_TITLE && |
| 478 type != AutocompleteMatch::HISTORY_BODY && | 478 type != AutocompleteMatch::HISTORY_BODY && |
| 479 type != AutocompleteMatch::HISTORY_KEYWORD && | 479 type != AutocompleteMatch::HISTORY_KEYWORD && |
| 480 type != AutocompleteMatch::NAVSUGGEST) | 480 type != AutocompleteMatch::NAVSUGGEST) |
| 481 continue; | 481 continue; |
| 482 DictionaryValue* entry = new DictionaryValue(); | 482 DictionaryValue* entry = new DictionaryValue(); |
| 483 entry->SetString("title", match.description); | 483 entry->SetString("title", match.description); |
| 484 entry->SetString("displayURL", match.contents); | 484 entry->SetString("displayURL", match.contents); |
| 485 entry->SetString("url", match.destination_url.spec()); | 485 entry->SetString("url", match.destination_url.spec()); |
| 486 suggestions.Append(entry); | 486 suggestions.Append(entry); |
| 487 } | 487 } |
| 488 | 488 |
| 489 web_ui_->CallJavascriptFunction( | 489 web_ui_->CallJavascriptFunction( |
| 490 "BrowserOptions.updateAutocompleteSuggestions", suggestions); | 490 "BrowserOptions.updateAutocompleteSuggestions", suggestions); |
| 491 } | 491 } |
| OLD | NEW |