OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/platform_app_launcher.h" | 5 #include "chrome/browser/extensions/platform_app_launcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.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/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/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/extension_host.h" | 15 #include "chrome/browser/extensions/extension_host.h" |
16 #include "chrome/browser/extensions/extension_process_manager.h" | 16 #include "chrome/browser/extensions/extension_process_manager.h" |
17 #include "chrome/browser/extensions/extension_system.h" | 17 #include "chrome/browser/extensions/extension_system.h" |
18 #include "chrome/browser/extensions/lazy_background_task_queue.h" | 18 #include "chrome/browser/extensions/lazy_background_task_queue.h" |
| 19 #include "chrome/browser/extensions/platform_app_service.h" |
19 #include "chrome/browser/intents/web_intents_util.h" | 20 #include "chrome/browser/intents/web_intents_util.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
22 #include "chrome/common/extensions/extension_messages.h" | 23 #include "chrome/common/extensions/extension_messages.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/child_process_security_policy.h" | 25 #include "content/public/browser/child_process_security_policy.h" |
25 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
27 #include "content/public/browser/web_intents_dispatcher.h" | 28 #include "content/public/browser/web_intents_dispatcher.h" |
28 #include "net/base/mime_util.h" | 29 #include "net/base/mime_util.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 340 |
340 DISALLOW_COPY_AND_ASSIGN(PlatformAppWebIntentLauncher); | 341 DISALLOW_COPY_AND_ASSIGN(PlatformAppWebIntentLauncher); |
341 }; | 342 }; |
342 | 343 |
343 } // namespace | 344 } // namespace |
344 | 345 |
345 void LaunchPlatformApp(Profile* profile, | 346 void LaunchPlatformApp(Profile* profile, |
346 const Extension* extension, | 347 const Extension* extension, |
347 const CommandLine* command_line, | 348 const CommandLine* command_line, |
348 const FilePath& current_directory) { | 349 const FilePath& current_directory) { |
| 350 PlatformAppService::CreateInstance(profile); |
349 FilePath path; | 351 FilePath path; |
350 if (!GetAbsolutePathFromCommandLine(command_line, current_directory, &path)) { | 352 if (!GetAbsolutePathFromCommandLine(command_line, current_directory, &path)) { |
351 LaunchPlatformAppWithNoData(profile, extension); | 353 LaunchPlatformAppWithNoData(profile, extension); |
352 return; | 354 return; |
353 } | 355 } |
354 | 356 |
355 LaunchPlatformAppWithPath(profile, extension, path); | 357 LaunchPlatformAppWithPath(profile, extension, path); |
356 } | 358 } |
357 | 359 |
358 void LaunchPlatformAppWithPath(Profile* profile, | 360 void LaunchPlatformAppWithPath(Profile* profile, |
359 const Extension* extension, | 361 const Extension* extension, |
360 const FilePath& file_path) { | 362 const FilePath& file_path) { |
| 363 PlatformAppService::CreateInstance(profile); |
361 // launcher will be freed when nothing has a reference to it. The message | 364 // launcher will be freed when nothing has a reference to it. The message |
362 // queue will retain a reference for any outstanding task, so when the | 365 // queue will retain a reference for any outstanding task, so when the |
363 // launcher has finished it will be freed. | 366 // launcher has finished it will be freed. |
364 scoped_refptr<PlatformAppPathLauncher> launcher = | 367 scoped_refptr<PlatformAppPathLauncher> launcher = |
365 new PlatformAppPathLauncher(profile, extension, file_path); | 368 new PlatformAppPathLauncher(profile, extension, file_path); |
366 launcher->Launch(); | 369 launcher->Launch(); |
367 } | 370 } |
368 | 371 |
369 void LaunchPlatformAppWithWebIntent( | 372 void LaunchPlatformAppWithWebIntent( |
370 Profile* profile, | 373 Profile* profile, |
371 const Extension* extension, | 374 const Extension* extension, |
372 content::WebIntentsDispatcher* intents_dispatcher, | 375 content::WebIntentsDispatcher* intents_dispatcher, |
373 content::WebContents* source) { | 376 content::WebContents* source) { |
| 377 PlatformAppService::CreateInstance(profile); |
374 scoped_refptr<PlatformAppWebIntentLauncher> launcher = | 378 scoped_refptr<PlatformAppWebIntentLauncher> launcher = |
375 new PlatformAppWebIntentLauncher( | 379 new PlatformAppWebIntentLauncher( |
376 profile, extension, intents_dispatcher, source); | 380 profile, extension, intents_dispatcher, source); |
377 launcher->Launch(); | 381 launcher->Launch(); |
378 } | 382 } |
379 | 383 |
380 } // namespace extensions | 384 } // namespace extensions |
OLD | NEW |