| 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 template_url_service_->Load(); | 322 template_url_service_->Load(); |
| 323 template_url_service_->AddObserver(this); | 323 template_url_service_->AddObserver(this); |
| 324 OnTemplateURLServiceChanged(); | 324 OnTemplateURLServiceChanged(); |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 void BrowserOptionsHandler::UpdateRestoreOnStartup() { | 328 void BrowserOptionsHandler::UpdateRestoreOnStartup() { |
| 329 Profile* profile = web_ui_->GetProfile(); | 329 Profile* profile = web_ui_->GetProfile(); |
| 330 const SessionStartupPref startup_pref = | 330 const SessionStartupPref startup_pref = |
| 331 SessionStartupPref::GetStartupPref(profile->GetPrefs()); | 331 SessionStartupPref::GetStartupPref(profile->GetPrefs()); |
| 332 FundamentalValue restore_on_startup(startup_pref.type); | 332 base::FundamentalValue restore_on_startup(startup_pref.type); |
| 333 web_ui_->CallJavascriptFunction("BrowserOptions.updateRestoreOnStartup", | 333 web_ui_->CallJavascriptFunction("BrowserOptions.updateRestoreOnStartup", |
| 334 restore_on_startup); | 334 restore_on_startup); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void BrowserOptionsHandler::UpdateStartupPages() { | 337 void BrowserOptionsHandler::UpdateStartupPages() { |
| 338 Profile* profile = web_ui_->GetProfile(); | 338 Profile* profile = web_ui_->GetProfile(); |
| 339 const SessionStartupPref startup_pref = | 339 const SessionStartupPref startup_pref = |
| 340 SessionStartupPref::GetStartupPref(profile->GetPrefs()); | 340 SessionStartupPref::GetStartupPref(profile->GetPrefs()); |
| 341 startup_custom_pages_table_model_->SetURLs(startup_pref.urls); | 341 startup_custom_pages_table_model_->SetURLs(startup_pref.urls); |
| 342 } | 342 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 519 |
| 520 void BrowserOptionsHandler::EnableInstant(const ListValue* args) { | 520 void BrowserOptionsHandler::EnableInstant(const ListValue* args) { |
| 521 InstantController::Enable(web_ui_->GetProfile()); | 521 InstantController::Enable(web_ui_->GetProfile()); |
| 522 } | 522 } |
| 523 | 523 |
| 524 void BrowserOptionsHandler::DisableInstant(const ListValue* args) { | 524 void BrowserOptionsHandler::DisableInstant(const ListValue* args) { |
| 525 InstantController::Disable(web_ui_->GetProfile()); | 525 InstantController::Disable(web_ui_->GetProfile()); |
| 526 } | 526 } |
| 527 | 527 |
| 528 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { | 528 void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) { |
| 529 FundamentalValue enabled( | 529 base::FundamentalValue enabled( |
| 530 InstantFieldTrial::IsExperimentGroup(web_ui_->GetProfile())); | 530 InstantFieldTrial::IsExperimentGroup(web_ui_->GetProfile())); |
| 531 web_ui_->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", | 531 web_ui_->CallJavascriptFunction("BrowserOptions.setInstantFieldTrialStatus", |
| 532 enabled); | 532 enabled); |
| 533 } | 533 } |
| 534 | 534 |
| 535 void BrowserOptionsHandler::OnResultChanged(bool default_match_changed) { | 535 void BrowserOptionsHandler::OnResultChanged(bool default_match_changed) { |
| 536 const AutocompleteResult& result = autocomplete_controller_->result(); | 536 const AutocompleteResult& result = autocomplete_controller_->result(); |
| 537 ListValue suggestions; | 537 ListValue suggestions; |
| 538 for (size_t i = 0; i < result.size(); ++i) { | 538 for (size_t i = 0; i < result.size(); ++i) { |
| 539 const AutocompleteMatch& match = result.match_at(i); | 539 const AutocompleteMatch& match = result.match_at(i); |
| 540 AutocompleteMatch::Type type = match.type; | 540 AutocompleteMatch::Type type = match.type; |
| 541 if (type != AutocompleteMatch::HISTORY_URL && | 541 if (type != AutocompleteMatch::HISTORY_URL && |
| 542 type != AutocompleteMatch::HISTORY_TITLE && | 542 type != AutocompleteMatch::HISTORY_TITLE && |
| 543 type != AutocompleteMatch::HISTORY_BODY && | 543 type != AutocompleteMatch::HISTORY_BODY && |
| 544 type != AutocompleteMatch::HISTORY_KEYWORD && | 544 type != AutocompleteMatch::HISTORY_KEYWORD && |
| 545 type != AutocompleteMatch::NAVSUGGEST) | 545 type != AutocompleteMatch::NAVSUGGEST) |
| 546 continue; | 546 continue; |
| 547 DictionaryValue* entry = new DictionaryValue(); | 547 DictionaryValue* entry = new DictionaryValue(); |
| 548 entry->SetString("title", match.description); | 548 entry->SetString("title", match.description); |
| 549 entry->SetString("displayURL", match.contents); | 549 entry->SetString("displayURL", match.contents); |
| 550 entry->SetString("url", match.destination_url.spec()); | 550 entry->SetString("url", match.destination_url.spec()); |
| 551 suggestions.Append(entry); | 551 suggestions.Append(entry); |
| 552 } | 552 } |
| 553 | 553 |
| 554 web_ui_->CallJavascriptFunction( | 554 web_ui_->CallJavascriptFunction( |
| 555 "BrowserOptions.updateAutocompleteSuggestions", suggestions); | 555 "BrowserOptions.updateAutocompleteSuggestions", suggestions); |
| 556 } | 556 } |
| OLD | NEW |