OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/options/general_page_view.h" | 5 #include "chrome/browser/views/options/general_page_view.h" |
6 | 6 |
7 #include "app/combobox_model.h" | 7 #include "app/combobox_model.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 default_browser_group_(NULL), | 210 default_browser_group_(NULL), |
211 default_browser_status_label_(NULL), | 211 default_browser_status_label_(NULL), |
212 default_browser_use_as_default_button_(NULL), | 212 default_browser_use_as_default_button_(NULL), |
213 ALLOW_THIS_IN_INITIALIZER_LIST( | 213 ALLOW_THIS_IN_INITIALIZER_LIST( |
214 default_browser_worker_( | 214 default_browser_worker_( |
215 new ShellIntegration::DefaultBrowserWorker(this))), | 215 new ShellIntegration::DefaultBrowserWorker(this))), |
216 OptionsPageView(profile) { | 216 OptionsPageView(profile) { |
217 } | 217 } |
218 | 218 |
219 GeneralPageView::~GeneralPageView() { | 219 GeneralPageView::~GeneralPageView() { |
220 profile()->GetPrefs()->RemovePrefObserver(prefs::kRestoreOnStartup, this); | |
221 profile()->GetPrefs()->RemovePrefObserver( | |
222 prefs::kURLsToRestoreOnStartup, this); | |
223 if (startup_custom_pages_table_) | 220 if (startup_custom_pages_table_) |
224 startup_custom_pages_table_->SetModel(NULL); | 221 startup_custom_pages_table_->SetModel(NULL); |
225 default_browser_worker_->ObserverDestroyed(); | 222 default_browser_worker_->ObserverDestroyed(); |
226 } | 223 } |
227 | 224 |
228 /////////////////////////////////////////////////////////////////////////////// | 225 /////////////////////////////////////////////////////////////////////////////// |
229 // GeneralPageView, views::ButtonListener implementation: | 226 // GeneralPageView, views::ButtonListener implementation: |
230 | 227 |
231 void GeneralPageView::ButtonPressed( | 228 void GeneralPageView::ButtonPressed( |
232 views::Button* sender, const views::Event& event) { | 229 views::Button* sender, const views::Event& event) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 346 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
350 | 347 |
351 #if !defined(OS_CHROMEOS) | 348 #if !defined(OS_CHROMEOS) |
352 layout->StartRow(0, single_column_view_set_id); | 349 layout->StartRow(0, single_column_view_set_id); |
353 InitDefaultBrowserGroup(); | 350 InitDefaultBrowserGroup(); |
354 layout->AddView(default_browser_group_); | 351 layout->AddView(default_browser_group_); |
355 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 352 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
356 #endif | 353 #endif |
357 | 354 |
358 // Register pref observers that update the controls when a pref changes. | 355 // Register pref observers that update the controls when a pref changes. |
359 profile()->GetPrefs()->AddPrefObserver(prefs::kRestoreOnStartup, this); | 356 registrar_.Init(profile()->GetPrefs()); |
360 profile()->GetPrefs()->AddPrefObserver(prefs::kURLsToRestoreOnStartup, this); | 357 registrar_.Add(prefs::kRestoreOnStartup, this); |
| 358 registrar_.Add(prefs::kURLsToRestoreOnStartup, this); |
361 | 359 |
362 new_tab_page_is_home_page_.Init(prefs::kHomePageIsNewTabPage, | 360 new_tab_page_is_home_page_.Init(prefs::kHomePageIsNewTabPage, |
363 profile()->GetPrefs(), this); | 361 profile()->GetPrefs(), this); |
364 homepage_.Init(prefs::kHomePage, profile()->GetPrefs(), this); | 362 homepage_.Init(prefs::kHomePage, profile()->GetPrefs(), this); |
365 show_home_button_.Init(prefs::kShowHomeButton, profile()->GetPrefs(), this); | 363 show_home_button_.Init(prefs::kShowHomeButton, profile()->GetPrefs(), this); |
366 } | 364 } |
367 | 365 |
368 void GeneralPageView::NotifyPrefChanged(const std::string* pref_name) { | 366 void GeneralPageView::NotifyPrefChanged(const std::string* pref_name) { |
369 if (!pref_name || | 367 if (!pref_name || |
370 *pref_name == prefs::kRestoreOnStartup || | 368 *pref_name == prefs::kRestoreOnStartup || |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 } | 813 } |
816 homepage_use_url_textfield_->SetEnabled(enabled); | 814 homepage_use_url_textfield_->SetEnabled(enabled); |
817 homepage_use_url_textfield_->SetReadOnly(!enabled); | 815 homepage_use_url_textfield_->SetReadOnly(!enabled); |
818 } | 816 } |
819 | 817 |
820 void GeneralPageView::SetDefaultSearchProvider() { | 818 void GeneralPageView::SetDefaultSearchProvider() { |
821 const int index = default_search_engine_combobox_->selected_item(); | 819 const int index = default_search_engine_combobox_->selected_item(); |
822 default_search_engines_model_->model()->SetDefaultSearchProvider( | 820 default_search_engines_model_->model()->SetDefaultSearchProvider( |
823 default_search_engines_model_->GetTemplateURLAt(index)); | 821 default_search_engines_model_->GetTemplateURLAt(index)); |
824 } | 822 } |
OLD | NEW |