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 EXTENSIONS_COMMON_MANIFEST_URL_HANDLERS_H_
6 #define EXTENSIONS_COMMON_MANIFEST_URL_HANDLERS_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 value of a URL key for an extension, or an empty URL if unset.
25 static const GURL& Get(const Extension* extension, const std::string& key);
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 true if the extension specified a valid home page url in the
35 static bool SpecifiedHomepageURL(const Extension* extension);
37 // Returns the Update URL for this extension.
38 static const GURL& GetUpdateURL(const Extension* extension);
40 // Returns true if this extension's update URL is the extension gallery.
41 static bool UpdatesFromGallery(const Extension* extension);
42 static bool UpdatesFromGallery(const base::DictionaryValue* manifest);
44 // Returns the About Page for this extension.
45 static const GURL& GetAboutPage(const Extension* extension);
47 // Returns the webstore page URL for this extension.
48 static const GURL GetDetailsURL(const Extension* extension);
51 // Parses the "homepage_url" manifest key.
52 class HomepageURLHandler : public ManifestHandler {
55 ~HomepageURLHandler() override;
57 bool Parse(Extension* extension, base::string16* error) override;
60 const std::vector<std::string> Keys() const override;
62 DISALLOW_COPY_AND_ASSIGN(HomepageURLHandler);
65 // Parses the "update_url" manifest key.
66 class UpdateURLHandler : public ManifestHandler {
69 ~UpdateURLHandler() override;
71 bool Parse(Extension* extension, base::string16* error) override;
74 const std::vector<std::string> Keys() const override;
76 DISALLOW_COPY_AND_ASSIGN(UpdateURLHandler);
79 // Parses the "about_page" manifest key.
80 // TODO(sashab): Make this and any other similar handlers extend from the same
81 // abstract class, URLManifestHandler, which has pure virtual methods for
82 // detecting the required URL type (relative or absolute) and abstracts the
83 // URL parsing logic away.
84 class AboutPageHandler : public ManifestHandler {
87 ~AboutPageHandler() override;
89 bool Parse(Extension* extension, base::string16* error) override;
90 bool Validate(const Extension* extension,
92 std::vector<InstallWarning>* warnings) const override;
95 const std::vector<std::string> Keys() const override;
97 DISALLOW_COPY_AND_ASSIGN(AboutPageHandler);
100 } // namespace extensions
102 #endif // EXTENSIONS_COMMON_MANIFEST_URL_HANDLERS_H_