[email protected] | 44e329a | 2012-07-14 01:13:06 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | ea0f18b | 2009-07-27 22:16:11 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 8f9d4eb | 2011-02-05 01:39:10 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ |
[email protected] | 811bfe37 | 2009-07-01 08:46:25 | [diff] [blame] | 7 | |
[email protected] | b2725756 | 2009-11-16 23:28:26 | [diff] [blame] | 8 | #include <string> |
| 9 | |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 10 | #include "base/memory/scoped_ptr.h" |
[email protected] | ee2ed42c | 2011-04-28 22:19:14 | [diff] [blame] | 11 | #include "chrome/browser/favicon/favicon_service.h" |
[email protected] | 636ee4328 | 2013-01-12 15:58:00 | [diff] [blame] | 12 | #include "chrome/common/extensions/manifest_url_handler.h" |
[email protected] | e14c95912 | 2012-01-13 16:58:25 | [diff] [blame] | 13 | #include "content/public/browser/web_ui_controller.h" |
[email protected] | 811bfe37 | 2009-07-01 08:46:25 | [diff] [blame] | 14 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 15 | class Profile; |
| 16 | |
[email protected] | 44e329a | 2012-07-14 01:13:06 | [diff] [blame] | 17 | namespace content { |
[email protected] | 7048264 | 2012-12-19 22:25:24 | [diff] [blame] | 18 | class BrowserContext; |
[email protected] | 44e329a | 2012-07-14 01:13:06 | [diff] [blame] | 19 | class WebContents; |
| 20 | } |
| 21 | |
[email protected] | 7048264 | 2012-12-19 22:25:24 | [diff] [blame] | 22 | namespace extensions { |
| 23 | class BookmarkManagerPrivateEventRouter; |
| 24 | } |
| 25 | |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 26 | namespace user_prefs { |
[email protected] | c753f14 | 2013-02-10 13:14:04 | [diff] [blame] | 27 | class PrefRegistrySyncable; |
[email protected] | 443e931 | 2013-05-06 06:17:34 | [diff] [blame] | 28 | } |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 29 | |
[email protected] | d21cdb1 | 2011-02-10 01:22:32 | [diff] [blame] | 30 | // This class implements WebUI for extensions and allows extensions to put UI in |
[email protected] | bad77bf | 2010-08-21 21:21:22 | [diff] [blame] | 31 | // the main tab contents area. For example, each extension can specify an |
| 32 | // "options_page", and that page is displayed in the tab contents area and is |
| 33 | // hosted by this class. |
[email protected] | c63cedf2 | 2012-01-17 18:42:22 | [diff] [blame] | 34 | class ExtensionWebUI : public content::WebUIController { |
[email protected] | 811bfe37 | 2009-07-01 08:46:25 | [diff] [blame] | 35 | public: |
[email protected] | e219474 | 2010-08-12 05:54:34 | [diff] [blame] | 36 | static const char kExtensionURLOverrides[]; |
[email protected] | c5b8ab4 | 2010-04-14 22:06:50 | [diff] [blame] | 37 | |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 38 | ExtensionWebUI(content::WebUI* web_ui, const GURL& url); |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 39 | |
[email protected] | 8f9d4eb | 2011-02-05 01:39:10 | [diff] [blame] | 40 | virtual ~ExtensionWebUI(); |
[email protected] | 8e38341 | 2010-10-19 16:57:03 | [diff] [blame] | 41 | |
[email protected] | 7048264 | 2012-12-19 22:25:24 | [diff] [blame] | 42 | virtual extensions::BookmarkManagerPrivateEventRouter* |
| 43 | bookmark_manager_private_event_router(); |
[email protected] | ced90ae1 | 2010-02-20 02:06:16 | [diff] [blame] | 44 | |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 45 | // BrowserURLHandler |
[email protected] | 3d7474ff | 2011-07-27 17:47:37 | [diff] [blame] | 46 | static bool HandleChromeURLOverride(GURL* url, |
| 47 | content::BrowserContext* browser_context); |
| 48 | static bool HandleChromeURLOverrideReverse( |
| 49 | GURL* url, content::BrowserContext* browser_context); |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 50 | |
| 51 | // Register and unregister a dictionary of one or more overrides. |
| 52 | // Page names are the keys, and chrome-extension: URLs are the values. |
| 53 | // (e.g. { "newtab": "chrome-extension://<id>/my_new_tab.html" } |
| 54 | static void RegisterChromeURLOverrides(Profile* profile, |
[email protected] | 636ee4328 | 2013-01-12 15:58:00 | [diff] [blame] | 55 | const extensions::URLOverrides::URLOverrideMap& overrides); |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 56 | static void UnregisterChromeURLOverrides(Profile* profile, |
[email protected] | 636ee4328 | 2013-01-12 15:58:00 | [diff] [blame] | 57 | const extensions::URLOverrides::URLOverrideMap& overrides); |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 58 | static void UnregisterChromeURLOverride(const std::string& page, |
| 59 | Profile* profile, |
[email protected] | 5d30f92bf | 2012-08-03 08:43:37 | [diff] [blame] | 60 | const base::Value* override); |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 61 | |
| 62 | // Called from BrowserPrefs |
[email protected] | 37ca3fe0 | 2013-07-05 15:32:44 | [diff] [blame^] | 63 | static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 64 | |
[email protected] | 4b91f1f | 2010-07-14 20:01:04 | [diff] [blame] | 65 | // Get the favicon for the extension by getting an icon from the manifest. |
[email protected] | 0ea3db5 | 2012-12-07 01:32:01 | [diff] [blame] | 66 | // Note. |callback| is always run asynchronously. |
| 67 | static void GetFaviconForURL( |
| 68 | Profile* profile, |
| 69 | const GURL& page_url, |
[email protected] | a55e85b | 2012-12-12 02:31:58 | [diff] [blame] | 70 | const FaviconService::FaviconResultsCallback& callback); |
[email protected] | 59194896 | 2010-03-12 19:37:52 | [diff] [blame] | 71 | |
[email protected] | 811bfe37 | 2009-07-01 08:46:25 | [diff] [blame] | 72 | private: |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 73 | // Unregister the specified override, and if it's the currently active one, |
| 74 | // ensure that something takes its place. |
| 75 | static void UnregisterAndReplaceOverride(const std::string& page, |
| 76 | Profile* profile, |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 77 | base::ListValue* list, |
[email protected] | 5d30f92bf | 2012-08-03 08:43:37 | [diff] [blame] | 78 | const base::Value* override); |
[email protected] | 86c008e8 | 2009-08-28 20:26:05 | [diff] [blame] | 79 | |
[email protected] | bad77bf | 2010-08-21 21:21:22 | [diff] [blame] | 80 | // TODO(aa): This seems out of place. Why is it not with the event routers for |
| 81 | // the other extension APIs? |
[email protected] | 7048264 | 2012-12-19 22:25:24 | [diff] [blame] | 82 | scoped_ptr<extensions::BookmarkManagerPrivateEventRouter> |
| 83 | bookmark_manager_private_event_router_; |
[email protected] | 3efe14a6 | 2010-10-25 22:18:38 | [diff] [blame] | 84 | |
[email protected] | d21cdb1 | 2011-02-10 01:22:32 | [diff] [blame] | 85 | // The URL this WebUI was created for. |
[email protected] | 3efe14a6 | 2010-10-25 22:18:38 | [diff] [blame] | 86 | GURL url_; |
[email protected] | 811bfe37 | 2009-07-01 08:46:25 | [diff] [blame] | 87 | }; |
| 88 | |
[email protected] | 8f9d4eb | 2011-02-05 01:39:10 | [diff] [blame] | 89 | #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ |