| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/profile_resetter/profile_resetter.h" | 5 #include "chrome/browser/profile_resetter/profile_resetter.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| 11 #include "base/synchronization/cancellation_flag.h" | 11 #include "base/synchronization/cancellation_flag.h" |
| 12 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 12 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 13 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 13 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/google/google_url_tracker_factory.h" | 15 #include "chrome/browser/google/google_url_tracker_factory.h" |
| 16 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" | 16 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_iterator.h" | 20 #include "chrome/browser/ui/browser_iterator.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/installer/util/browser_distribution.h" | 23 #include "chrome/installer/util/browser_distribution.h" |
| 24 #include "components/content_settings/core/browser/content_settings_info.h" |
| 25 #include "components/content_settings/core/browser/content_settings_registry.h" |
| 24 #include "components/content_settings/core/browser/host_content_settings_map.h" | 26 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 25 #include "components/content_settings/core/browser/website_settings_info.h" | 27 #include "components/content_settings/core/browser/website_settings_info.h" |
| 26 #include "components/content_settings/core/browser/website_settings_registry.h" | 28 #include "components/content_settings/core/browser/website_settings_registry.h" |
| 27 #include "components/google/core/browser/google_url_tracker.h" | 29 #include "components/google/core/browser/google_url_tracker.h" |
| 28 #include "components/search_engines/search_engines_pref_names.h" | 30 #include "components/search_engines/search_engines_pref_names.h" |
| 29 #include "components/search_engines/template_url_prepopulate_data.h" | 31 #include "components/search_engines/template_url_prepopulate_data.h" |
| 30 #include "components/search_engines/template_url_service.h" | 32 #include "components/search_engines/template_url_service.h" |
| 31 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 32 #include "extensions/browser/extension_system.h" | 34 #include "extensions/browser/extension_system.h" |
| 33 #include "extensions/browser/management_policy.h" | 35 #include "extensions/browser/management_policy.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 213 |
| 212 if (master_settings_->GetShowHomeButton(&show_home_button)) | 214 if (master_settings_->GetShowHomeButton(&show_home_button)) |
| 213 prefs->SetBoolean(prefs::kShowHomeButton, show_home_button); | 215 prefs->SetBoolean(prefs::kShowHomeButton, show_home_button); |
| 214 else | 216 else |
| 215 prefs->ClearPref(prefs::kShowHomeButton); | 217 prefs->ClearPref(prefs::kShowHomeButton); |
| 216 MarkAsDone(HOMEPAGE); | 218 MarkAsDone(HOMEPAGE); |
| 217 } | 219 } |
| 218 | 220 |
| 219 void ProfileResetter::ResetContentSettings() { | 221 void ProfileResetter::ResetContentSettings() { |
| 220 DCHECK(CalledOnValidThread()); | 222 DCHECK(CalledOnValidThread()); |
| 221 PrefService* prefs = profile_->GetPrefs(); | |
| 222 HostContentSettingsMap* map = | 223 HostContentSettingsMap* map = |
| 223 HostContentSettingsMapFactory::GetForProfile(profile_); | 224 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 224 | 225 |
| 225 content_settings::WebsiteSettingsRegistry* registry = | 226 for (const content_settings::WebsiteSettingsInfo* info : |
| 226 content_settings::WebsiteSettingsRegistry::GetInstance(); | 227 *content_settings::WebsiteSettingsRegistry::GetInstance()) { |
| 227 for (const content_settings::WebsiteSettingsInfo* info : *registry) { | |
| 228 map->ClearSettingsForOneType(info->type()); | 228 map->ClearSettingsForOneType(info->type()); |
| 229 if (HostContentSettingsMap::IsSettingAllowedForType( | 229 } |
| 230 prefs, CONTENT_SETTING_DEFAULT, info->type())) { | 230 |
| 231 // TODO(raymes): Why don't we just set this to | 231 // TODO(raymes): The default value isn't really used for website settings |
| 232 // info->intial_default_value(). | 232 // right now, but if it were we should probably reset that here too. |
| 233 map->SetDefaultContentSetting(info->type(), CONTENT_SETTING_DEFAULT); | 233 for (const content_settings::ContentSettingsInfo* info : |
| 234 } | 234 *content_settings::ContentSettingsRegistry::GetInstance()) { |
| 235 map->SetDefaultContentSetting(info->website_settings_info()->type(), |
| 236 CONTENT_SETTING_DEFAULT); |
| 235 } | 237 } |
| 236 MarkAsDone(CONTENT_SETTINGS); | 238 MarkAsDone(CONTENT_SETTINGS); |
| 237 } | 239 } |
| 238 | 240 |
| 239 void ProfileResetter::ResetCookiesAndSiteData() { | 241 void ProfileResetter::ResetCookiesAndSiteData() { |
| 240 DCHECK(CalledOnValidThread()); | 242 DCHECK(CalledOnValidThread()); |
| 241 DCHECK(!cookies_remover_); | 243 DCHECK(!cookies_remover_); |
| 242 | 244 |
| 243 cookies_remover_ = BrowsingDataRemover::CreateForUnboundedRange(profile_); | 245 cookies_remover_ = BrowsingDataRemover::CreateForUnboundedRange(profile_); |
| 244 cookies_remover_->AddObserver(this); | 246 cookies_remover_->AddObserver(this); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 chrome_exe, | 354 chrome_exe, |
| 353 false, | 355 false, |
| 354 cancel, | 356 cancel, |
| 355 &shortcuts); | 357 &shortcuts); |
| 356 } | 358 } |
| 357 return shortcuts; | 359 return shortcuts; |
| 358 #else | 360 #else |
| 359 return std::vector<ShortcutCommand>(); | 361 return std::vector<ShortcutCommand>(); |
| 360 #endif | 362 #endif |
| 361 } | 363 } |
| OLD | NEW |