Enable Enterprise enrollment on desktop builds.
[chromium-blink-merge.git] / chrome / common / extensions / manifest_url_handler.h
blob057589b3cff35ba3ebbdd82f2f5ac5a01c6fb57a
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
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_URL_HANDLER_H_
6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_URL_HANDLER_H_
8 #include <string>
10 #include "extensions/common/extension.h"
11 #include "extensions/common/manifest_handler.h"
13 namespace base {
14 class DictionaryValue;
17 namespace extensions {
19 // A structure to hold various URLs like devtools_page, homepage_url, etc
20 // that may be specified in the manifest of an extension.
21 struct ManifestURL : public Extension::ManifestData {
22 GURL url_;
24 // Returns the DevTools Page for this extension.
25 static const GURL& GetDevToolsPage(const Extension* extension);
27 // Returns the Homepage URL for this extension.
28 // If homepage_url was not specified in the manifest,
29 // this returns the Google Gallery URL. For third-party extensions,
30 // this returns a blank GURL.
31 static const GURL GetHomepageURL(const Extension* extension);
33 // Returns the Update URL for this extension.
34 static const GURL& GetUpdateURL(const Extension* extension);
36 // Returns true if this extension's update URL is the extension gallery.
37 static bool UpdatesFromGallery(const Extension* extension);
38 static bool UpdatesFromGallery(const base::DictionaryValue* manifest);
40 // Returns the Options Page for this extension.
41 static const GURL& GetOptionsPage(const Extension* extension);
43 // Returns the webstore page URL for this extension.
44 static const GURL GetDetailsURL(const Extension* extension);
47 // A structure to hold the chrome URL overrides that may be specified
48 // in the manifest of an extension.
49 struct URLOverrides : public Extension::ManifestData {
50 typedef std::map<const std::string, GURL> URLOverrideMap;
52 // Define out of line constructor/destructor to please Clang.
53 URLOverrides();
54 virtual ~URLOverrides();
56 static const URLOverrideMap&
57 GetChromeURLOverrides(const Extension* extension);
59 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs
60 // which override the handling of those URLs. (see ExtensionOverrideUI).
61 URLOverrideMap chrome_url_overrides_;
64 // Parses the "devtools_page" manifest key.
65 class DevToolsPageHandler : public ManifestHandler {
66 public:
67 DevToolsPageHandler();
68 virtual ~DevToolsPageHandler();
70 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE;
72 private:
73 virtual const std::vector<std::string> Keys() const OVERRIDE;
75 DISALLOW_COPY_AND_ASSIGN(DevToolsPageHandler);
78 // Parses the "homepage_url" manifest key.
79 class HomepageURLHandler : public ManifestHandler {
80 public:
81 HomepageURLHandler();
82 virtual ~HomepageURLHandler();
84 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE;
86 private:
87 virtual const std::vector<std::string> Keys() const OVERRIDE;
89 DISALLOW_COPY_AND_ASSIGN(HomepageURLHandler);
92 // Parses the "update_url" manifest key.
93 class UpdateURLHandler : public ManifestHandler {
94 public:
95 UpdateURLHandler();
96 virtual ~UpdateURLHandler();
98 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE;
100 private:
101 virtual const std::vector<std::string> Keys() const OVERRIDE;
103 DISALLOW_COPY_AND_ASSIGN(UpdateURLHandler);
106 // Parses the "options_page" manifest key.
107 class OptionsPageHandler : public ManifestHandler {
108 public:
109 OptionsPageHandler();
110 virtual ~OptionsPageHandler();
112 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE;
113 virtual bool Validate(const Extension* extension,
114 std::string* error,
115 std::vector<InstallWarning>* warnings) const OVERRIDE;
117 private:
118 virtual const std::vector<std::string> Keys() const OVERRIDE;
120 DISALLOW_COPY_AND_ASSIGN(OptionsPageHandler);
123 // Parses the "chrome_url_overrides" manifest key.
124 class URLOverridesHandler : public ManifestHandler {
125 public:
126 URLOverridesHandler();
127 virtual ~URLOverridesHandler();
129 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE;
131 private:
132 virtual const std::vector<std::string> Keys() const OVERRIDE;
134 DISALLOW_COPY_AND_ASSIGN(URLOverridesHandler);
137 } // namespace extensions
139 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_URL_HANDLER_H_