| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after 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. |
| 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 |