OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 EXTENSIONS_COMMON_MANIFEST_HANDLERS_OPTIONS_PAGE_INFO_H_ | |
6 #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_OPTIONS_PAGE_INFO_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/values.h" | |
12 #include "extensions/common/extension.h" | |
13 #include "extensions/common/manifest_handler.h" | |
14 #include "url/gurl.h" | |
15 | |
16 namespace base { | |
17 class Value; | |
18 } | |
19 | |
20 namespace extensions { | |
21 | |
22 class Extension; | |
Devlin
2014/09/04 21:16:04
If you include the .h, you don't need to forward-d
ericzeng
2014/09/04 22:22:07
Done.
| |
23 | |
24 // A class to provide options page configuration settings from the manifest. | |
25 class OptionsPageInfo : public Extension::ManifestData { | |
26 public: | |
27 OptionsPageInfo(const GURL& options_page, | |
28 bool chrome_styles, | |
29 bool open_in_tab); | |
30 virtual ~OptionsPageInfo(); | |
31 | |
32 // Returns the URL to the given extension's options page. This method supports | |
33 // both the "options_ui.page" field and the legacy "options_page" field. If | |
34 // both are present, it will return the value of "options_ui.page". | |
35 static const GURL& GetOptionsPage(const Extension* extension); | |
36 | |
37 // Returns true if the given extension has an options page. An extension has | |
38 // an options page if one or both of "options_ui.page" and "options_page" | |
39 // specify a valid options page. | |
40 static bool HasOptionsPage(const Extension* extension); | |
41 | |
42 // Returns whether the Chrome user agent stylesheet should be applied to the | |
43 // given extension's options page. | |
44 static bool ShouldUseChromeStyle(const Extension* extension); | |
45 | |
46 // Returns whether the given extension's options page should be opened in a | |
47 // new tab instead of an embedded popup. | |
48 static bool ShouldOpenInTab(const Extension* extension); | |
49 | |
50 static scoped_ptr<OptionsPageInfo> Create( | |
51 Extension* extension, | |
52 const base::Value* options_ui_value, | |
53 const std::string& options_page_string, | |
54 std::vector<InstallWarning>* install_warnings, | |
55 base::string16* error); | |
56 | |
57 private: | |
58 // The URL to the options page of this extension. We only store one options | |
59 // URL, either options_page or options_ui.page. options_ui.page is preferred | |
60 // if both are present. | |
61 GURL options_page_; | |
62 | |
63 bool chrome_styles_; | |
64 | |
65 bool open_in_tab_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(OptionsPageInfo); | |
68 }; | |
69 | |
70 // Parses the "options_ui" manifest key and the legacy "options_page" key. | |
71 class OptionsPageManifestHandler : public ManifestHandler { | |
72 public: | |
73 OptionsPageManifestHandler(); | |
74 virtual ~OptionsPageManifestHandler(); | |
75 | |
76 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE; | |
77 virtual bool Validate(const Extension* extension, | |
78 std::string* error, | |
79 std::vector<InstallWarning>* warnings) const OVERRIDE; | |
80 | |
81 private: | |
82 virtual const std::vector<std::string> Keys() const OVERRIDE; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(OptionsPageManifestHandler); | |
85 }; | |
86 | |
87 } // namespace extensions | |
88 | |
89 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_OPTIONS_PAGE_INFO_H_ | |
OLD | NEW |