From 3c046d3a419e4585d5c6f7b1f6d5963ce8a5902b Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Wed, 6 Jun 2018 01:22:08 -0400 Subject: [PATCH] Allow progressive web apps (PWAs) --- app/brave_main_delegate.cc | 9 ++++++++- extensions/browser/brave_extension_provider.cc | 11 ++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/brave_main_delegate.cc b/app/brave_main_delegate.cc index 59674c867da7..bd01ff807d74 100644 --- a/app/brave_main_delegate.cc +++ b/app/brave_main_delegate.cc @@ -4,6 +4,8 @@ #include "brave/app/brave_main_delegate.h" +#include + #include "base/base_switches.h" #include "base/lazy_instance.h" #include "base/path_service.h" @@ -13,6 +15,7 @@ #include "brave/common/resource_bundle_helper.h" #include "brave/renderer/brave_content_renderer_client.h" #include "brave/utility/brave_content_utility_client.h" +#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths_internal.h" #include "chrome/common/chrome_switches.h" @@ -101,7 +104,11 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) { base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); command_line.AppendSwitch(switches::kEnableTabAudioMuting); + + std::stringstream enabled_features; + enabled_features << features::kEnableEmojiContextMenu.name + << "," << features::kDesktopPWAWindowing.name; command_line.AppendSwitchASCII(switches::kEnableFeatures, - features::kEnableEmojiContextMenu.name); + enabled_features.str()); return ChromeMainDelegate::BasicStartupComplete(exit_code); } diff --git a/extensions/browser/brave_extension_provider.cc b/extensions/browser/brave_extension_provider.cc index e0c97bbcd2a8..e2f6a274d7cd 100644 --- a/extensions/browser/brave_extension_provider.cc +++ b/extensions/browser/brave_extension_provider.cc @@ -15,7 +15,11 @@ namespace { -bool IsWhitelisted(const std::string& id) { +bool IsWhitelisted(const extensions::Extension* extension) { + // Allow PWAs to run + if (extension->GetType() == extensions::Manifest::TYPE_HOSTED_APP) { + return true; + } static std::vector whitelist({ brave_extension_id, pdfjs_extension_id, @@ -70,7 +74,8 @@ bool IsWhitelisted(const std::string& id) { // Test ID: Brave HTTPS Everywhere Updater "bhlmpjhncoojbkemjkeppfahkglffilp" }); - return std::find(whitelist.begin(), whitelist.end(), id) != whitelist.end(); + return std::find(whitelist.begin(), whitelist.end(), + extension->id()) != whitelist.end(); } } // namespace @@ -94,7 +99,7 @@ std::string BraveExtensionProvider::GetDebugPolicyProviderName() const { bool BraveExtensionProvider::UserMayLoad(const Extension* extension, base::string16* error) const { - if (!IsWhitelisted(extension->id())) { + if (!IsWhitelisted(extension)) { if (error) { *error = l10n_util::GetStringFUTF16(IDS_EXTENSION_CANT_INSTALL_ON_BRAVE,