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