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

Unified Diff: chrome/browser/android/webapk/webapk_installer.cc

Issue 2236033003: Make downloaded WebAPK world readable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_builder_impl2_directory Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/webapk/webapk_installer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/webapk/webapk_installer.cc
diff --git a/chrome/browser/android/webapk/webapk_installer.cc b/chrome/browser/android/webapk/webapk_installer.cc
index 6e30ff6d51ed30b29ff9ce7232817333fb2da8a5..19affd8fbf29cd105e0d4ed66380853284e575a7 100644
--- a/chrome/browser/android/webapk/webapk_installer.cc
+++ b/chrome/browser/android/webapk/webapk_installer.cc
@@ -84,6 +84,13 @@ std::string ColorToString(int64_t color) {
return base::StringPrintf("rgba(%d,%d,%d,%.2f)", r, g, b, a);
}
+// Returns task runner for running background tasks.
+scoped_refptr<base::TaskRunner> GetBackgroundTaskRunner() {
+ return content::BrowserThread::GetBlockingPool()
+ ->GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
+}
+
} // anonymous namespace
WebApkInstaller::WebApkInstaller(const ShortcutInfo& shortcut_info,
@@ -117,12 +124,8 @@ void WebApkInstaller::InstallAsyncWithURLRequestContextGetter(
// base::Unretained() is safe because WebApkInstaller owns itself and does not
// start the timeout timer till after SendCreateWebApkRequest() is called.
- scoped_refptr<base::TaskRunner> background_task_runner =
- content::BrowserThread::GetBlockingPool()
- ->GetTaskRunnerWithShutdownBehavior(
- base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
base::PostTaskAndReplyWithResult(
- background_task_runner.get(), FROM_HERE,
+ GetBackgroundTaskRunner().get(), FROM_HERE,
base::Bind(&WebApkInstaller::BuildWebApkProtoInBackground,
base::Unretained(this)),
base::Bind(&WebApkInstaller::SendCreateWebApkRequest,
@@ -214,6 +217,26 @@ void WebApkInstaller::OnWebApkDownloaded(const base::FilePath& file_path,
return;
}
+ int posix_permissions = base::FILE_PERMISSION_READ_BY_USER |
+ base::FILE_PERMISSION_WRITE_BY_USER |
+ base::FILE_PERMISSION_READ_BY_GROUP |
+ base::FILE_PERMISSION_READ_BY_OTHERS;
+ base::PostTaskAndReplyWithResult(
+ GetBackgroundTaskRunner().get(), FROM_HERE,
+ base::Bind(&base::SetPosixFilePermissions, file_path, posix_permissions),
+ base::Bind(&WebApkInstaller::OnWebApkMadeWorldReadable,
+ weak_ptr_factory_.GetWeakPtr(), file_path, package_name));
+}
+
+void WebApkInstaller::OnWebApkMadeWorldReadable(
+ const base::FilePath& file_path,
+ const std::string& package_name,
+ bool change_permission_success) {
+ if (!change_permission_success) {
+ OnFailure();
+ return;
+ }
+
JNIEnv* env = base::android::AttachCurrentThread();
base::android::ScopedJavaLocalRef<jstring> java_file_path =
base::android::ConvertUTF8ToJavaString(env, file_path.value());
« no previous file with comments | « chrome/browser/android/webapk/webapk_installer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698