| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 ContentPageView::ContentPageView(Profile* profile) | 59 ContentPageView::ContentPageView(Profile* profile) |
| 60 : show_passwords_button_(NULL), | 60 : show_passwords_button_(NULL), |
| 61 passwords_group_(NULL), | 61 passwords_group_(NULL), |
| 62 passwords_asktosave_radio_(NULL), | 62 passwords_asktosave_radio_(NULL), |
| 63 passwords_neversave_radio_(NULL), | 63 passwords_neversave_radio_(NULL), |
| 64 change_autofill_settings_button_(NULL), | 64 change_autofill_settings_button_(NULL), |
| 65 form_autofill_enable_radio_(NULL), | |
| 66 form_autofill_disable_radio_(NULL), | |
| 67 themes_group_(NULL), | 65 themes_group_(NULL), |
| 68 themes_reset_button_(NULL), | 66 themes_reset_button_(NULL), |
| 69 themes_gallery_link_(NULL), | 67 themes_gallery_link_(NULL), |
| 70 browsing_data_group_(NULL), | 68 browsing_data_group_(NULL), |
| 71 import_button_(NULL), | 69 import_button_(NULL), |
| 72 sync_group_(NULL), | 70 sync_group_(NULL), |
| 73 sync_action_link_(NULL), | 71 sync_action_link_(NULL), |
| 74 sync_status_label_(NULL), | 72 sync_status_label_(NULL), |
| 75 sync_start_stop_button_(NULL), | 73 sync_start_stop_button_(NULL), |
| 76 sync_customize_button_(NULL), | 74 sync_customize_button_(NULL), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 99 if (enabled) { | 97 if (enabled) { |
| 100 UserMetricsRecordAction( | 98 UserMetricsRecordAction( |
| 101 UserMetricsAction("Options_PasswordManager_Enable"), | 99 UserMetricsAction("Options_PasswordManager_Enable"), |
| 102 profile()->GetPrefs()); | 100 profile()->GetPrefs()); |
| 103 } else { | 101 } else { |
| 104 UserMetricsRecordAction( | 102 UserMetricsRecordAction( |
| 105 UserMetricsAction("Options_PasswordManager_Disable"), | 103 UserMetricsAction("Options_PasswordManager_Disable"), |
| 106 profile()->GetPrefs()); | 104 profile()->GetPrefs()); |
| 107 } | 105 } |
| 108 ask_to_save_passwords_.SetValue(enabled); | 106 ask_to_save_passwords_.SetValue(enabled); |
| 109 } else if (sender == form_autofill_enable_radio_ || | |
| 110 sender == form_autofill_disable_radio_) { | |
| 111 bool enabled = form_autofill_enable_radio_->checked(); | |
| 112 if (enabled) { | |
| 113 UserMetricsRecordAction(UserMetricsAction("Options_FormAutofill_Enable"), | |
| 114 profile()->GetPrefs()); | |
| 115 } else { | |
| 116 UserMetricsRecordAction(UserMetricsAction("Options_FormAutofill_Disable"), | |
| 117 profile()->GetPrefs()); | |
| 118 } | |
| 119 ask_to_save_form_autofill_.SetValue(enabled); | |
| 120 } else if (sender == show_passwords_button_) { | 107 } else if (sender == show_passwords_button_) { |
| 121 UserMetricsRecordAction( | 108 UserMetricsRecordAction( |
| 122 UserMetricsAction("Options_ShowPasswordsExceptions"), NULL); | 109 UserMetricsAction("Options_ShowPasswordsExceptions"), NULL); |
| 123 PasswordsExceptionsWindowView::Show(profile()); | 110 PasswordsExceptionsWindowView::Show(profile()); |
| 124 } else if (sender == change_autofill_settings_button_) { | 111 } else if (sender == change_autofill_settings_button_) { |
| 125 // This button should be disabled if we lack PersonalDataManager. | 112 // This button should be disabled if we lack PersonalDataManager. |
| 126 DCHECK(profile()->GetPersonalDataManager()); | 113 DCHECK(profile()->GetPersonalDataManager()); |
| 127 ShowAutoFillDialog(GetWindow()->GetNativeWindow(), | 114 ShowAutoFillDialog(GetWindow()->GetNativeWindow(), |
| 128 profile()->GetPersonalDataManager(), | 115 profile()->GetPersonalDataManager(), |
| 129 profile()); | 116 profile()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 212 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 226 | 213 |
| 227 layout->StartRow(0, single_column_view_set_id); | 214 layout->StartRow(0, single_column_view_set_id); |
| 228 InitThemesGroup(); | 215 InitThemesGroup(); |
| 229 layout->AddView(themes_group_); | 216 layout->AddView(themes_group_); |
| 230 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 217 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 231 | 218 |
| 232 // Init member prefs so we can update the controls if prefs change. | 219 // Init member prefs so we can update the controls if prefs change. |
| 233 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, | 220 ask_to_save_passwords_.Init(prefs::kPasswordManagerEnabled, |
| 234 profile()->GetPrefs(), this); | 221 profile()->GetPrefs(), this); |
| 235 ask_to_save_form_autofill_.Init(prefs::kAutoFillEnabled, | |
| 236 profile()->GetPrefs(), this); | |
| 237 is_using_default_theme_.Init(prefs::kCurrentThemeID, | 222 is_using_default_theme_.Init(prefs::kCurrentThemeID, |
| 238 profile()->GetPrefs(), this); | 223 profile()->GetPrefs(), this); |
| 239 | 224 |
| 240 // Disable UI elements that are managed via policy. | 225 // Disable UI elements that are managed via policy. |
| 241 bool enablePasswordManagerElements = !ask_to_save_passwords_.IsManaged(); | 226 bool enablePasswordManagerElements = !ask_to_save_passwords_.IsManaged(); |
| 242 passwords_asktosave_radio_->SetEnabled(enablePasswordManagerElements); | 227 passwords_asktosave_radio_->SetEnabled(enablePasswordManagerElements); |
| 243 passwords_neversave_radio_->SetEnabled(enablePasswordManagerElements); | 228 passwords_neversave_radio_->SetEnabled(enablePasswordManagerElements); |
| 244 show_passwords_button_->SetEnabled(enablePasswordManagerElements); | 229 show_passwords_button_->SetEnabled(enablePasswordManagerElements); |
| 245 } | 230 } |
| 246 | 231 |
| 247 void ContentPageView::NotifyPrefChanged(const std::wstring* pref_name) { | 232 void ContentPageView::NotifyPrefChanged(const std::wstring* pref_name) { |
| 248 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { | 233 if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) { |
| 249 if (ask_to_save_passwords_.GetValue()) { | 234 if (ask_to_save_passwords_.GetValue()) { |
| 250 passwords_asktosave_radio_->SetChecked(true); | 235 passwords_asktosave_radio_->SetChecked(true); |
| 251 } else { | 236 } else { |
| 252 passwords_neversave_radio_->SetChecked(true); | 237 passwords_neversave_radio_->SetChecked(true); |
| 253 } | 238 } |
| 254 } | 239 } |
| 255 if (!pref_name || *pref_name == prefs::kAutoFillEnabled) { | |
| 256 if (ask_to_save_form_autofill_.GetValue()) { | |
| 257 form_autofill_enable_radio_->SetChecked(true); | |
| 258 } else { | |
| 259 form_autofill_disable_radio_->SetChecked(true); | |
| 260 } | |
| 261 } | |
| 262 if (!pref_name || *pref_name == prefs::kCurrentThemeID) { | 240 if (!pref_name || *pref_name == prefs::kCurrentThemeID) { |
| 263 themes_reset_button_->SetEnabled( | 241 themes_reset_button_->SetEnabled( |
| 264 is_using_default_theme_.GetValue().length() > 0); | 242 is_using_default_theme_.GetValue().length() > 0); |
| 265 } | 243 } |
| 266 } | 244 } |
| 267 | 245 |
| 268 /////////////////////////////////////////////////////////////////////////////// | 246 /////////////////////////////////////////////////////////////////////////////// |
| 269 // ContentsPageView, views::View overrides: | 247 // ContentsPageView, views::View overrides: |
| 270 | 248 |
| 271 void ContentPageView::Layout() { | 249 void ContentPageView::Layout() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); | 303 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); |
| 326 layout->StartRow(0, single_column_view_set_id); | 304 layout->StartRow(0, single_column_view_set_id); |
| 327 layout->AddView(show_passwords_button_); | 305 layout->AddView(show_passwords_button_); |
| 328 | 306 |
| 329 passwords_group_ = new OptionsGroupView( | 307 passwords_group_ = new OptionsGroupView( |
| 330 contents, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_GROUP_NAME), L"", | 308 contents, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_GROUP_NAME), L"", |
| 331 true); | 309 true); |
| 332 } | 310 } |
| 333 | 311 |
| 334 void ContentPageView::InitFormAutofillGroup() { | 312 void ContentPageView::InitFormAutofillGroup() { |
| 335 form_autofill_enable_radio_ = new views::RadioButton( | |
| 336 l10n_util::GetString(IDS_OPTIONS_AUTOFILL_ENABLE), | |
| 337 kFormAutofillRadioGroup); | |
| 338 form_autofill_enable_radio_->set_listener(this); | |
| 339 form_autofill_enable_radio_->SetMultiLine(true); | |
| 340 form_autofill_disable_radio_ = new views::RadioButton( | |
| 341 l10n_util::GetString(IDS_OPTIONS_AUTOFILL_DISABLE), | |
| 342 kFormAutofillRadioGroup); | |
| 343 form_autofill_disable_radio_->set_listener(this); | |
| 344 form_autofill_disable_radio_->SetMultiLine(true); | |
| 345 | |
| 346 change_autofill_settings_button_ = new views::NativeButton( | 313 change_autofill_settings_button_ = new views::NativeButton( |
| 347 this, l10n_util::GetString(IDS_AUTOFILL_OPTIONS)); | 314 this, l10n_util::GetString(IDS_AUTOFILL_OPTIONS)); |
| 348 if (!profile()->GetPersonalDataManager()) | 315 if (!profile()->GetPersonalDataManager()) |
| 349 change_autofill_settings_button_->SetEnabled(false); | 316 change_autofill_settings_button_->SetEnabled(false); |
| 350 | 317 |
| 351 | 318 |
| 352 using views::GridLayout; | 319 using views::GridLayout; |
| 353 using views::ColumnSet; | 320 using views::ColumnSet; |
| 354 | 321 |
| 355 views::View* contents = new views::View; | 322 views::View* contents = new views::View; |
| 356 GridLayout* layout = new GridLayout(contents); | 323 GridLayout* layout = new GridLayout(contents); |
| 357 contents->SetLayoutManager(layout); | 324 contents->SetLayoutManager(layout); |
| 358 | 325 |
| 359 const int fill_column_view_set_id = 0; | 326 const int fill_column_view_set_id = 0; |
| 360 const int leading_column_view_set_id = 1; | 327 const int leading_column_view_set_id = 1; |
| 361 ColumnSet* column_set = layout->AddColumnSet(fill_column_view_set_id); | 328 ColumnSet* column_set = layout->AddColumnSet(fill_column_view_set_id); |
| 362 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, | 329 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, |
| 363 GridLayout::USE_PREF, 0, 0); | 330 GridLayout::USE_PREF, 0, 0); |
| 364 column_set = layout->AddColumnSet(leading_column_view_set_id); | 331 column_set = layout->AddColumnSet(leading_column_view_set_id); |
| 365 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, | 332 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1, |
| 366 GridLayout::USE_PREF, 0, 0); | 333 GridLayout::USE_PREF, 0, 0); |
| 367 | 334 |
| 368 layout->StartRow(0, fill_column_view_set_id); | |
| 369 layout->AddView(form_autofill_enable_radio_, 1, 1, | |
| 370 GridLayout::FILL, GridLayout::LEADING); | |
| 371 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | |
| 372 layout->StartRow(0, fill_column_view_set_id); | |
| 373 layout->AddView(form_autofill_disable_radio_, 1, 1, | |
| 374 GridLayout::FILL, GridLayout::LEADING); | |
| 375 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | |
| 376 layout->StartRow(0, leading_column_view_set_id); | 335 layout->StartRow(0, leading_column_view_set_id); |
| 377 layout->AddView(change_autofill_settings_button_); | 336 layout->AddView(change_autofill_settings_button_); |
| 378 | 337 |
| 379 form_autofill_group_ = new OptionsGroupView( | 338 form_autofill_group_ = new OptionsGroupView( |
| 380 contents, l10n_util::GetString(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME), | 339 contents, l10n_util::GetString(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME), |
| 381 L"", true); | 340 L"", true); |
| 382 } | 341 } |
| 383 | 342 |
| 384 void ContentPageView::InitThemesGroup() { | 343 void ContentPageView::InitThemesGroup() { |
| 385 themes_reset_button_ = new views::NativeButton(this, | 344 themes_reset_button_ = new views::NativeButton(this, |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 sync_action_link_->SetEnabled(!managed); | 485 sync_action_link_->SetEnabled(!managed); |
| 527 | 486 |
| 528 if (status_has_error) { | 487 if (status_has_error) { |
| 529 sync_status_label_->set_background(CreateErrorBackground()); | 488 sync_status_label_->set_background(CreateErrorBackground()); |
| 530 sync_action_link_->set_background(CreateErrorBackground()); | 489 sync_action_link_->set_background(CreateErrorBackground()); |
| 531 } else { | 490 } else { |
| 532 sync_status_label_->set_background(NULL); | 491 sync_status_label_->set_background(NULL); |
| 533 sync_action_link_->set_background(NULL); | 492 sync_action_link_->set_background(NULL); |
| 534 } | 493 } |
| 535 } | 494 } |
| OLD | NEW |