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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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.
4
5 #ifndef CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_
6 #define CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/values.h"
12 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/extensions/manifest_handler.h"
14 #include "googleurl/src/gurl.h"
15
16 namespace extensions {
17
18 class BackgroundInfo : public Extension::ManifestData {
19 public:
20 BackgroundInfo();
21 virtual ~BackgroundInfo();
22
23 static GURL GetBackgroundURL(const Extension* extension);
24 static const std::vector<std::string>& GetBackgroundScripts(
25 const Extension* extension);
26 static bool HasBackgroundPage(const Extension* extension);
27 static bool HasPersistentBackgroundPage(const Extension* extension);
28 static bool HasLazyBackgroundPage(const Extension* extension);
29 static bool AllowJSAccess(const Extension* extension);
30
31 bool has_background_page() const {
32 return background_url_.is_valid() || !background_scripts_.empty();
33 }
34
35 bool Parse(const Extension* extension, string16* error);
36
37 private:
38 bool LoadBackgroundScripts(const Extension* extension,
39 const std::string& key,
40 string16* error);
41 bool LoadBackgroundPage(const Extension* extension,
42 const std::string& key,
43 string16* error);
44 bool LoadBackgroundPage(const Extension* extension, string16* error);
45 bool LoadBackgroundPersistent(const Extension* extension, string16* error);
46 bool LoadAllowJSAccess(const Extension* extension, string16* error);
47
48 // Optional URL to a master page of which a single instance should be always
49 // loaded in the background.
50 GURL background_url_;
51
52 // Optional list of scripts to use to generate a background page. If this is
53 // present, background_url_ will be empty and generated by GetBackgroundURL().
54 std::vector<std::string> background_scripts_;
55
56 // True if the background page should stay loaded forever; false if it should
57 // load on-demand (when it needs to handle an event). Defaults to true.
58 bool is_persistent_;
59
60 // True if the background page can be scripted by pages of the app or
61 // extension, in which case all such pages must run in the same process.
62 // False if such pages are not permitted to script the background page,
63 // allowing them to run in different processes.
64 // Defaults to true.
65 bool allow_js_access_;
66 };
67
68 // Parses all background/event page-related keys in the manifest.
69 class BackgroundManifestHandler : public ManifestHandler {
70 public:
71 BackgroundManifestHandler();
72 virtual ~BackgroundManifestHandler();
73
74 virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
75
76 private:
77 virtual const std::vector<std::string> Keys() const OVERRIDE;
78 };
79
80 } // namespace extensions
81
82 #endif // CHROME_COMMON_EXTENSIONS_BACKGROUND_INFO_H_
OLDNEW
« 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