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/content_page_view.h" | 5 #include "chrome/browser/views/options/content_page_view.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 #include <vsstyle.h> | 9 #include <vsstyle.h> |
10 #include <vssym32.h> | 10 #include <vssym32.h> |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 211 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
212 | 212 |
213 layout->StartRow(0, single_column_view_set_id); | 213 layout->StartRow(0, single_column_view_set_id); |
214 InitThemesGroup(); | 214 InitThemesGroup(); |
215 layout->AddView(themes_group_); | 215 layout->AddView(themes_group_); |
216 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 216 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
217 | 217 |
218 // Init member prefs so we can update the controls if prefs change. | 218 // Init member prefs so we can update the controls if prefs change. |
219 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, | 219 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, |
220 profile()->GetPrefs(), this); | 220 profile()->GetPrefs(), this); |
| 221 form_autofill_enabled_.Init(prefs::kAutoFillEnabled, |
| 222 profile()->GetPrefs(), this); |
221 is_using_default_theme_.Init(prefs::kCurrentThemeID, | 223 is_using_default_theme_.Init(prefs::kCurrentThemeID, |
222 profile()->GetPrefs(), this); | 224 profile()->GetPrefs(), this); |
223 | 225 |
224 // Disable UI elements that are managed via policy. | 226 // Disable UI elements that are managed via policy. |
225 bool enablePasswordManagerElements = !ask_to_save_passwords_.IsManaged(); | 227 bool enablePasswordManagerElements = !ask_to_save_passwords_.IsManaged(); |
226 passwords_asktosave_radio_->SetEnabled(enablePasswordManagerElements); | 228 passwords_asktosave_radio_->SetEnabled(enablePasswordManagerElements); |
227 passwords_neversave_radio_->SetEnabled(enablePasswordManagerElements); | 229 passwords_neversave_radio_->SetEnabled(enablePasswordManagerElements); |
228 show_passwords_button_->SetEnabled(enablePasswordManagerElements); | 230 show_passwords_button_->SetEnabled(enablePasswordManagerElements); |
229 } | 231 } |
230 | 232 |
231 void ContentPageView::NotifyPrefChanged(const std::string* pref_name) { | 233 void ContentPageView::NotifyPrefChanged(const std::string* pref_name) { |
232 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { | 234 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { |
233 if (ask_to_save_passwords_.GetValue()) { | 235 if (ask_to_save_passwords_.GetValue()) { |
234 passwords_asktosave_radio_->SetChecked(true); | 236 passwords_asktosave_radio_->SetChecked(true); |
235 } else { | 237 } else { |
236 passwords_neversave_radio_->SetChecked(true); | 238 passwords_neversave_radio_->SetChecked(true); |
237 } | 239 } |
238 } | 240 } |
| 241 if (!pref_name || *pref_name == prefs::kAutoFillEnabled) { |
| 242 bool disabled_by_policy = form_autofill_enabled_.IsManaged() && |
| 243 !form_autofill_enabled_.GetValue(); |
| 244 change_autofill_settings_button_->SetEnabled( |
| 245 !disabled_by_policy && profile()->GetPersonalDataManager()); |
| 246 } |
239 if (!pref_name || *pref_name == prefs::kCurrentThemeID) { | 247 if (!pref_name || *pref_name == prefs::kCurrentThemeID) { |
240 themes_reset_button_->SetEnabled( | 248 themes_reset_button_->SetEnabled( |
241 is_using_default_theme_.GetValue().length() > 0); | 249 is_using_default_theme_.GetValue().length() > 0); |
242 } | 250 } |
243 } | 251 } |
244 | 252 |
245 /////////////////////////////////////////////////////////////////////////////// | 253 /////////////////////////////////////////////////////////////////////////////// |
246 // ContentsPageView, views::View overrides: | 254 // ContentsPageView, views::View overrides: |
247 | 255 |
248 void ContentPageView::Layout() { | 256 void ContentPageView::Layout() { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 layout->AddView(show_passwords_button_); | 312 layout->AddView(show_passwords_button_); |
305 | 313 |
306 passwords_group_ = new OptionsGroupView( | 314 passwords_group_ = new OptionsGroupView( |
307 contents, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_GROUP_NAME), L"", | 315 contents, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_GROUP_NAME), L"", |
308 true); | 316 true); |
309 } | 317 } |
310 | 318 |
311 void ContentPageView::InitFormAutofillGroup() { | 319 void ContentPageView::InitFormAutofillGroup() { |
312 change_autofill_settings_button_ = new views::NativeButton( | 320 change_autofill_settings_button_ = new views::NativeButton( |
313 this, l10n_util::GetString(IDS_AUTOFILL_OPTIONS)); | 321 this, l10n_util::GetString(IDS_AUTOFILL_OPTIONS)); |
314 if (!profile()->GetPersonalDataManager()) | |
315 change_autofill_settings_button_->SetEnabled(false); | |
316 | |
317 | 322 |
318 using views::GridLayout; | 323 using views::GridLayout; |
319 using views::ColumnSet; | 324 using views::ColumnSet; |
320 | 325 |
321 views::View* contents = new views::View; | 326 views::View* contents = new views::View; |
322 GridLayout* layout = new GridLayout(contents); | 327 GridLayout* layout = new GridLayout(contents); |
323 contents->SetLayoutManager(layout); | 328 contents->SetLayoutManager(layout); |
324 | 329 |
325 const int fill_column_view_set_id = 0; | 330 const int fill_column_view_set_id = 0; |
326 const int leading_column_view_set_id = 1; | 331 const int leading_column_view_set_id = 1; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 sync_action_link_->SetEnabled(!managed); | 489 sync_action_link_->SetEnabled(!managed); |
485 | 490 |
486 if (status_has_error) { | 491 if (status_has_error) { |
487 sync_status_label_->set_background(CreateErrorBackground()); | 492 sync_status_label_->set_background(CreateErrorBackground()); |
488 sync_action_link_->set_background(CreateErrorBackground()); | 493 sync_action_link_->set_background(CreateErrorBackground()); |
489 } else { | 494 } else { |
490 sync_status_label_->set_background(NULL); | 495 sync_status_label_->set_background(NULL); |
491 sync_action_link_->set_background(NULL); | 496 sync_action_link_->set_background(NULL); |
492 } | 497 } |
493 } | 498 } |
OLD | NEW |