Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: chrome/browser/profile_resetter/profile_resetter.cc

Issue 17274006: Reset profile: reset cookies and site data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/browsing_data/browsing_data_helper.h"
8 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/extensions/management_policy.h" 11 #include "chrome/browser/extensions/management_policy.h"
11 #include "chrome/browser/google/google_url_tracker.h" 12 #include "chrome/browser/google/google_url_tracker.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 14 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
14 #include "chrome/browser/search_engines/template_url_service.h" 15 #include "chrome/browser/search_engines/template_url_service.h"
15 #include "chrome/browser/search_engines/template_url_service_factory.h" 16 #include "chrome/browser/search_engines/template_url_service_factory.h"
16 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_iterator.h" 18 #include "chrome/browser/ui/browser_iterator.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
23 24
24 ProfileResetter::ProfileResetter(Profile* profile) 25 ProfileResetter::ProfileResetter(Profile* profile)
25 : profile_(profile), 26 : profile_(profile),
26 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile_)), 27 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile_)),
27 pending_reset_flags_(0) { 28 pending_reset_flags_(0),
29 cookies_remover_(NULL) {
28 DCHECK(CalledOnValidThread()); 30 DCHECK(CalledOnValidThread());
29 DCHECK(profile_); 31 DCHECK(profile_);
30 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, 32 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
31 content::Source<TemplateURLService>(template_url_service_)); 33 content::Source<TemplateURLService>(template_url_service_));
32 } 34 }
33 35
34 ProfileResetter::~ProfileResetter() {} 36 ProfileResetter::~ProfileResetter() {
37 if (cookies_remover_)
38 cookies_remover_->RemoveObserver(this);
39 }
35 40
36 void ProfileResetter::Reset(ProfileResetter::ResettableFlags resettable_flags, 41 void ProfileResetter::Reset(ProfileResetter::ResettableFlags resettable_flags,
37 const base::Closure& callback) { 42 const base::Closure& callback) {
38 DCHECK(CalledOnValidThread()); 43 DCHECK(CalledOnValidThread());
39 44
40 // We should never be called with unknown flags. 45 // We should never be called with unknown flags.
41 CHECK_EQ(static_cast<ResettableFlags>(0), resettable_flags & ~ALL); 46 CHECK_EQ(static_cast<ResettableFlags>(0), resettable_flags & ~ALL);
42 47
43 // We should never be called when a previous reset has not finished. 48 // We should never be called when a previous reset has not finished.
44 CHECK_EQ(static_cast<ResettableFlags>(0), pending_reset_flags_); 49 CHECK_EQ(static_cast<ResettableFlags>(0), pending_reset_flags_);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 135
131 void ProfileResetter::ResetContentSettings() { 136 void ProfileResetter::ResetContentSettings() {
132 DCHECK(CalledOnValidThread()); 137 DCHECK(CalledOnValidThread());
133 NOTIMPLEMENTED(); 138 NOTIMPLEMENTED();
134 // TODO(battre/vabr): Implement 139 // TODO(battre/vabr): Implement
135 MarkAsDone(CONTENT_SETTINGS); 140 MarkAsDone(CONTENT_SETTINGS);
136 } 141 }
137 142
138 void ProfileResetter::ResetCookiesAndSiteData() { 143 void ProfileResetter::ResetCookiesAndSiteData() {
139 DCHECK(CalledOnValidThread()); 144 DCHECK(CalledOnValidThread());
140 NOTIMPLEMENTED(); 145 DCHECK(!cookies_remover_);
141 // TODO(battre/vabr): Implement 146
142 MarkAsDone(COOKIES_AND_SITE_DATA); 147 cookies_remover_ = BrowsingDataRemover::CreateForUnboundedRange(profile_);
148 cookies_remover_->AddObserver(this);
149 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA |
150 BrowsingDataRemover::REMOVE_CACHE;
151 PrefService* prefs = profile_->GetPrefs();
152 DCHECK(prefs);
153 // Don't try to clear LSO data if it's not supported.
154 if (!prefs->GetBoolean(prefs::kClearPluginLSODataEnabled))
155 remove_mask &= ~BrowsingDataRemover::REMOVE_PLUGIN_DATA;
156 cookies_remover_->Remove(remove_mask, BrowsingDataHelper::UNPROTECTED_WEB);
143 } 157 }
144 158
145 void ProfileResetter::ResetExtensions() { 159 void ProfileResetter::ResetExtensions() {
146 DCHECK(CalledOnValidThread()); 160 DCHECK(CalledOnValidThread());
147 ExtensionService* extension_service = profile_->GetExtensionService(); 161 ExtensionService* extension_service = profile_->GetExtensionService();
148 DCHECK(extension_service); 162 DCHECK(extension_service);
149 extension_service->DisableUserExtensions(); 163 extension_service->DisableUserExtensions();
150 164
151 MarkAsDone(EXTENSIONS); 165 MarkAsDone(EXTENSIONS);
152 } 166 }
(...skipping 27 matching lines...) Expand all
180 194
181 void ProfileResetter::Observe(int type, 195 void ProfileResetter::Observe(int type,
182 const content::NotificationSource& source, 196 const content::NotificationSource& source,
183 const content::NotificationDetails& details) { 197 const content::NotificationDetails& details) {
184 DCHECK(CalledOnValidThread()); 198 DCHECK(CalledOnValidThread());
185 // TemplateURLService has loaded. If we need to clean search engines, it's 199 // TemplateURLService has loaded. If we need to clean search engines, it's
186 // time to go on. 200 // time to go on.
187 if (pending_reset_flags_ & DEFAULT_SEARCH_ENGINE) 201 if (pending_reset_flags_ & DEFAULT_SEARCH_ENGINE)
188 ResetDefaultSearchEngine(); 202 ResetDefaultSearchEngine();
189 } 203 }
204
205 void ProfileResetter::OnBrowsingDataRemoverDone() {
206 cookies_remover_ = NULL;
207 MarkAsDone(COOKIES_AND_SITE_DATA);
208 }
OLDNEW
« no previous file with comments | « chrome/browser/profile_resetter/profile_resetter.h ('k') | chrome/browser/profile_resetter/profile_resetter_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698