OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "apps/launcher.h" | 5 #include "apps/launcher.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
401 std::move(launch_data)); | 401 std::move(launch_data)); |
402 return; | 402 return; |
403 } | 403 } |
404 | 404 |
405 base::FilePath file_path(command_line.GetArgs()[0]); | 405 base::FilePath file_path(command_line.GetArgs()[0]); |
406 scoped_refptr<PlatformAppPathLauncher> launcher = | 406 scoped_refptr<PlatformAppPathLauncher> launcher = |
407 new PlatformAppPathLauncher(profile, app, file_path); | 407 new PlatformAppPathLauncher(profile, app, file_path); |
408 launcher->LaunchWithRelativePath(current_directory); | 408 launcher->LaunchWithRelativePath(current_directory); |
409 } | 409 } |
410 | 410 |
411 void LaunchPlatformAppWithCommandLineAndLaunchId( | |
412 Profile* profile, | |
413 const extensions::Extension* app, | |
414 const std::string& launch_id, | |
415 const base::CommandLine& command_line, | |
416 const base::FilePath& current_directory, | |
417 extensions::AppLaunchSource source, | |
418 PlayStoreStatus play_store_status) { | |
419 // An app with "kiosk_only" should not be installed and launched | |
420 // outside of ChromeOS kiosk mode in the first place. This is a defensive | |
421 // check in case this scenario does occur. | |
422 if (extensions::KioskModeInfo::IsKioskOnly(app)) { | |
423 bool in_kiosk_mode = false; | |
424 #if defined(OS_CHROMEOS) | |
425 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | |
426 in_kiosk_mode = user_manager && user_manager->IsLoggedInAsKioskApp(); | |
427 #endif | |
428 if (!in_kiosk_mode) { | |
429 LOG(ERROR) << "App with 'kiosk_only' attribute must be run in " | |
430 << " ChromeOS kiosk mode."; | |
431 NOTREACHED(); | |
432 return; | |
433 } | |
434 } | |
stevenjb
2016/12/06 16:42:07
Don't duplucate all of this code, have LaunchPlatf
Andra Paraschiv
2016/12/07 08:33:21
Yes, sorry for this, I fixed it now.
| |
435 | |
436 #if defined(OS_WIN) | |
437 base::CommandLine::StringType about_blank_url( | |
438 base::ASCIIToUTF16(url::kAboutBlankURL)); | |
439 #else | |
440 base::CommandLine::StringType about_blank_url(url::kAboutBlankURL); | |
441 #endif | |
442 base::CommandLine::StringVector args = command_line.GetArgs(); | |
443 // Browser tests will add about:blank to the command line. This should | |
444 // never be interpreted as a file to open, as doing so with an app that | |
445 // has write access will result in a file 'about' being created, which | |
446 // causes problems on the bots. | |
447 if (args.empty() || (command_line.HasSwitch(switches::kTestType) && | |
448 args[0] == about_blank_url)) { | |
449 std::unique_ptr<app_runtime::LaunchData> launch_data = | |
450 base::MakeUnique<app_runtime::LaunchData>(); | |
451 if (play_store_status != PlayStoreStatus::PLAY_STORE_STATUS_UNKNOWN) | |
452 launch_data->play_store_status = play_store_status; | |
453 launch_data->id.reset(new std::string(launch_id)); | |
454 AppRuntimeEventRouter::DispatchOnLaunchedEvent(profile, app, source, | |
455 std::move(launch_data)); | |
456 return; | |
457 } | |
458 | |
459 base::FilePath file_path(command_line.GetArgs()[0]); | |
460 scoped_refptr<PlatformAppPathLauncher> launcher = | |
461 new PlatformAppPathLauncher(profile, app, file_path); | |
462 launcher->LaunchWithRelativePath(current_directory); | |
463 } | |
464 | |
411 void LaunchPlatformAppWithPath(Profile* profile, | 465 void LaunchPlatformAppWithPath(Profile* profile, |
412 const Extension* app, | 466 const Extension* app, |
413 const base::FilePath& file_path) { | 467 const base::FilePath& file_path) { |
414 scoped_refptr<PlatformAppPathLauncher> launcher = | 468 scoped_refptr<PlatformAppPathLauncher> launcher = |
415 new PlatformAppPathLauncher(profile, app, file_path); | 469 new PlatformAppPathLauncher(profile, app, file_path); |
416 launcher->Launch(); | 470 launcher->Launch(); |
417 } | 471 } |
418 | 472 |
419 void LaunchPlatformAppWithAction( | 473 void LaunchPlatformAppWithAction( |
420 Profile* profile, | 474 Profile* profile, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 void LaunchPlatformAppWithUrl(Profile* profile, | 526 void LaunchPlatformAppWithUrl(Profile* profile, |
473 const Extension* app, | 527 const Extension* app, |
474 const std::string& handler_id, | 528 const std::string& handler_id, |
475 const GURL& url, | 529 const GURL& url, |
476 const GURL& referrer_url) { | 530 const GURL& referrer_url) { |
477 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl( | 531 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl( |
478 profile, app, handler_id, url, referrer_url); | 532 profile, app, handler_id, url, referrer_url); |
479 } | 533 } |
480 | 534 |
481 } // namespace apps | 535 } // namespace apps |
OLD | NEW |