Prevent creating background pages for non-incognito profile in Guest mode
BUG=329498
TEST=manually
Review URL: https://codereview.chromium.org/101413011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242271 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/chrome_extensions_browser_client.cc b/chrome/browser/extensions/chrome_extensions_browser_client.cc
index 69b3a96..f6b1292 100644
--- a/chrome/browser/extensions/chrome_extensions_browser_client.cc
+++ b/chrome/browser/extensions/chrome_extensions_browser_client.cc
@@ -18,6 +18,10 @@
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
+#if defined(OS_CHROMEOS)
+#include "chromeos/chromeos_switches.h"
+#endif
+
namespace extensions {
ChromeExtensionsBrowserClient::ChromeExtensionsBrowserClient() {}
@@ -89,6 +93,21 @@
#endif
}
+bool ChromeExtensionsBrowserClient::IsBackgroundPageAllowed(
+ content::BrowserContext* context) const {
+#if defined(OS_CHROMEOS)
+ // Returns true if current session is Chrome OS Guest mode session and current
+ // browser context is *not* off-the-record. Such context is artificial and
+ // background page shouldn't be created in it.
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(chromeos::switches::kGuestSession) &&
+ !context->IsOffTheRecord()) {
+ return false;
+ }
+#endif
+ return true;
+}
+
bool ChromeExtensionsBrowserClient::DidVersionUpdate(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);