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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" | 14 #include "chrome/browser/extensions/api/app_runtime/app_runtime_api.h" |
15 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" | 15 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
16 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 16 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
17 #include "chrome/browser/extensions/event_router.h" | 17 #include "chrome/browser/extensions/event_router.h" |
18 #include "chrome/browser/extensions/extension_host.h" | 18 #include "chrome/browser/extensions/extension_host.h" |
19 #include "chrome/browser/extensions/extension_prefs.h" | 19 #include "chrome/browser/extensions/extension_prefs.h" |
20 #include "chrome/browser/extensions/extension_process_manager.h" | 20 #include "chrome/browser/extensions/extension_process_manager.h" |
21 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
22 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
23 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 23 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/ui/apps/app_metro_infobar_delegate_win.h" | 25 #include "chrome/browser/ui/apps/app_metro_infobar_delegate_win.h" |
26 #include "chrome/common/extensions/api/app_runtime.h" | 26 #include "chrome/common/extensions/api/app_runtime.h" |
27 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
28 #include "chrome/common/extensions/extension_messages.h" | 28 #include "chrome/common/extensions/extension_messages.h" |
| 29 #include "chrome/common/extensions/manifest_handlers/kiosk_mode_info.h" |
29 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
31 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
32 #include "net/base/mime_util.h" | 33 #include "net/base/mime_util.h" |
33 #include "net/base/net_util.h" | 34 #include "net/base/net_util.h" |
34 #include "url/gurl.h" | 35 #include "url/gurl.h" |
35 | 36 |
36 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
37 #include "chrome/browser/chromeos/drive/file_errors.h" | 38 #include "chrome/browser/chromeos/drive/file_errors.h" |
38 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 39 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
39 #include "chrome/browser/chromeos/drive/file_system_util.h" | 40 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 41 #include "chrome/browser/chromeos/login/user_manager.h" |
40 #endif | 42 #endif |
41 | 43 |
42 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
43 #include "win8/util/win8_util.h" | 45 #include "win8/util/win8_util.h" |
44 #endif | 46 #endif |
45 | 47 |
46 namespace app_runtime = extensions::api::app_runtime; | 48 namespace app_runtime = extensions::api::app_runtime; |
47 | 49 |
48 using content::BrowserThread; | 50 using content::BrowserThread; |
49 using extensions::app_file_handler_util::CheckWritableFiles; | 51 using extensions::app_file_handler_util::CheckWritableFiles; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher); | 308 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher); |
307 }; | 309 }; |
308 | 310 |
309 } // namespace | 311 } // namespace |
310 | 312 |
311 void LaunchPlatformAppWithCommandLine(Profile* profile, | 313 void LaunchPlatformAppWithCommandLine(Profile* profile, |
312 const Extension* extension, | 314 const Extension* extension, |
313 const CommandLine* command_line, | 315 const CommandLine* command_line, |
314 const base::FilePath& current_directory) { | 316 const base::FilePath& current_directory) { |
315 #if defined(OS_WIN) | 317 #if defined(OS_WIN) |
316 // On Windows 8's single window Metro mode we can not launch platform apps. | 318 // On Windows 8's single window Metro mode we can not launch platform apps. |
317 // Offer to switch Chrome to desktop mode. | 319 // Offer to switch Chrome to desktop mode. |
318 if (win8::IsSingleWindowMetroMode()) { | 320 if (win8::IsSingleWindowMetroMode()) { |
319 AppMetroInfoBarDelegateWin::Create( | 321 AppMetroInfoBarDelegateWin::Create( |
320 profile, AppMetroInfoBarDelegateWin::LAUNCH_PACKAGED_APP, | 322 profile, AppMetroInfoBarDelegateWin::LAUNCH_PACKAGED_APP, |
321 extension->id()); | 323 extension->id()); |
| 324 return; |
| 325 } |
| 326 #endif |
| 327 |
| 328 // An app with "kiosk_only" should not be installed and launched |
| 329 // outside of ChromeOS kiosk mode in the first place. This is a defensive |
| 330 // check in case this scenario does occur. |
| 331 if (extensions::KioskModeInfo::IsKioskOnly(extension)) { |
| 332 bool in_kiosk_mode = false; |
| 333 #if defined(OS_CHROMEOS) |
| 334 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 335 in_kiosk_mode = user_manager && user_manager->IsLoggedInAsKioskApp(); |
| 336 #endif |
| 337 if (!in_kiosk_mode) { |
| 338 LOG(ERROR) << "App with 'kiosk_only' attribute must be run in " |
| 339 << " ChromeOS kiosk mode."; |
| 340 NOTREACHED(); |
322 return; | 341 return; |
323 } | 342 } |
324 #endif | 343 } |
325 | 344 |
326 base::FilePath path; | 345 base::FilePath path; |
327 if (!GetAbsolutePathFromCommandLine(command_line, current_directory, &path)) { | 346 if (!GetAbsolutePathFromCommandLine(command_line, current_directory, &path)) { |
328 LaunchPlatformAppWithNoData(profile, extension); | 347 LaunchPlatformAppWithNoData(profile, extension); |
329 return; | 348 return; |
330 } | 349 } |
331 | 350 |
332 // TODO(benwells): add a command-line argument to provide a handler ID. | 351 // TODO(benwells): add a command-line argument to provide a handler ID. |
333 LaunchPlatformAppWithPath(profile, extension, path); | 352 LaunchPlatformAppWithPath(profile, extension, path); |
334 } | 353 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 void LaunchPlatformAppWithUrl(Profile* profile, | 409 void LaunchPlatformAppWithUrl(Profile* profile, |
391 const Extension* extension, | 410 const Extension* extension, |
392 const std::string& handler_id, | 411 const std::string& handler_id, |
393 const GURL& url, | 412 const GURL& url, |
394 const GURL& referrer_url) { | 413 const GURL& referrer_url) { |
395 extensions::AppEventRouter::DispatchOnLaunchedEventWithUrl( | 414 extensions::AppEventRouter::DispatchOnLaunchedEventWithUrl( |
396 profile, extension, handler_id, url, referrer_url); | 415 profile, extension, handler_id, url, referrer_url); |
397 } | 416 } |
398 | 417 |
399 } // namespace apps | 418 } // namespace apps |
OLD | NEW |