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