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_UI_H_ |
| 6 #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_OPTIONS_UI_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 extensions { |
| 17 |
| 18 // A class to provide options page configuration settings from the manifest. |
| 19 class OptionsPageInfo : public Extension::ManifestData { |
| 20 public: |
| 21 OptionsPageInfo(const GURL& options_page, |
| 22 const GURL& options_ui_page, |
| 23 bool chrome_styles, |
| 24 bool open_in_tab); |
| 25 virtual ~OptionsPageInfo(); |
| 26 |
| 27 // Returns the URL to the given extension's options page. This method supports |
| 28 // both the "options_ui.page" field and the legacy "options_page" field. If |
| 29 // both are present, it will return the value of "options_ui.page". |
| 30 static const GURL& GetOptionsPage(const Extension* extension); |
| 31 |
| 32 // Returns true if the given extension has an options page, false otherwise. |
| 33 // An extension has an options page if one or both of "options_ui.page" and |
| 34 // "options_page" specify a valid options page. |
| 35 static bool HasOptionsPage(const Extension* extension); |
| 36 |
| 37 // Returns whether the Chrome user agent stylesheet should be applied to the |
| 38 // given extension's options page. |
| 39 static bool ShouldUseChromeStyle(const Extension* extension); |
| 40 |
| 41 // Returns whether the given extension's options page should be opened in a |
| 42 // new tab instead of an embedded popup. |
| 43 static bool ShouldOpenInTab(const Extension* extension); |
| 44 |
| 45 static scoped_ptr<OptionsPageInfo> Create( |
| 46 Extension* extension, |
| 47 const base::Value* options_ui_value, |
| 48 const std::string& options_page_string, |
| 49 std::vector<InstallWarning>* install_warnings, |
| 50 base::string16* error); |
| 51 |
| 52 private: |
| 53 bool LoadOptionsPage(const Extension* extension, base::string16* error); |
| 54 |
| 55 GURL options_page_; // The legacy options_page entry |
| 56 GURL options_ui_page_; // The options_ui.page entry |
| 57 bool chrome_styles_; |
| 58 bool open_in_tab_; |
| 59 }; |
| 60 |
| 61 // Parses the "options_ui" manifest key. |
| 62 class OptionsPageManifestHandler : public ManifestHandler { |
| 63 public: |
| 64 OptionsPageManifestHandler(); |
| 65 virtual ~OptionsPageManifestHandler(); |
| 66 |
| 67 virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE; |
| 68 virtual bool Validate(const Extension* extension, |
| 69 std::string* error, |
| 70 std::vector<InstallWarning>* warnings) const OVERRIDE; |
| 71 |
| 72 private: |
| 73 virtual const std::vector<std::string> Keys() const OVERRIDE; |
| 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(OptionsPageManifestHandler); |
| 76 }; |
| 77 |
| 78 } // namespace extensions |
| 79 |
| 80 #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_OPTIONS_UI_H_ |
OLD | NEW |