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.
5 #ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_OPTIONS_PAGE_INFO_H_
6 #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_OPTIONS_PAGE_INFO_H_
11 #include "base/values.h"
12 #include "extensions/common/extension.h"
13 #include "extensions/common/manifest_handler.h"
20 namespace extensions
{
22 // A class to provide options page configuration settings from the manifest.
23 class OptionsPageInfo
: public Extension::ManifestData
{
25 OptionsPageInfo(const GURL
& options_page
,
28 ~OptionsPageInfo() override
;
30 // Returns the URL to the given extension's options page. This method supports
31 // both the "options_ui.page" field and the legacy "options_page" field. If
32 // both are present, it will return the value of "options_ui.page".
33 static const GURL
& GetOptionsPage(const Extension
* extension
);
35 // Returns true if the given extension has an options page. An extension has
36 // an options page if one or both of "options_ui.page" and "options_page"
37 // specify a valid options page.
38 static bool HasOptionsPage(const Extension
* extension
);
40 // Returns whether the Chrome user agent stylesheet should be applied to the
41 // given extension's options page.
42 static bool ShouldUseChromeStyle(const Extension
* extension
);
44 // Returns whether the given extension's options page should be opened in a
45 // new tab instead of an embedded popup.
46 static bool ShouldOpenInTab(const Extension
* extension
);
48 static scoped_ptr
<OptionsPageInfo
> Create(
50 const base::Value
* options_ui_value
,
51 const std::string
& options_page_string
,
52 std::vector
<InstallWarning
>* install_warnings
,
53 base::string16
* error
);
56 // The URL to the options page of this extension. We only store one options
57 // URL, either options_page or options_ui.page. options_ui.page is preferred
58 // if both are present.
65 DISALLOW_COPY_AND_ASSIGN(OptionsPageInfo
);
68 // Parses the "options_ui" manifest key and the legacy "options_page" key.
69 class OptionsPageManifestHandler
: public ManifestHandler
{
71 OptionsPageManifestHandler();
72 ~OptionsPageManifestHandler() override
;
74 bool Parse(Extension
* extension
, base::string16
* error
) override
;
75 bool Validate(const Extension
* extension
,
77 std::vector
<InstallWarning
>* warnings
) const override
;
80 const std::vector
<std::string
> Keys() const override
;
82 DISALLOW_COPY_AND_ASSIGN(OptionsPageManifestHandler
);
85 } // namespace extensions
87 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_OPTIONS_PAGE_INFO_H_