Chromium Code Reviews| Index: chrome/common/extensions/background_info.h |
| diff --git a/chrome/common/extensions/background_info.h b/chrome/common/extensions/background_info.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e201aab8bb7f46d2f674ca49e4e3ce76915b3584 |
| --- /dev/null |
| +++ b/chrome/common/extensions/background_info.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_ |
| +#define CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/values.h" |
| +#include "chrome/common/extensions/extension.h" |
| +#include "chrome/common/extensions/manifest_handler.h" |
| +#include "googleurl/src/gurl.h" |
| + |
| +namespace extensions { |
| + |
| +struct BackgroundInfo : public Extension::ManifestData { |
|
Matt Perry
2013/02/15 20:15:02
Make this a class.
Yoyo Zhou
2013/02/16 00:54:04
Done.
|
| + BackgroundInfo(); |
| + virtual ~BackgroundInfo(); |
| + |
| + static GURL GetBackgroundURL(const Extension* extension); |
| + static const std::vector<std::string>& GetBackgroundScripts( |
| + const Extension* extension); |
| + static bool HasBackgroundPage(const Extension* extension); |
| + static bool HasPersistentBackgroundPage(const Extension* extension); |
| + static bool HasLazyBackgroundPage(const Extension* extension); |
| + static bool AllowJSAccess(const Extension* extension); |
| + |
| + bool has_background_page() const { |
| + return background_url.is_valid() || !background_scripts.empty(); |
| + } |
| + |
| + // Optional URL to a master page of which a single instance should be always |
| + // loaded in the background. |
| + GURL background_url; |
|
Matt Perry
2013/02/15 20:15:02
These should all be private. You only access them
Yoyo Zhou
2013/02/16 00:54:04
Done; also needed to make the load functions membe
Matt Perry
2013/02/16 01:16:52
Aw, didn't see that originally. Another thing you
|
| + |
| + // Optional list of scripts to use to generate a background page. If this is |
| + // present, background_url_ will be empty and generated by GetBackgroundURL(). |
| + std::vector<std::string> background_scripts; |
| + |
| + // True if the background page should stay loaded forever; false if it should |
| + // load on-demand (when it needs to handle an event). Defaults to true. |
| + bool is_persistent; |
| + |
| + // True if the background page can be scripted by pages of the app or |
| + // extension, in which case all such pages must run in the same process. |
| + // False if such pages are not permitted to script the background page, |
| + // allowing them to run in different processes. |
| + // Defaults to true. |
| + bool allow_js_access; |
| +}; |
| + |
| +// Parses all background/event page-related keys in the manifest. |
| +class BackgroundManifestHandler : public ManifestHandler { |
| + public: |
| + BackgroundManifestHandler(); |
| + virtual ~BackgroundManifestHandler(); |
| + |
| + virtual bool Parse(Extension* extension, |
| + string16* error) OVERRIDE; |
| + |
| + // For convenience, returns the list of keys that this parses. |
| + static const std::vector<std::string> keys(); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_ |