Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" | 11 #include "ios/chrome/browser/bookmarks/bookmarks_utils.h" |
| 12 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 12 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 13 #include "ios/chrome/browser/reading_list/reading_list_remover_helper.h" | |
| 13 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 14 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 14 #import "ios/chrome/browser/ui/commands/clear_browsing_data_command.h" | 15 #import "ios/chrome/browser/ui/commands/clear_browsing_data_command.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 const int kRemoveAllDataMask = ~0; | 18 const int kRemoveAllDataMask = ~0; |
| 18 } | 19 } |
| 19 | 20 |
| 20 BrowserStateDataRemover::BrowserStateDataRemover( | 21 BrowserStateDataRemover::BrowserStateDataRemover( |
| 21 ios::ChromeBrowserState* browser_state) | 22 ios::ChromeBrowserState* browser_state) |
| 22 : browser_state_(browser_state), forget_last_username_(false) { | 23 : browser_state_(browser_state), forget_last_username_(false) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 mask:kRemoveAllDataMask | 55 mask:kRemoveAllDataMask |
| 55 timePeriod:browsing_data::TimePeriod::ALL_TIME]); | 56 timePeriod:browsing_data::TimePeriod::ALL_TIME]); |
| 56 | 57 |
| 57 UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow]; | 58 UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow]; |
| 58 DCHECK(mainWindow); | 59 DCHECK(mainWindow); |
| 59 [mainWindow chromeExecuteCommand:command]; | 60 [mainWindow chromeExecuteCommand:command]; |
| 60 } | 61 } |
| 61 | 62 |
| 62 void BrowserStateDataRemover::NotifyWithDetails( | 63 void BrowserStateDataRemover::NotifyWithDetails( |
| 63 const IOSChromeBrowsingDataRemover::NotificationDetails& details) { | 64 const IOSChromeBrowsingDataRemover::NotificationDetails& details) { |
| 64 // Remove bookmarks once all browsing data was removed. | 65 // Remove bookmarks once all browsing data was removed. |
|
sdefresne
2017/03/20 15:09:40
Maybe change this to "Remove bookmarks and read li
Olivier
2017/03/21 10:10:15
Done.
| |
| 65 // Removal of browsing data waits for the bookmark model to be loaded, so | 66 // Removal of browsing data waits for the bookmark model to be loaded, so |
| 66 // there should be no issue calling the function here. | 67 // there should be no issue calling the function here. |
| 67 CHECK(RemoveAllUserBookmarksIOS(browser_state_)) | 68 CHECK(RemoveAllUserBookmarksIOS(browser_state_)) |
| 68 << "Failed to remove all user bookmarks."; | 69 << "Failed to remove all user bookmarks."; |
| 70 reading_list_remover_helper_ = | |
| 71 base::MakeUnique<reading_list::ReadingListRemoverHelper>(browser_state_); | |
| 72 reading_list_remover_helper_->RemoveAllUserReadingListItemsIOS( | |
| 73 base::Bind(&BrowserStateDataRemover::ReadingListCleaned, | |
| 74 base::Unretained(this), details)); | |
| 75 } | |
| 76 | |
| 77 void BrowserStateDataRemover::ReadingListCleaned( | |
| 78 const IOSChromeBrowsingDataRemover::NotificationDetails& details, | |
| 79 bool reading_list_cleaned) { | |
| 80 CHECK(reading_list_cleaned) | |
| 81 << "Failed to remove all user reading list items."; | |
| 69 | 82 |
| 70 if (details.removal_mask != kRemoveAllDataMask) { | 83 if (details.removal_mask != kRemoveAllDataMask) { |
| 71 NOTREACHED() << "Unexpected partial remove browsing data request " | 84 NOTREACHED() << "Unexpected partial remove browsing data request " |
| 72 << "(removal mask = " << details.removal_mask << ")"; | 85 << "(removal mask = " << details.removal_mask << ")"; |
| 73 return; | 86 return; |
| 74 } | 87 } |
| 75 | 88 |
| 76 if (forget_last_username_) { | 89 if (forget_last_username_) { |
| 77 browser_state_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastAccountId); | 90 browser_state_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastAccountId); |
| 78 browser_state_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); | 91 browser_state_->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); |
| 79 } | 92 } |
| 80 | 93 |
| 81 if (callback_) | 94 if (callback_) |
| 82 callback_.get()(); | 95 callback_.get()(); |
| 83 | 96 |
| 84 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 97 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 85 } | 98 } |
| OLD | NEW |