| 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/options2/startup_pages_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/startup_pages_handler2.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_controller_delegate.h" | 10 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 const SessionStartupPref startup_pref = | 79 const SessionStartupPref startup_pref = |
| 80 SessionStartupPref::GetStartupPref(profile->GetPrefs()); | 80 SessionStartupPref::GetStartupPref(profile->GetPrefs()); |
| 81 startup_custom_pages_table_model_->SetURLs(startup_pref.urls); | 81 startup_custom_pages_table_model_->SetURLs(startup_pref.urls); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void StartupPagesHandler::InitializeHandler() { | 84 void StartupPagesHandler::InitializeHandler() { |
| 85 Profile* profile = Profile::FromWebUI(web_ui()); | 85 Profile* profile = Profile::FromWebUI(web_ui()); |
| 86 | 86 |
| 87 startup_custom_pages_table_model_.reset( | 87 startup_custom_pages_table_model_.reset( |
| 88 new CustomHomePagesTableModel(profile)); | 88 new CustomHomePagesTableModel(profile)); |
| 89 startup_custom_pages_table_model_->SetObserver(this); | |
| 90 | |
| 91 pref_change_registrar_.Init(profile->GetPrefs()); | 89 pref_change_registrar_.Init(profile->GetPrefs()); |
| 92 pref_change_registrar_.Add(prefs::kURLsToRestoreOnStartup, this); | |
| 93 | |
| 94 autocomplete_controller_.reset(new AutocompleteController(profile, this)); | |
| 95 } | 90 } |
| 96 | 91 |
| 97 void StartupPagesHandler::InitializePage() { | 92 void StartupPagesHandler::InitializePage() { |
| 93 Profile* profile = Profile::FromWebUI(web_ui()); |
| 94 |
| 95 startup_custom_pages_table_model_->SetObserver(this); |
| 96 pref_change_registrar_.Add(prefs::kURLsToRestoreOnStartup, this); |
| 97 autocomplete_controller_.reset(new AutocompleteController(profile, this)); |
| 98 UpdateStartupPages(); | 98 UpdateStartupPages(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void StartupPagesHandler::OnModelChanged() { | 101 void StartupPagesHandler::OnModelChanged() { |
| 102 ListValue startup_pages; | 102 ListValue startup_pages; |
| 103 int page_count = startup_custom_pages_table_model_->RowCount(); | 103 int page_count = startup_custom_pages_table_model_->RowCount(); |
| 104 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); | 104 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); |
| 105 for (int i = 0; i < page_count; ++i) { | 105 for (int i = 0; i < page_count; ++i) { |
| 106 DictionaryValue* entry = new DictionaryValue(); | 106 DictionaryValue* entry = new DictionaryValue(); |
| 107 entry->SetString("title", startup_custom_pages_table_model_->GetText(i, 0)); | 107 entry->SetString("title", startup_custom_pages_table_model_->GetText(i, 0)); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { | 252 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { |
| 253 const AutocompleteResult& result = autocomplete_controller_->result(); | 253 const AutocompleteResult& result = autocomplete_controller_->result(); |
| 254 ListValue suggestions; | 254 ListValue suggestions; |
| 255 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); | 255 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); |
| 256 web_ui()->CallJavascriptFunction( | 256 web_ui()->CallJavascriptFunction( |
| 257 "StartupOverlay.updateAutocompleteSuggestions", suggestions); | 257 "StartupOverlay.updateAutocompleteSuggestions", suggestions); |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace options2 | 260 } // namespace options2 |
| OLD | NEW |