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_
10 #include "extensions/common/extension.h"
11 #include "extensions/common/manifest_handler.h"
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
{
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.
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
{
67 DevToolsPageHandler();
68 virtual ~DevToolsPageHandler();
70 virtual bool Parse(Extension
* extension
, base::string16
* error
) OVERRIDE
;
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
{
82 virtual ~HomepageURLHandler();
84 virtual bool Parse(Extension
* extension
, base::string16
* error
) OVERRIDE
;
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
{
96 virtual ~UpdateURLHandler();
98 virtual bool Parse(Extension
* extension
, base::string16
* error
) OVERRIDE
;
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
{
109 OptionsPageHandler();
110 virtual ~OptionsPageHandler();
112 virtual bool Parse(Extension
* extension
, base::string16
* error
) OVERRIDE
;
113 virtual bool Validate(const Extension
* extension
,
115 std::vector
<InstallWarning
>* warnings
) const OVERRIDE
;
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
{
126 URLOverridesHandler();
127 virtual ~URLOverridesHandler();
129 virtual bool Parse(Extension
* extension
, base::string16
* error
) OVERRIDE
;
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_