Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / extensions / manifest_handlers / app_launch_info.h
blob5c833cb9abcd99228008f4614cfd328cc2de59b0
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.
5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_APP_LAUNCH_INFO_H_
6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_APP_LAUNCH_INFO_H_
8 #include <string>
9 #include <vector>
11 #include "chrome/common/extensions/extension_constants.h"
12 #include "extensions/common/constants.h"
13 #include "extensions/common/extension.h"
14 #include "extensions/common/manifest.h"
15 #include "extensions/common/manifest_handler.h"
16 #include "url/gurl.h"
18 namespace extensions {
20 // Container that holds the parsed app launch data.
21 class AppLaunchInfo : public Extension::ManifestData {
22 public:
23 AppLaunchInfo();
24 ~AppLaunchInfo() override;
26 // Get the local path inside the extension to use with the launcher.
27 static const std::string& GetLaunchLocalPath(const Extension* extension);
29 // Get the absolute web url to use with the launcher.
30 static const GURL& GetLaunchWebURL(const Extension* extension);
32 // The window type that an app's manifest specifies to launch into.
33 // This is not always the window type an app will open into, because
34 // users can override the way each app launches. See
35 // ExtensionPrefs::GetLaunchContainer(), which looks at a per-app pref
36 // to decide what container an app will launch in.
37 static LaunchContainer GetLaunchContainer(
38 const Extension* extension);
40 // The default size of the container when launching. Only respected for
41 // containers like panels and windows.
42 static int GetLaunchWidth(const Extension* extension);
43 static int GetLaunchHeight(const Extension* extension);
45 // Get the fully resolved absolute launch URL.
46 static GURL GetFullLaunchURL(const Extension* extension);
48 bool Parse(Extension* extension, base::string16* error);
50 private:
51 bool LoadLaunchURL(Extension* extension, base::string16* error);
52 bool LoadLaunchContainer(Extension* extension, base::string16* error);
53 void OverrideLaunchURL(Extension* extension, GURL override_url);
55 std::string launch_local_path_;
57 GURL launch_web_url_;
59 LaunchContainer launch_container_;
61 int launch_width_;
62 int launch_height_;
64 DISALLOW_COPY_AND_ASSIGN(AppLaunchInfo);
67 // Parses all app launch related keys in the manifest.
68 class AppLaunchManifestHandler : public ManifestHandler {
69 public:
70 AppLaunchManifestHandler();
71 ~AppLaunchManifestHandler() override;
73 bool Parse(Extension* extension, base::string16* error) override;
74 bool AlwaysParseForType(Manifest::Type type) const override;
76 private:
77 const std::vector<std::string> Keys() const override;
79 DISALLOW_COPY_AND_ASSIGN(AppLaunchManifestHandler);
82 } // namespace extensions
84 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_APP_LAUNCH_INFO_H_