-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add shell.trashItem() to replace shell.moveItemToTrash() (#25114)
- Loading branch information
Showing
11 changed files
with
212 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
export default process._linkedBinding('electron_common_shell'); | ||
import { deprecate } from 'electron/main'; | ||
|
||
const shell = process._linkedBinding('electron_common_shell'); | ||
|
||
shell.moveItemToTrash = deprecate.renameFunction(shell.moveItemToTrash, 'shell.trashItem'); | ||
|
||
export default shell; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2020 Slack Technologies, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "shell/common/platform_util.h" | ||
|
||
#include <utility> | ||
|
||
#include "base/bind.h" | ||
#include "base/task/thread_pool.h" | ||
#include "content/public/browser/browser_task_traits.h" | ||
#include "content/public/browser/browser_thread.h" | ||
#include "shell/common/platform_util_internal.h" | ||
|
||
namespace platform_util { | ||
|
||
void TrashItemOnBlockingThread( | ||
const base::FilePath& full_path, | ||
base::OnceCallback<void(bool, const std::string&)> callback) { | ||
std::string error; | ||
bool success = internal::PlatformTrashItem(full_path, &error); | ||
content::GetUIThreadTaskRunner({})->PostTask( | ||
FROM_HERE, base::BindOnce(std::move(callback), success, error)); | ||
} | ||
|
||
void TrashItem(const base::FilePath& full_path, | ||
base::OnceCallback<void(bool, const std::string&)> callback) { | ||
// XXX: is continue_on_shutdown right? | ||
base::ThreadPool::PostTask(FROM_HERE, | ||
{base::MayBlock(), base::WithBaseSyncPrimitives(), | ||
base::TaskPriority::USER_BLOCKING, | ||
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, | ||
base::BindOnce(&TrashItemOnBlockingThread, | ||
full_path, std::move(callback))); | ||
} | ||
|
||
} // namespace platform_util |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2020 Slack Technologies, Inc. | ||
// Use of this source code is governed by the MIT license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef SHELL_COMMON_PLATFORM_UTIL_INTERNAL_H_ | ||
#define SHELL_COMMON_PLATFORM_UTIL_INTERNAL_H_ | ||
|
||
#include "shell/common/platform_util.h" | ||
|
||
#include <string> | ||
|
||
namespace base { | ||
class FilePath; | ||
} | ||
|
||
namespace platform_util { | ||
namespace internal { | ||
|
||
// Called by platform_util.cc on to invoke platform specific logic to move | ||
// |path| to trash using a suitable handler. | ||
bool PlatformTrashItem(const base::FilePath& path, std::string* error); | ||
|
||
} // namespace internal | ||
} // namespace platform_util | ||
|
||
#endif // SHELL_COMMON_PLATFORM_UTIL_INTERNAL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters