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

Unified Diff: chrome/browser/extensions/unpacked_installer.cc

Issue 2108853002: Restrict use of two app-launching command line flags (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add /* explanation */ for the bool parameter Created 4 years, 5 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
Index: chrome/browser/extensions/unpacked_installer.cc
diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc
index f812a2f5f368e2391f6404ffb8128699c844337f..988293d951b887b6b6b1308bd7aaec09155e0c6f 100644
--- a/chrome/browser/extensions/unpacked_installer.cc
+++ b/chrome/browser/extensions/unpacked_installer.cc
@@ -40,6 +40,10 @@ namespace {
const char kUnpackedExtensionsBlacklistedError[] =
"Loading of unpacked extensions is disabled by the administrator.";
+const char kUnpackedExtensionInsteadOfAppError[] =
+ "App loading flags cannot be used to load extensions. Please use "
+ "--load-extension instead.";
+
const char kImportMinVersionNewer[] =
"'import' version requested is newer than what is installed.";
const char kImportMissing[] = "'import' extension is not installed.";
@@ -130,7 +134,8 @@ void UnpackedInstaller::Load(const base::FilePath& path_in) {
}
bool UnpackedInstaller::LoadFromCommandLine(const base::FilePath& path_in,
- std::string* extension_id) {
+ std::string* extension_id,
+ bool only_allow_apps) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(extension_path_.empty());
@@ -152,6 +157,16 @@ bool UnpackedInstaller::LoadFromCommandLine(const base::FilePath& path_in,
file_util::LoadExtension(
extension_path_, Manifest::COMMAND_LINE, GetFlags(), &error).get());
+ if (only_allow_apps && !extension()->is_platform_app()) {
+#if defined(GOOGLE_CHROME_BUILD)
+ // Avoid crashing for users with hijacked shortcuts.
+ return true;
+#else
+ ReportExtensionLoadError(kUnpackedExtensionInsteadOfAppError);
+ return false;
+#endif
+ }
+
if (!extension() ||
!extension_l10n_util::ValidateExtensionLocales(
extension_path_, extension()->manifest()->value(), &error)) {

Powered by Google App Engine
This is Rietveld 408576698