diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-28 21:28:38 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-28 21:28:38 +0000 |
commit | 4dc3bcd6bc497ba5299212f9b8f960015c583761 (patch) | |
tree | eb941ee5f9bf4594c8b1f5f4c152f40141656702 | |
parent | 172c77a9f7922fc9b58632abe62173c66fb6e10b (diff) | |
download | chromium_src-4dc3bcd6bc497ba5299212f9b8f960015c583761.zip chromium_src-4dc3bcd6bc497ba5299212f9b8f960015c583761.tar.gz chromium_src-4dc3bcd6bc497ba5299212f9b8f960015c583761.tar.bz2 |
Remove unnecessary permission check in task execution from Files.app.
file_tasks::ExecuteTask is called either from
- ExecuteFileTaskForUrl, which always called GrantFileSystemAccessToFileBrowser beforehand, or
- fileBrowserPrivate.executeTask, which is used only from File manager that we always grant permission.
Hence, the check should just always pass.
BUG=337705
Review URL: https://codereview.chromium.org/148383007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247512 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 5 insertions, 59 deletions
diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc index ba77b16..e977271 100644 --- a/chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc @@ -62,9 +62,6 @@ bool FileBrowserPrivateExecuteTaskFunction::RunImpl() { const scoped_ptr<Params> params(Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params); - // TODO(kaznacheev): Crack the task_id here, store it in the Executor - // and avoid passing it around. - file_manager::file_tasks::TaskDescriptor task; if (!file_manager::file_tasks::ParseTaskID(params->task_id, &task)) { LOG(WARNING) << "Invalid task " << params->task_id; @@ -92,7 +89,6 @@ bool FileBrowserPrivateExecuteTaskFunction::RunImpl() { return file_manager::file_tasks::ExecuteFileTask( GetProfile(), source_url(), - extension_->id(), task, file_urls, base::Bind(&FileBrowserPrivateExecuteTaskFunction::OnTaskExecuted, this)); diff --git a/chrome/browser/chromeos/file_manager/file_tasks.cc b/chrome/browser/chromeos/file_manager/file_tasks.cc index 2298600..5cb3d8a 100644 --- a/chrome/browser/chromeos/file_manager/file_tasks.cc +++ b/chrome/browser/chromeos/file_manager/file_tasks.cc @@ -83,33 +83,6 @@ const char kDriveTaskExtensionPrefix[] = "drive-app:"; const size_t kDriveTaskExtensionPrefixLength = arraysize(kDriveTaskExtensionPrefix) - 1; -// Checks if the file browser extension has permissions for the files in its -// file system context. -bool FileBrowserHasAccessPermissionForFiles( - Profile* profile, - const GURL& source_url, - const std::string& file_browser_id, - const std::vector<FileSystemURL>& files) { - fileapi::ExternalFileSystemBackend* backend = - util::GetFileSystemContextForExtensionId( - profile, file_browser_id)->external_backend(); - if (!backend) - return false; - - for (size_t i = 0; i < files.size(); ++i) { - // Make sure this url really being used by the right caller extension. - if (source_url.GetOrigin() != files[i].origin()) - return false; - - if (!chromeos::FileSystemBackend::CanHandleURL(files[i]) || - !backend->IsAccessAllowed(files[i])) { - return false; - } - } - - return true; -} - // Returns true if path_mime_set contains a Google document. bool ContainsGoogleDocument(const PathAndMimeTypeSet& path_mime_set) { for (PathAndMimeTypeSet::const_iterator iter = path_mime_set.begin(); @@ -264,14 +237,9 @@ bool ParseTaskID(const std::string& task_id, TaskDescriptor* task) { bool ExecuteFileTask(Profile* profile, const GURL& source_url, - const std::string& app_id, const TaskDescriptor& task, const std::vector<FileSystemURL>& file_urls, const FileTaskFinishedCallback& done) { - if (!FileBrowserHasAccessPermissionForFiles(profile, source_url, - app_id, file_urls)) - return false; - // drive::FileTaskExecutor is responsible to handle drive tasks. if (task.task_type == TASK_TYPE_DRIVE_APP) { DCHECK_EQ(kDriveAppActionID, task.action_id); diff --git a/chrome/browser/chromeos/file_manager/file_tasks.h b/chrome/browser/chromeos/file_manager/file_tasks.h index 8be6edc..fb773a1 100644 --- a/chrome/browser/chromeos/file_manager/file_tasks.h +++ b/chrome/browser/chromeos/file_manager/file_tasks.h @@ -235,7 +235,6 @@ typedef base::Callback<void(bool success)> FileTaskFinishedCallback; // // Parameters: // profile - The profile used for making this function call. -// app_id - The ID of the app requesting the file task execution. // source_url - The source URL which originates this function call. // task - See the comment at TaskDescriptor struct. // file_urls - URLs of the target files. @@ -244,7 +243,6 @@ typedef base::Callback<void(bool success)> FileTaskFinishedCallback; // false. bool ExecuteFileTask(Profile* profile, const GURL& source_url, - const std::string& app_id, const TaskDescriptor& task, const std::vector<fileapi::FileSystemURL>& file_urls, const FileTaskFinishedCallback& done); diff --git a/chrome/browser/chromeos/file_manager/open_util.cc b/chrome/browser/chromeos/file_manager/open_util.cc index 8b78185..30fe1ac 100644 --- a/chrome/browser/chromeos/file_manager/open_util.cc +++ b/chrome/browser/chromeos/file_manager/open_util.cc @@ -19,14 +19,12 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/extensions/application_launch.h" #include "chrome/browser/ui/simple_message_box.h" -#include "chrome/common/extensions/api/file_browser_handlers/file_browser_handler.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/user_metrics.h" @@ -38,8 +36,6 @@ #include "webkit/browser/fileapi/file_system_operation_runner.h" #include "webkit/browser/fileapi/file_system_url.h" -using base::UserMetricsAction; -using content::BrowserContext; using content::BrowserThread; using extensions::Extension; using extensions::app_file_handler_util::FindFileHandlersForFiles; @@ -58,7 +54,7 @@ void ShowWarningMessageBox(Profile* profile, const base::FilePath& file_path) { browser ? browser->window()->GetNativeWindow() : NULL, l10n_util::GetStringFUTF16( IDS_FILE_BROWSER_ERROR_VIEWING_FILE_TITLE, - base::UTF8ToUTF16(file_path.BaseName().value())), + base::UTF8ToUTF16(file_path.BaseName().AsUTF8Unsafe())), l10n_util::GetStringUTF16(IDS_FILE_BROWSER_ERROR_VIEWING_FILE), chrome::MESSAGE_BOX_TYPE_WARNING); } @@ -80,26 +76,14 @@ bool GrantFileSystemAccessToFileBrowser(Profile* profile) { void ExecuteFileTaskForUrl(Profile* profile, const file_tasks::TaskDescriptor& task, const GURL& url) { - // If the file manager has not been open yet then it did not request access - // to the file system. Do it now. - if (!GrantFileSystemAccessToFileBrowser(profile)) - return; - fileapi::FileSystemContext* file_system_context = - GetFileSystemContextForExtensionId( - profile, kFileManagerAppId); - - // We are executing the task on behalf of the file manager. - const GURL source_url = GetFileManagerMainPageUrl(); - std::vector<FileSystemURL> urls; - urls.push_back(file_system_context->CrackURL(url)); + GetFileSystemContextForExtensionId(profile, kFileManagerAppId); file_tasks::ExecuteFileTask( profile, - source_url, - kFileManagerAppId, + GetFileManagerMainPageUrl(), // Executing the task on behalf of Files.app. task, - urls, + std::vector<FileSystemURL>(1, file_system_context->CrackURL(url)), file_tasks::FileTaskFinishedCallback()); } @@ -118,7 +102,7 @@ void OpenFileManagerWithInternalActionId(Profile* profile, action_id == "open" || action_id == "select"); - content::RecordAction(UserMetricsAction("ShowFileBrowserFullTab")); + content::RecordAction(base::UserMetricsAction("ShowFileBrowserFullTab")); GURL url; if (!ConvertAbsoluteFilePathToFileSystemUrl( |