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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::Initialize() { | 84 void StartupPagesHandler::Initialize() { |
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); | 89 startup_custom_pages_table_model_->SetObserver(this); |
90 UpdateStartupPages(); | |
91 | 90 |
92 pref_change_registrar_.Init(profile->GetPrefs()); | 91 pref_change_registrar_.Init(profile->GetPrefs()); |
93 pref_change_registrar_.Add(prefs::kURLsToRestoreOnStartup, this); | 92 pref_change_registrar_.Add(prefs::kURLsToRestoreOnStartup, this); |
94 | 93 |
95 autocomplete_controller_.reset(new AutocompleteController(profile, this)); | 94 autocomplete_controller_.reset(new AutocompleteController(profile, this)); |
96 } | 95 } |
97 | 96 |
| 97 void StartupPagesHandler::SendPageValues() { |
| 98 UpdateStartupPages(); |
| 99 } |
| 100 |
98 void StartupPagesHandler::OnModelChanged() { | 101 void StartupPagesHandler::OnModelChanged() { |
99 ListValue startup_pages; | 102 ListValue startup_pages; |
100 int page_count = startup_custom_pages_table_model_->RowCount(); | 103 int page_count = startup_custom_pages_table_model_->RowCount(); |
101 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); | 104 std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); |
102 for (int i = 0; i < page_count; ++i) { | 105 for (int i = 0; i < page_count; ++i) { |
103 DictionaryValue* entry = new DictionaryValue(); | 106 DictionaryValue* entry = new DictionaryValue(); |
104 entry->SetString("title", startup_custom_pages_table_model_->GetText(i, 0)); | 107 entry->SetString("title", startup_custom_pages_table_model_->GetText(i, 0)); |
105 entry->SetString("url", urls[i].spec()); | 108 entry->SetString("url", urls[i].spec()); |
106 entry->SetString("tooltip", | 109 entry->SetString("tooltip", |
107 startup_custom_pages_table_model_->GetTooltip(i)); | 110 startup_custom_pages_table_model_->GetTooltip(i)); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 251 |
249 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { | 252 void StartupPagesHandler::OnResultChanged(bool default_match_changed) { |
250 const AutocompleteResult& result = autocomplete_controller_->result(); | 253 const AutocompleteResult& result = autocomplete_controller_->result(); |
251 ListValue suggestions; | 254 ListValue suggestions; |
252 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); | 255 OptionsUI::ProcessAutocompleteSuggestions(result, &suggestions); |
253 web_ui()->CallJavascriptFunction( | 256 web_ui()->CallJavascriptFunction( |
254 "StartupOverlay.updateAutocompleteSuggestions", suggestions); | 257 "StartupOverlay.updateAutocompleteSuggestions", suggestions); |
255 } | 258 } |
256 | 259 |
257 } // namespace options2 | 260 } // namespace options2 |
OLD | NEW |