| 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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 11 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 11 #include "chrome/browser/autocomplete/autocomplete_input.h" | 12 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_result.h" | 13 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 13 #include "chrome/browser/custom_home_pages_table_model.h" | 14 #include "chrome/browser/custom_home_pages_table_model.h" |
| 14 #include "chrome/browser/net/url_fixer_upper.h" | 15 #include "chrome/browser/net/url_fixer_upper.h" |
| 15 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 16 #include "chrome/browser/prefs/session_startup_pref.h" | 17 #include "chrome/browser/prefs/session_startup_pref.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 void StartupPagesHandler::InitializeHandler() { | 85 void StartupPagesHandler::InitializeHandler() { |
| 85 Profile* profile = Profile::FromWebUI(web_ui()); | 86 Profile* profile = Profile::FromWebUI(web_ui()); |
| 86 | 87 |
| 87 startup_custom_pages_table_model_.reset( | 88 startup_custom_pages_table_model_.reset( |
| 88 new CustomHomePagesTableModel(profile)); | 89 new CustomHomePagesTableModel(profile)); |
| 89 startup_custom_pages_table_model_->SetObserver(this); | 90 startup_custom_pages_table_model_->SetObserver(this); |
| 90 | 91 |
| 91 pref_change_registrar_.Init(profile->GetPrefs()); | 92 pref_change_registrar_.Init(profile->GetPrefs()); |
| 92 pref_change_registrar_.Add(prefs::kURLsToRestoreOnStartup, this); | 93 pref_change_registrar_.Add(prefs::kURLsToRestoreOnStartup, this); |
| 93 | 94 |
| 94 autocomplete_controller_.reset(new AutocompleteController(profile, this)); | 95 autocomplete_controller_.reset( |
| 96 new AutocompleteController( |
| 97 profile, |
| 98 this, |
| 99 AutocompleteClassifier::kDefaultOmniboxProviders)); |
| 95 } | 100 } |
| 96 | 101 |
| 97 void StartupPagesHandler::InitializePage() { | 102 void StartupPagesHandler::InitializePage() { |
| 98 UpdateStartupPages(); | 103 UpdateStartupPages(); |
| 99 } | 104 } |
| 100 | 105 |
| 101 void StartupPagesHandler::OnModelChanged() { | 106 void StartupPagesHandler::OnModelChanged() { |
| 102 ListValue startup_pages; | 107 ListValue startup_pages; |
| 103 int page_count = startup_custom_pages_table_model_->RowCount(); | 108 int page_count = startup_custom_pages_table_model_->RowCount(); |
| 104 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); | 109 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 256 |
| 252 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { | 257 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { |
| 253 const AutocompleteResult& result = autocomplete_controller_->result(); | 258 const AutocompleteResult& result = autocomplete_controller_->result(); |
| 254 ListValue suggestions; | 259 ListValue suggestions; |
| 255 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); | 260 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); |
| 256 web_ui()->CallJavascriptFunction( | 261 web_ui()->CallJavascriptFunction( |
| 257 "StartupOverlay.updateAutocompleteSuggestions", suggestions); | 262 "StartupOverlay.updateAutocompleteSuggestions", suggestions); |
| 258 } | 263 } |
| 259 | 264 |
| 260 } // namespace options | 265 } // namespace options |
| OLD | NEW |