| 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/options/startup_pages_handler.h" | 5 #include "chrome/browser/ui/webui/options/startup_pages_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 11 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 11 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 12 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
| 12 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 13 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/custom_home_pages_table_model.h" | 15 #include "chrome/browser/custom_home_pages_table_model.h" |
| 15 #include "chrome/browser/prefs/session_startup_pref.h" | 16 #include "chrome/browser/prefs/session_startup_pref.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 20 #include "components/metrics/proto/omnibox_event.pb.h" | 21 #include "components/metrics/proto/omnibox_event.pb.h" |
| 21 #include "components/omnibox/autocomplete_input.h" | 22 #include "components/omnibox/autocomplete_input.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 startup_custom_pages_table_model_.reset( | 94 startup_custom_pages_table_model_.reset( |
| 94 new CustomHomePagesTableModel(profile)); | 95 new CustomHomePagesTableModel(profile)); |
| 95 startup_custom_pages_table_model_->SetObserver(this); | 96 startup_custom_pages_table_model_->SetObserver(this); |
| 96 | 97 |
| 97 pref_change_registrar_.Init(profile->GetPrefs()); | 98 pref_change_registrar_.Init(profile->GetPrefs()); |
| 98 pref_change_registrar_.Add( | 99 pref_change_registrar_.Add( |
| 99 prefs::kURLsToRestoreOnStartup, | 100 prefs::kURLsToRestoreOnStartup, |
| 100 base::Bind(&StartupPagesHandler::UpdateStartupPages, | 101 base::Bind(&StartupPagesHandler::UpdateStartupPages, |
| 101 base::Unretained(this))); | 102 base::Unretained(this))); |
| 102 | 103 |
| 103 autocomplete_controller_.reset(new AutocompleteController(profile, | 104 autocomplete_controller_.reset(new AutocompleteController( |
| 104 TemplateURLServiceFactory::GetForProfile(profile), this, | 105 make_scoped_ptr(new ChromeAutocompleteProviderClient(profile)), this, |
| 105 AutocompleteClassifier::kDefaultOmniboxProviders)); | 106 AutocompleteClassifier::kDefaultOmniboxProviders)); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void StartupPagesHandler::InitializePage() { | 109 void StartupPagesHandler::InitializePage() { |
| 109 UpdateStartupPages(); | 110 UpdateStartupPages(); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void StartupPagesHandler::OnModelChanged() { | 113 void StartupPagesHandler::OnModelChanged() { |
| 113 base::ListValue startup_pages; | 114 base::ListValue startup_pages; |
| 114 int page_count = startup_custom_pages_table_model_->RowCount(); | 115 int page_count = startup_custom_pages_table_model_->RowCount(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 252 |
| 252 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { | 253 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { |
| 253 const AutocompleteResult& result = autocomplete_controller_->result(); | 254 const AutocompleteResult& result = autocomplete_controller_->result(); |
| 254 base::ListValue suggestions; | 255 base::ListValue suggestions; |
| 255 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); | 256 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); |
| 256 web_ui()->CallJavascriptFunction( | 257 web_ui()->CallJavascriptFunction( |
| 257 "StartupOverlay.updateAutocompleteSuggestions", suggestions); | 258 "StartupOverlay.updateAutocompleteSuggestions", suggestions); |
| 258 } | 259 } |
| 259 | 260 |
| 260 } // namespace options | 261 } // namespace options |
| OLD | NEW |