Commit 40df60be authored by koz@chromium.org's avatar koz@chromium.org

Prevent chrome from launching apps in incognito mode from the command line.

`chrome --app-id=x --incognito` currently launches an app in incognito mode, which is not allowed. After this patch it will simply ignore the --app-id flag.


BUG=155130


Review URL: https://chromiumcodereview.appspot.com/11348315

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170529 0039d316-1c4b-4281-b951-d872f2087c98
parent aec331eb
......@@ -453,8 +453,12 @@ void StartupBrowserCreatorImpl::ExtractOptionalAppWindowSize(
}
}
bool StartupBrowserCreatorImpl::IsAppLaunch(std::string* app_url,
bool StartupBrowserCreatorImpl::IsAppLaunch(Profile* profile,
std::string* app_url,
std::string* app_id) {
// Don't launch apps in incognito mode.
if (profile->IsOffTheRecord())
return false;
if (command_line_.HasSwitch(switches::kApp)) {
if (app_url)
*app_url = command_line_.GetSwitchValueASCII(switches::kApp);
......@@ -474,7 +478,7 @@ bool StartupBrowserCreatorImpl::OpenApplicationTab(Profile* profile) {
// function will open an app that should be in a tab, there is no need
// to look at the app URL. OpenApplicationWindow() will open app url
// shortcuts.
if (!IsAppLaunch(NULL, &app_id) || app_id.empty())
if (!IsAppLaunch(profile, NULL, &app_id) || app_id.empty())
return false;
extension_misc::LaunchContainer launch_container;
......@@ -502,7 +506,7 @@ bool StartupBrowserCreatorImpl::OpenApplicationWindow(
*out_app_contents = NULL;
std::string url_string, app_id;
if (!IsAppLaunch(&url_string, &app_id))
if (!IsAppLaunch(profile, &url_string, &app_id))
return false;
// This can fail if the app_id is invalid. It can also fail if the
......
......@@ -78,7 +78,7 @@ class StartupBrowserCreatorImpl {
// If the process was launched with the web application command line flags,
// e.g. --app=http://www.google.com/ or --app_id=... return true.
// In this case |app_url| or |app_id| are populated if they're non-null.
bool IsAppLaunch(std::string* app_url, std::string* app_id);
bool IsAppLaunch(Profile* profile, std::string* app_url, std::string* app_id);
// If IsAppLaunch is true, tries to open an application window.
// If the app is specified to start in a tab, or IsAppLaunch is false,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment