launcher.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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
  3. // found in the LICENSE file.
  4. #ifndef APPS_LAUNCHER_H_
  5. #define APPS_LAUNCHER_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "extensions/common/api/app_runtime.h"
  10. #include "extensions/common/constants.h"
  11. class GURL;
  12. namespace base {
  13. class CommandLine;
  14. class FilePath;
  15. }
  16. namespace content {
  17. class BrowserContext;
  18. }
  19. namespace extensions {
  20. class Extension;
  21. namespace api {
  22. namespace app_runtime {
  23. struct ActionData;
  24. }
  25. }
  26. }
  27. namespace apps {
  28. // Launches the platform app |app|. Creates appropriate launch data for the
  29. // |command_line| fields present. |app| and |context| must not be NULL. An empty
  30. // |command_line| means there is no launch data. If non-empty,
  31. // |current_directory| is used to expand any relative paths on the command line.
  32. // |source| is one of the enumerated values which trace how the app is launched.
  33. void LaunchPlatformAppWithCommandLine(content::BrowserContext* context,
  34. const extensions::Extension* app,
  35. const base::CommandLine& command_line,
  36. const base::FilePath& current_directory,
  37. extensions::AppLaunchSource source);
  38. // As above but includes |launch_id|, an id that can be passed to
  39. // an app when launched in order to support multiple shelf items per app.
  40. void LaunchPlatformAppWithCommandLineAndLaunchId(
  41. content::BrowserContext* context,
  42. const extensions::Extension* app,
  43. const std::string& launch_id,
  44. const base::CommandLine& command_line,
  45. const base::FilePath& current_directory,
  46. extensions::AppLaunchSource source);
  47. // Launches the platform app |app| by issuing an onLaunched event with the
  48. // contents of |file_path| available through the launch data.
  49. void LaunchPlatformAppWithPath(content::BrowserContext* context,
  50. const extensions::Extension* app,
  51. const base::FilePath& file_path);
  52. // Launches the platform app |app| by issuing an onLaunched event with the
  53. // contents of |file_paths| available through the launch data.
  54. void LaunchPlatformAppWithFilePaths(
  55. content::BrowserContext* context,
  56. const extensions::Extension* app,
  57. const std::vector<base::FilePath>& file_paths);
  58. // Launches the platform app |app| with the specific |action_data|.
  59. void LaunchPlatformAppWithAction(
  60. content::BrowserContext* context,
  61. const extensions::Extension* app,
  62. std::unique_ptr<extensions::api::app_runtime::ActionData> action_data);
  63. // Launches the platform app |app|. |source| tells us how the app is launched.
  64. void LaunchPlatformApp(content::BrowserContext* context,
  65. const extensions::Extension* app,
  66. extensions::AppLaunchSource source);
  67. // Launches the platform app |app| with |handler_id| and the contents of
  68. // |file_paths| available through the launch data. |handler_id| corresponds to
  69. // the id of the file_handlers item in the manifest that resulted in a match
  70. // that triggered this launch.
  71. void LaunchPlatformAppWithFileHandler(
  72. content::BrowserContext* context,
  73. const extensions::Extension* app,
  74. const std::string& handler_id,
  75. const std::vector<base::FilePath>& file_paths);
  76. // Launches the platform app |app| with |handler_id|, |url| and |referrer_url|
  77. // available through the launch data. |handler_id| corresponds to the id of the
  78. // file_handlers item in the manifest that resulted in a match that triggered
  79. // this launch.
  80. void LaunchPlatformAppWithUrl(content::BrowserContext* context,
  81. const extensions::Extension* app,
  82. const std::string& handler_id,
  83. const GURL& url,
  84. const GURL& referrer_url);
  85. void RestartPlatformApp(content::BrowserContext* context,
  86. const extensions::Extension* app);
  87. } // namespace apps
  88. #endif // APPS_LAUNCHER_H_