Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2568)

Unified Diff: chrome/common/extensions/background_info.h

Issue 12253022: Manifest handler for all keys background-related. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/api/themes/theme_handler.cc ('k') | chrome/common/extensions/background_info.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c3d59804d5541126fe45561c5feeba187b07e864
--- /dev/null
+++ b/chrome/common/extensions/background_info.h
@@ -0,0 +1,82 @@
+// 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 {
+
+class BackgroundInfo : public Extension::ManifestData {
+ public:
+ 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();
+ }
+
+ bool Parse(const Extension* extension, string16* error);
+
+ private:
+ bool LoadBackgroundScripts(const Extension* extension,
+ const std::string& key,
+ string16* error);
+ bool LoadBackgroundPage(const Extension* extension,
+ const std::string& key,
+ string16* error);
+ bool LoadBackgroundPage(const Extension* extension, string16* error);
+ bool LoadBackgroundPersistent(const Extension* extension, string16* error);
+ bool LoadAllowJSAccess(const Extension* extension, string16* error);
+
+ // Optional URL to a master page of which a single instance should be always
+ // loaded in the background.
+ GURL background_url_;
+
+ // 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;
+
+ private:
+ virtual const std::vector<std::string> Keys() const OVERRIDE;
+};
+
+} // namespace extensions
+
+#endif // CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_
« no previous file with comments | « chrome/common/extensions/api/themes/theme_handler.cc ('k') | chrome/common/extensions/background_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698