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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 }; | 356 }; |
357 | 357 |
358 } // namespace | 358 } // namespace |
359 | 359 |
360 void LaunchPlatformAppWithCommandLine(Profile* profile, | 360 void LaunchPlatformAppWithCommandLine(Profile* profile, |
361 const extensions::Extension* app, | 361 const extensions::Extension* app, |
362 const base::CommandLine& command_line, | 362 const base::CommandLine& command_line, |
363 const base::FilePath& current_directory, | 363 const base::FilePath& current_directory, |
364 extensions::AppLaunchSource source, | 364 extensions::AppLaunchSource source, |
365 PlayStoreStatus play_store_status) { | 365 PlayStoreStatus play_store_status) { |
| 366 LaunchPlatformAppWithCommandLineAndLaunchId(profile, app, "", command_line, |
| 367 current_directory, source, |
| 368 play_store_status); |
| 369 } |
| 370 |
| 371 void LaunchPlatformAppWithCommandLineAndLaunchId( |
| 372 Profile* profile, |
| 373 const extensions::Extension* app, |
| 374 const std::string& launch_id, |
| 375 const base::CommandLine& command_line, |
| 376 const base::FilePath& current_directory, |
| 377 extensions::AppLaunchSource source, |
| 378 PlayStoreStatus play_store_status) { |
366 // An app with "kiosk_only" should not be installed and launched | 379 // An app with "kiosk_only" should not be installed and launched |
367 // outside of ChromeOS kiosk mode in the first place. This is a defensive | 380 // outside of ChromeOS kiosk mode in the first place. This is a defensive |
368 // check in case this scenario does occur. | 381 // check in case this scenario does occur. |
369 if (extensions::KioskModeInfo::IsKioskOnly(app)) { | 382 if (extensions::KioskModeInfo::IsKioskOnly(app)) { |
370 bool in_kiosk_mode = false; | 383 bool in_kiosk_mode = false; |
371 #if defined(OS_CHROMEOS) | 384 #if defined(OS_CHROMEOS) |
372 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 385 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
373 in_kiosk_mode = user_manager && user_manager->IsLoggedInAsKioskApp(); | 386 in_kiosk_mode = user_manager && user_manager->IsLoggedInAsKioskApp(); |
374 #endif | 387 #endif |
375 if (!in_kiosk_mode) { | 388 if (!in_kiosk_mode) { |
376 LOG(ERROR) << "App with 'kiosk_only' attribute must be run in " | 389 LOG(ERROR) << "App with 'kiosk_only' attribute must be run in " |
377 << " ChromeOS kiosk mode."; | 390 << " ChromeOS kiosk mode."; |
378 NOTREACHED(); | 391 NOTREACHED(); |
379 return; | 392 return; |
380 } | 393 } |
381 } | 394 } |
382 | 395 |
383 #if defined(OS_WIN) | 396 #if defined(OS_WIN) |
384 base::CommandLine::StringType about_blank_url( | 397 base::CommandLine::StringType about_blank_url( |
385 base::ASCIIToUTF16(url::kAboutBlankURL)); | 398 base::ASCIIToUTF16(url::kAboutBlankURL)); |
386 #else | 399 #else |
387 base::CommandLine::StringType about_blank_url(url::kAboutBlankURL); | 400 base::CommandLine::StringType about_blank_url(url::kAboutBlankURL); |
388 #endif | 401 #endif |
389 base::CommandLine::StringVector args = command_line.GetArgs(); | 402 base::CommandLine::StringVector args = command_line.GetArgs(); |
390 // Browser tests will add about:blank to the command line. This should | 403 // Browser tests will add about:blank to the command line. This should |
391 // never be interpreted as a file to open, as doing so with an app that | 404 // never be interpreted as a file to open, as doing so with an app that |
392 // has write access will result in a file 'about' being created, which | 405 // has write access will result in a file 'about' being created, which |
393 // causes problems on the bots. | 406 // causes problems on the bots. |
394 if (args.empty() || (command_line.HasSwitch(switches::kTestType) && | 407 if (args.empty() || (command_line.HasSwitch(switches::kTestType) && |
395 args[0] == about_blank_url)) { | 408 args[0] == about_blank_url)) { |
396 std::unique_ptr<app_runtime::LaunchData> launch_data = | 409 std::unique_ptr<app_runtime::LaunchData> launch_data = |
397 base::MakeUnique<app_runtime::LaunchData>(); | 410 base::MakeUnique<app_runtime::LaunchData>(); |
398 if (play_store_status != PlayStoreStatus::PLAY_STORE_STATUS_UNKNOWN) | 411 if (play_store_status != PlayStoreStatus::PLAY_STORE_STATUS_UNKNOWN) |
399 launch_data->play_store_status = play_store_status; | 412 launch_data->play_store_status = play_store_status; |
| 413 if (!launch_id.empty()) |
| 414 launch_data->id.reset(new std::string(launch_id)); |
400 AppRuntimeEventRouter::DispatchOnLaunchedEvent(profile, app, source, | 415 AppRuntimeEventRouter::DispatchOnLaunchedEvent(profile, app, source, |
401 std::move(launch_data)); | 416 std::move(launch_data)); |
402 return; | 417 return; |
403 } | 418 } |
404 | 419 |
405 base::FilePath file_path(command_line.GetArgs()[0]); | 420 base::FilePath file_path(command_line.GetArgs()[0]); |
406 scoped_refptr<PlatformAppPathLauncher> launcher = | 421 scoped_refptr<PlatformAppPathLauncher> launcher = |
407 new PlatformAppPathLauncher(profile, app, file_path); | 422 new PlatformAppPathLauncher(profile, app, file_path); |
408 launcher->LaunchWithRelativePath(current_directory); | 423 launcher->LaunchWithRelativePath(current_directory); |
409 } | 424 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 void LaunchPlatformAppWithUrl(Profile* profile, | 487 void LaunchPlatformAppWithUrl(Profile* profile, |
473 const Extension* app, | 488 const Extension* app, |
474 const std::string& handler_id, | 489 const std::string& handler_id, |
475 const GURL& url, | 490 const GURL& url, |
476 const GURL& referrer_url) { | 491 const GURL& referrer_url) { |
477 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl( | 492 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl( |
478 profile, app, handler_id, url, referrer_url); | 493 profile, app, handler_id, url, referrer_url); |
479 } | 494 } |
480 | 495 |
481 } // namespace apps | 496 } // namespace apps |
OLD | NEW |