| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_URL_HANDLER_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_URL_HANDLER_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_URL_HANDLER_H_ | 6 #define CHROME_COMMON_EXTENSIONS_MANIFEST_URL_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| 11 #include "chrome/common/extensions/manifest_handler.h" | 11 #include "chrome/common/extensions/manifest_handler.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 // A structure to hold various URLs like devtools_page, homepage_url, etc | 15 // A structure to hold various URLs like devtools_page, homepage_url, etc |
| 16 // that may be specified in the manifest of an extension. | 16 // that may be specified in the manifest of an extension. |
| 17 struct ManifestURL : public Extension::ManifestData { | 17 struct ManifestURL : public Extension::ManifestData { |
| 18 GURL url_; | 18 GURL url_; |
| 19 | 19 |
| 20 // Returns the DevTools Page for this extension. | 20 // Returns the DevTools Page for this extension. |
| 21 static const GURL& GetDevToolsPage(const Extension* extension); | 21 static const GURL& GetDevToolsPage(const Extension* extension); |
| 22 | 22 |
| 23 // Returns the Homepage URL for this extension. | 23 // Returns the Homepage URL for this extension. |
| 24 // If homepage_url was not specified in the manifest, | 24 // If homepage_url was not specified in the manifest, |
| 25 // this returns the Google Gallery URL. For third-party extensions, | 25 // this returns the Google Gallery URL. For third-party extensions, |
| 26 // this returns a blank GURL. | 26 // this returns a blank GURL. |
| 27 static const GURL GetHomepageURL(const Extension* extension); | 27 static const GURL GetHomepageURL(const Extension* extension); |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 // A structure to hold the chrome URL overrides that may be specified |
| 31 // in the manifest of an extension. |
| 32 struct URLOverrides : public Extension::ManifestData { |
| 33 typedef std::map<const std::string, GURL> URLOverrideMap; |
| 34 |
| 35 // Define out of line constructor/destructor to please Clang. |
| 36 URLOverrides(); |
| 37 virtual ~URLOverrides(); |
| 38 |
| 39 static const URLOverrideMap& |
| 40 GetChromeURLOverrides(const Extension* extension); |
| 41 |
| 42 // A map of chrome:// hostnames (newtab, downloads, etc.) to Extension URLs |
| 43 // which override the handling of those URLs. (see ExtensionOverrideUI). |
| 44 URLOverrideMap chrome_url_overrides_; |
| 45 }; |
| 46 |
| 30 // Parses the "devtools_page" manifest key. | 47 // Parses the "devtools_page" manifest key. |
| 31 class DevToolsPageHandler : public ManifestHandler { | 48 class DevToolsPageHandler : public ManifestHandler { |
| 32 public: | 49 public: |
| 33 DevToolsPageHandler(); | 50 DevToolsPageHandler(); |
| 34 virtual ~DevToolsPageHandler(); | 51 virtual ~DevToolsPageHandler(); |
| 35 | 52 |
| 36 virtual bool Parse(const base::Value* value, | 53 virtual bool Parse(const base::Value* value, |
| 37 Extension* extension, | 54 Extension* extension, |
| 38 string16* error) OVERRIDE; | 55 string16* error) OVERRIDE; |
| 39 }; | 56 }; |
| 40 | 57 |
| 41 // Parses the "homepage_url" manifest key. | 58 // Parses the "homepage_url" manifest key. |
| 42 class HomepageURLHandler : public ManifestHandler { | 59 class HomepageURLHandler : public ManifestHandler { |
| 43 public: | 60 public: |
| 44 HomepageURLHandler(); | 61 HomepageURLHandler(); |
| 45 virtual ~HomepageURLHandler(); | 62 virtual ~HomepageURLHandler(); |
| 46 | 63 |
| 47 virtual bool Parse(const base::Value* value, | 64 virtual bool Parse(const base::Value* value, |
| 48 Extension* extension, | 65 Extension* extension, |
| 49 string16* error) OVERRIDE; | 66 string16* error) OVERRIDE; |
| 50 }; | 67 }; |
| 51 | 68 |
| 69 // Parses the "chrome_url_overrides" manifest key. |
| 70 class URLOverridesHandler : public ManifestHandler { |
| 71 public: |
| 72 URLOverridesHandler(); |
| 73 virtual ~URLOverridesHandler(); |
| 74 |
| 75 virtual bool Parse(const base::Value* value, |
| 76 Extension* extension, |
| 77 string16* error) OVERRIDE; |
| 78 }; |
| 79 |
| 52 } // namespace extensions | 80 } // namespace extensions |
| 53 | 81 |
| 54 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_URL_HANDLER_H_ | 82 #endif // CHROME_COMMON_EXTENSIONS_MANIFEST_URL_HANDLER_H_ |
| OLD | NEW |