Commit e8e05752 authored by Mohammad Refaat's avatar Mohammad Refaat Committed by Commit Bot

Fix Problem where clear browsing data weren't deleting the session file

Updated the browsing_data_remover_impl to call a different method on
session service which will get all session directories and remove them.

Bug: 1151388
Change-Id: I21f62b6d5f6ccbf3279383d872e1a2b5fbaee954
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2551849
Commit-Queue: Mohammad Refaat <mrefaat@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829892}
parent 29e38e5f
...@@ -278,10 +278,8 @@ void BrowsingDataRemoverImpl::RemoveImpl(base::Time delete_begin, ...@@ -278,10 +278,8 @@ void BrowsingDataRemoverImpl::RemoveImpl(base::Time delete_begin,
if (session_service_) { if (session_service_) {
NSString* state_path = base::SysUTF8ToNSString( NSString* state_path = base::SysUTF8ToNSString(
browser_state_->GetStatePath().AsUTF8Unsafe()); browser_state_->GetStatePath().AsUTF8Unsafe());
[session_service_ [session_service_ deleteAllSessionFilesInBrowserStateDirectory:state_path
deleteLastSessionFileInDirectory:state_path completion:CreatePendingTaskCompletionClosure()];
completion:
CreatePendingTaskCompletionClosure()];
} }
// Remove the screenshots taken by the system when backgrounding the // Remove the screenshots taken by the system when backgrounding the
......
...@@ -47,9 +47,11 @@ NSString* const kSessionsDirectory = @"Sessions"; ...@@ -47,9 +47,11 @@ NSString* const kSessionsDirectory = @"Sessions";
// of errors. // of errors.
- (SessionIOS*)loadSessionFromPath:(NSString*)sessionPath; - (SessionIOS*)loadSessionFromPath:(NSString*)sessionPath;
// Schedules deletion of the file containing the last session in |directory|. // Schedules deletion of the all session files from a specific browser state
- (void)deleteLastSessionFileInDirectory:(NSString*)directory // |directory|.
completion:(base::OnceClosure)callback; - (void)deleteAllSessionFilesInBrowserStateDirectory:(NSString*)directory
completion:
(base::OnceClosure)callback;
// Schedule deletion of session directories with |sessionIDs| which resides in // Schedule deletion of session directories with |sessionIDs| which resides in
// a specific browser state |directory|. // a specific browser state |directory|.
......
...@@ -171,11 +171,29 @@ NSString* const kSessionFileName = ...@@ -171,11 +171,29 @@ NSString* const kSessionFileName =
return base::mac::ObjCCastStrict<SessionIOS>(rootObject); return base::mac::ObjCCastStrict<SessionIOS>(rootObject);
} }
- (void)deleteLastSessionFileInDirectory:(NSString*)directory - (void)deleteAllSessionFilesInBrowserStateDirectory:(NSString*)directory
completion:(base::OnceClosure)callback { completion:
NSString* sessionPath = [[self class] sessionPathForDirectory:directory]; (base::OnceClosure)callback {
[self deletePaths:[NSArray arrayWithObject:sessionPath] NSMutableArray<NSString*>* sessionFilesPaths = [[NSMutableArray alloc] init];
completion:std::move(callback)]; NSString* sessionsDirectoryPath =
[directory stringByAppendingPathComponent:kSessionDirectory];
NSArray<NSString*>* allSessionIDs = [[NSFileManager defaultManager]
contentsOfDirectoryAtPath:sessionsDirectoryPath
error:nil];
for (NSString* sessionID in allSessionIDs) {
NSString* sessionPath =
[SessionServiceIOS sessionPathForSessionID:sessionID
directory:directory];
[sessionFilesPaths addObject:sessionPath];
}
// If there were no session ids, then scenes are not supported fall back to
// the original location
if (sessionFilesPaths.count == 0)
[sessionFilesPaths
addObject:[[self class] sessionPathForDirectory:directory]];
[self deletePaths:sessionFilesPaths completion:std::move(callback)];
} }
- (void)deleteSessions:(NSArray<NSString*>*)sessionIDs - (void)deleteSessions:(NSArray<NSString*>*)sessionIDs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment