blob: 2d32f04669ed5794037cb7f20a1a9cf7b00213b4 [file] [log] [blame]
[email protected]44e329a2012-07-14 01:13:061// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ea0f18b2009-07-27 22:16:112// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]8f9d4eb2011-02-05 01:39:105#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
6#define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
[email protected]811bfe372009-07-01 08:46:257
[email protected]b27257562009-11-16 23:28:268#include <string>
9
[email protected]3b63f8f42011-03-28 01:54:1510#include "base/memory/scoped_ptr.h"
rockot3b99b8e2014-10-14 21:54:3511#include "chrome/common/extensions/chrome_manifest_url_handlers.h"
[email protected]8823c502014-05-22 03:11:1612#include "components/favicon_base/favicon_callback.h"
[email protected]e14c959122012-01-13 16:58:2513#include "content/public/browser/web_ui_controller.h"
[email protected]811bfe372009-07-01 08:46:2514
[email protected]443e9312013-05-06 06:17:3415class Profile;
16
[email protected]44e329a2012-07-14 01:13:0617namespace content {
[email protected]70482642012-12-19 22:25:2418class BrowserContext;
[email protected]44e329a2012-07-14 01:13:0619class WebContents;
20}
21
[email protected]70482642012-12-19 22:25:2422namespace extensions {
[email protected]c59ebe12014-03-12 21:43:2723class BookmarkManagerPrivateDragEventRouter;
[email protected]70482642012-12-19 22:25:2424}
25
[email protected]443e9312013-05-06 06:17:3426namespace user_prefs {
[email protected]c753f142013-02-10 13:14:0427class PrefRegistrySyncable;
[email protected]443e9312013-05-06 06:17:3428}
[email protected]86c008e82009-08-28 20:26:0529
[email protected]d21cdb12011-02-10 01:22:3230// This class implements WebUI for extensions and allows extensions to put UI in
[email protected]bad77bf2010-08-21 21:21:2231// 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]c63cedf22012-01-17 18:42:2234class ExtensionWebUI : public content::WebUIController {
[email protected]811bfe372009-07-01 08:46:2535 public:
[email protected]e2194742010-08-12 05:54:3436 static const char kExtensionURLOverrides[];
[email protected]c5b8ab42010-04-14 22:06:5037
[email protected]01ec4ec2012-01-18 04:13:4738 ExtensionWebUI(content::WebUI* web_ui, const GURL& url);
[email protected]86c008e82009-08-28 20:26:0539
dchengae36a4a2014-10-21 12:36:3640 ~ExtensionWebUI() override;
[email protected]8e383412010-10-19 16:57:0341
[email protected]c59ebe12014-03-12 21:43:2742 virtual extensions::BookmarkManagerPrivateDragEventRouter*
43 bookmark_manager_private_drag_event_router();
[email protected]ced90ae12010-02-20 02:06:1644
[email protected]86c008e82009-08-28 20:26:0545 // BrowserURLHandler
[email protected]3d7474ff2011-07-27 17:47:3746 static bool HandleChromeURLOverride(GURL* url,
47 content::BrowserContext* browser_context);
48 static bool HandleChromeURLOverrideReverse(
49 GURL* url, content::BrowserContext* browser_context);
[email protected]86c008e82009-08-28 20:26:0550
rdevlin.cronin5fafa5a2015-12-30 03:42:0251 // Initialize the Chrome URL overrides. This must happen *before* any further
52 // calls for URL overrides!
53 static void InitializeChromeURLOverrides(Profile* profile);
54
55 // Validate the Chrome URL overrides, ensuring that each is valid and points
56 // to an existing extension. To be called once all extensions are loaded.
57 static void ValidateChromeURLOverrides(Profile* profile);
58
59 // Add new Chrome URL overrides. If an entry exists, it is marked as active.
60 // If one doesn't exist, it is added at the beginning of the list of
61 // overrides (meaning it has priority).
62 static void RegisterOrActivateChromeURLOverrides(
63 Profile* profile,
[email protected]636ee43282013-01-12 15:58:0064 const extensions::URLOverrides::URLOverrideMap& overrides);
rdevlin.cronin5fafa5a2015-12-30 03:42:0265
66 // Deactivate overrides without removing them from the list or modifying their
67 // positions in the list.
68 static void DeactivateChromeURLOverrides(
69 Profile* profile,
[email protected]636ee43282013-01-12 15:58:0070 const extensions::URLOverrides::URLOverrideMap& overrides);
rdevlin.cronin5fafa5a2015-12-30 03:42:0271
72 // Completely unregister overrides, removing them from the list.
73 static void UnregisterChromeURLOverrides(
74 Profile* profile,
75 const extensions::URLOverrides::URLOverrideMap& overrides);
[email protected]86c008e82009-08-28 20:26:0576
77 // Called from BrowserPrefs
[email protected]37ca3fe02013-07-05 15:32:4478 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
[email protected]86c008e82009-08-28 20:26:0579
[email protected]4b91f1f2010-07-14 20:01:0480 // Get the favicon for the extension by getting an icon from the manifest.
[email protected]0ea3db52012-12-07 01:32:0181 // Note. |callback| is always run asynchronously.
82 static void GetFaviconForURL(
83 Profile* profile,
84 const GURL& page_url,
[email protected]8823c502014-05-22 03:11:1685 const favicon_base::FaviconResultsCallback& callback);
[email protected]591948962010-03-12 19:37:5286
[email protected]811bfe372009-07-01 08:46:2587 private:
[email protected]86c008e82009-08-28 20:26:0588 // Unregister the specified override, and if it's the currently active one,
89 // ensure that something takes its place.
90 static void UnregisterAndReplaceOverride(const std::string& page,
91 Profile* profile,
[email protected]f3a1c642011-07-12 19:15:0392 base::ListValue* list,
[email protected]5d30f92bf2012-08-03 08:43:3793 const base::Value* override);
[email protected]86c008e82009-08-28 20:26:0594
[email protected]bad77bf2010-08-21 21:21:2295 // TODO(aa): This seems out of place. Why is it not with the event routers for
96 // the other extension APIs?
[email protected]c59ebe12014-03-12 21:43:2797 scoped_ptr<extensions::BookmarkManagerPrivateDragEventRouter>
98 bookmark_manager_private_drag_event_router_;
[email protected]3efe14a62010-10-25 22:18:3899
[email protected]d21cdb12011-02-10 01:22:32100 // The URL this WebUI was created for.
[email protected]3efe14a62010-10-25 22:18:38101 GURL url_;
[email protected]811bfe372009-07-01 08:46:25102};
103
[email protected]8f9d4eb2011-02-05 01:39:10104#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_