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

Side by Side Diff: ios/chrome/browser/signin/browser_state_data_remover.mm

Issue 2390003003: Upstream helper method to clear data using BrowserStateDataRemover. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « ios/chrome/browser/signin/browser_state_data_remover.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ios/chrome/browser/signin/browser_state_data_remover.h" 5 #import "ios/chrome/browser/signin/browser_state_data_remover.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "components/prefs/pref_service.h" 9 #include "components/prefs/pref_service.h"
10 #include "components/signin/core/common/signin_pref_names.h" 10 #include "components/signin/core/common/signin_pref_names.h"
(...skipping 11 matching lines...) Expand all
22 : browser_state_(browser_state), forget_last_username_(false) { 22 : browser_state_(browser_state), forget_last_username_(false) {
23 callback_subscription_ = 23 callback_subscription_ =
24 IOSChromeBrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( 24 IOSChromeBrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
25 base::Bind(&BrowserStateDataRemover::NotifyWithDetails, 25 base::Bind(&BrowserStateDataRemover::NotifyWithDetails,
26 base::Unretained(this))); 26 base::Unretained(this)));
27 } 27 }
28 28
29 BrowserStateDataRemover::~BrowserStateDataRemover() { 29 BrowserStateDataRemover::~BrowserStateDataRemover() {
30 } 30 }
31 31
32 // static
33 void BrowserStateDataRemover::ClearData(ios::ChromeBrowserState* browser_state,
34 ProceduralBlock completion) {
35 // The user just changed the account and chose to clear the previously
36 // existing data. As browsing data is being cleared, it is fine to clear the
37 // last username, as there will be no data to be merged.
38 BrowserStateDataRemover* remover = new BrowserStateDataRemover(browser_state);
39 remover->SetForgetLastUsername();
40 remover->RemoveBrowserStateData(completion);
41 }
42
32 void BrowserStateDataRemover::SetForgetLastUsername() { 43 void BrowserStateDataRemover::SetForgetLastUsername() {
33 forget_last_username_ = true; 44 forget_last_username_ = true;
34 } 45 }
35 46
36 void BrowserStateDataRemover::RemoveBrowserStateData(ProceduralBlock callback) { 47 void BrowserStateDataRemover::RemoveBrowserStateData(ProceduralBlock callback) {
37 DCHECK(!callback_); 48 DCHECK(!callback_);
38 callback_.reset([callback copy]); 49 callback_.reset([callback copy]);
39 50
40 base::scoped_nsobject<ClearBrowsingDataCommand> command( 51 base::scoped_nsobject<ClearBrowsingDataCommand> command(
41 [[ClearBrowsingDataCommand alloc] 52 [[ClearBrowsingDataCommand alloc]
(...skipping 23 matching lines...) Expand all
65 if (forget_last_username_) { 76 if (forget_last_username_) {
66 browser_state_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastAccountId); 77 browser_state_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastAccountId);
67 browser_state_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); 78 browser_state_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername);
68 } 79 }
69 80
70 if (callback_) 81 if (callback_)
71 callback_.get()(); 82 callback_.get()();
72 83
73 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 84 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
74 } 85 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/signin/browser_state_data_remover.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698