Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/options/reset_profile_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/reset_profile_settings_handler.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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 RegisterStrings(localized_strings, resources, arraysize(resources)); | 55 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 56 RegisterTitle(localized_strings, "resetProfileSettingsOverlay", | 56 RegisterTitle(localized_strings, "resetProfileSettingsOverlay", |
| 57 IDS_RESET_PROFILE_SETTINGS_TITLE); | 57 IDS_RESET_PROFILE_SETTINGS_TITLE); |
| 58 localized_strings->SetString( | 58 localized_strings->SetString( |
| 59 "resetProfileSettingsLearnMoreUrl", | 59 "resetProfileSettingsLearnMoreUrl", |
| 60 google_util::StringAppendGoogleLocaleParam( | 60 google_util::StringAppendGoogleLocaleParam( |
| 61 kResetProfileSettingsLearnMoreUrl)); | 61 kResetProfileSettingsLearnMoreUrl)); |
| 62 | 62 |
| 63 scoped_ptr<ListValue> reset_extensions_handling(new ListValue); | 63 scoped_ptr<ListValue> reset_extensions_handling(new ListValue); |
|
battre
2013/06/14 17:51:21
This block can be deleted
vasilii
2013/06/17 11:56:30
Done.
| |
| 64 for (int i = 0; i < 2; i++) { | 64 for (int i = 0; i < 2; i++) { |
| 65 string16 label_string; | 65 string16 label_string; |
| 66 switch (i) { | 66 switch (i) { |
| 67 case 0: | 67 case 0: |
| 68 label_string = l10n_util::GetStringUTF16( | 68 label_string = l10n_util::GetStringUTF16( |
| 69 IDS_RESET_PROFILE_EXTENSIONS_DISABLE); | 69 IDS_RESET_PROFILE_EXTENSIONS_DISABLE); |
|
battre
2013/06/14 17:51:21
these resources can be deleted from the resource f
vasilii
2013/06/17 11:56:30
Done.
| |
| 70 break; | 70 break; |
| 71 case 1: | 71 case 1: |
| 72 label_string = l10n_util::GetStringUTF16( | 72 label_string = l10n_util::GetStringUTF16( |
| 73 IDS_RESET_PROFILE_EXTENSIONS_UNINSTALL); | 73 IDS_RESET_PROFILE_EXTENSIONS_UNINSTALL); |
| 74 break; | 74 break; |
| 75 } | 75 } |
| 76 scoped_ptr<ListValue> option(new ListValue); | 76 scoped_ptr<ListValue> option(new ListValue); |
| 77 option->Append(new base::FundamentalValue(i)); | 77 option->Append(new base::FundamentalValue(i)); |
| 78 option->Append(new base::StringValue(label_string)); | 78 option->Append(new base::StringValue(label_string)); |
| 79 reset_extensions_handling->Append(option.release()); | 79 reset_extensions_handling->Append(option.release()); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 92 void ResetProfileSettingsHandler::HandleResetProfileSettings( | 92 void ResetProfileSettingsHandler::HandleResetProfileSettings( |
| 93 const ListValue* /*value*/) { | 93 const ListValue* /*value*/) { |
| 94 DCHECK(resetter_); | 94 DCHECK(resetter_); |
| 95 DCHECK(!resetter_->IsActive()); | 95 DCHECK(!resetter_->IsActive()); |
| 96 | 96 |
| 97 Profile* profile = Profile::FromWebUI(web_ui()); | 97 Profile* profile = Profile::FromWebUI(web_ui()); |
| 98 PrefService* prefs = profile->GetPrefs(); | 98 PrefService* prefs = profile->GetPrefs(); |
| 99 | 99 |
| 100 ProfileResetter::ResettableFlags reset_mask = 0; | 100 ProfileResetter::ResettableFlags reset_mask = 0; |
| 101 | 101 |
| 102 // TODO(vasilii): remove all UI checkboxes and reset ProfileResetter::ALL. | |
|
battre
2013/06/14 17:51:21
I think it would be good to have this as part of t
vasilii
2013/06/17 11:56:30
Done.
| |
| 103 | |
| 102 struct { | 104 struct { |
| 103 const char* flag_name; | 105 const char* flag_name; |
| 104 ProfileResetter::ResettableFlags mask; | 106 ProfileResetter::ResettableFlags mask; |
| 105 } name_to_flag[] = { | 107 } name_to_flag[] = { |
| 106 { prefs::kResetDefaultSearchEngine, | 108 { prefs::kResetDefaultSearchEngine, |
| 107 ProfileResetter::DEFAULT_SEARCH_ENGINE }, | 109 ProfileResetter::DEFAULT_SEARCH_ENGINE }, |
| 108 { prefs::kResetHomepage, ProfileResetter::HOMEPAGE | | 110 { prefs::kResetHomepage, ProfileResetter::HOMEPAGE | |
| 109 ProfileResetter::STARTUP_PAGE }, | 111 ProfileResetter::STARTUP_PAGES | |
| 112 ProfileResetter::PINNED_TABS }, | |
| 110 { prefs::kResetContentSettings, ProfileResetter::CONTENT_SETTINGS }, | 113 { prefs::kResetContentSettings, ProfileResetter::CONTENT_SETTINGS }, |
| 111 { prefs::kResetCookiesAndSiteData, ProfileResetter::COOKIES_AND_SITE_DATA }, | 114 { prefs::kResetCookiesAndSiteData, ProfileResetter::COOKIES_AND_SITE_DATA }, |
| 112 { prefs::kResetExtensions, ProfileResetter::EXTENSIONS }, | 115 { prefs::kResetExtensions, ProfileResetter::EXTENSIONS }, |
| 113 }; | 116 }; |
| 114 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(name_to_flag); ++i) { | 117 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(name_to_flag); ++i) { |
| 115 if (prefs->GetBoolean(name_to_flag[i].flag_name)) | 118 if (prefs->GetBoolean(name_to_flag[i].flag_name)) |
| 116 reset_mask |= name_to_flag[i].mask; | 119 reset_mask |= name_to_flag[i].mask; |
| 117 } | 120 } |
| 118 | 121 |
| 119 ProfileResetter::ExtensionHandling extension_handling = | |
| 120 (prefs->GetInteger(prefs::kResetExtensionsHandling) == 0) | |
| 121 ? ProfileResetter::DISABLE_EXTENSIONS | |
| 122 : ProfileResetter::UNINSTALL_EXTENSIONS; | |
| 123 | |
| 124 resetter_->Reset( | 122 resetter_->Reset( |
| 125 reset_mask, | 123 reset_mask, |
| 126 extension_handling, | |
| 127 base::Bind(&ResetProfileSettingsHandler::OnResetProfileSettingsDone, | 124 base::Bind(&ResetProfileSettingsHandler::OnResetProfileSettingsDone, |
| 128 AsWeakPtr())); | 125 AsWeakPtr())); |
| 129 } | 126 } |
| 130 | 127 |
| 131 void ResetProfileSettingsHandler::OnResetProfileSettingsDone() { | 128 void ResetProfileSettingsHandler::OnResetProfileSettingsDone() { |
| 132 web_ui()->CallJavascriptFunction("ResetProfileSettingsOverlay.doneResetting"); | 129 web_ui()->CallJavascriptFunction("ResetProfileSettingsOverlay.doneResetting"); |
| 133 } | 130 } |
| 134 | 131 |
| 135 } // namespace options | 132 } // namespace options |
| OLD | NEW |