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/autocomplete_result.h" | 12 #include "chrome/browser/autocomplete/autocomplete_result.h" |
13 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 13 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/custom_home_pages_table_model.h" | 15 #include "chrome/browser/custom_home_pages_table_model.h" |
16 #include "chrome/browser/prefs/session_startup_pref.h" | 16 #include "chrome/browser/prefs/session_startup_pref.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
20 #include "components/autocomplete/autocomplete_input.h" | 19 #include "components/autocomplete/autocomplete_input.h" |
21 #include "components/metrics/proto/omnibox_event.pb.h" | 20 #include "components/metrics/proto/omnibox_event.pb.h" |
22 #include "components/url_fixer/url_fixer.h" | 21 #include "components/url_fixer/url_fixer.h" |
23 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/web_ui.h" | 23 #include "content/public/browser/web_ui.h" |
25 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
26 | 25 |
27 namespace options { | 26 namespace options { |
28 | 27 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 startup_custom_pages_table_model_.reset( | 87 startup_custom_pages_table_model_.reset( |
89 new CustomHomePagesTableModel(profile)); | 88 new CustomHomePagesTableModel(profile)); |
90 startup_custom_pages_table_model_->SetObserver(this); | 89 startup_custom_pages_table_model_->SetObserver(this); |
91 | 90 |
92 pref_change_registrar_.Init(profile->GetPrefs()); | 91 pref_change_registrar_.Init(profile->GetPrefs()); |
93 pref_change_registrar_.Add( | 92 pref_change_registrar_.Add( |
94 prefs::kURLsToRestoreOnStartup, | 93 prefs::kURLsToRestoreOnStartup, |
95 base::Bind(&StartupPagesHandler::UpdateStartupPages, | 94 base::Bind(&StartupPagesHandler::UpdateStartupPages, |
96 base::Unretained(this))); | 95 base::Unretained(this))); |
97 | 96 |
98 autocomplete_controller_.reset(new AutocompleteController(profile, | 97 autocomplete_controller_.reset(new AutocompleteController(profile, this, |
99 TemplateURLServiceFactory::GetForProfile(profile), this, | |
100 AutocompleteClassifier::kDefaultOmniboxProviders)); | 98 AutocompleteClassifier::kDefaultOmniboxProviders)); |
101 } | 99 } |
102 | 100 |
103 void StartupPagesHandler::InitializePage() { | 101 void StartupPagesHandler::InitializePage() { |
104 UpdateStartupPages(); | 102 UpdateStartupPages(); |
105 } | 103 } |
106 | 104 |
107 void StartupPagesHandler::OnModelChanged() { | 105 void StartupPagesHandler::OnModelChanged() { |
108 base::ListValue startup_pages; | 106 base::ListValue startup_pages; |
109 int page_count = startup_custom_pages_table_model_->RowCount(); | 107 int page_count = startup_custom_pages_table_model_->RowCount(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 244 |
247 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { | 245 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { |
248 const AutocompleteResult& result = autocomplete_controller_->result(); | 246 const AutocompleteResult& result = autocomplete_controller_->result(); |
249 base::ListValue suggestions; | 247 base::ListValue suggestions; |
250 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); | 248 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); |
251 web_ui()->CallJavascriptFunction( | 249 web_ui()->CallJavascriptFunction( |
252 "StartupOverlay.updateAutocompleteSuggestions", suggestions); | 250 "StartupOverlay.updateAutocompleteSuggestions", suggestions); |
253 } | 251 } |
254 | 252 |
255 } // namespace options | 253 } // namespace options |
OLD | NEW |