Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / extensions / extension_web_ui.h
blob0d44b0e271242ab1a2b2b807d0edd1d475707ca3
1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "chrome/common/extensions/chrome_manifest_url_handlers.h"
12 #include "components/favicon_base/favicon_callback.h"
13 #include "content/public/browser/web_ui_controller.h"
15 class Profile;
17 namespace content {
18 class BrowserContext;
19 class WebContents;
22 namespace extensions {
23 class BookmarkManagerPrivateDragEventRouter;
26 namespace user_prefs {
27 class PrefRegistrySyncable;
30 // This class implements WebUI for extensions and allows extensions to put UI in
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.
34 class ExtensionWebUI : public content::WebUIController {
35 public:
36 static const char kExtensionURLOverrides[];
38 ExtensionWebUI(content::WebUI* web_ui, const GURL& url);
40 ~ExtensionWebUI() override;
42 virtual extensions::BookmarkManagerPrivateDragEventRouter*
43 bookmark_manager_private_drag_event_router();
45 // BrowserURLHandler
46 static bool HandleChromeURLOverride(GURL* url,
47 content::BrowserContext* browser_context);
48 static bool HandleChromeURLOverrideReverse(
49 GURL* url, content::BrowserContext* browser_context);
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,
55 const extensions::URLOverrides::URLOverrideMap& overrides);
56 static void UnregisterChromeURLOverrides(Profile* profile,
57 const extensions::URLOverrides::URLOverrideMap& overrides);
58 static void UnregisterChromeURLOverride(const std::string& page,
59 Profile* profile,
60 const base::Value* override);
62 // Called from BrowserPrefs
63 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
65 // Get the favicon for the extension by getting an icon from the manifest.
66 // Note. |callback| is always run asynchronously.
67 static void GetFaviconForURL(
68 Profile* profile,
69 const GURL& page_url,
70 const favicon_base::FaviconResultsCallback& callback);
72 private:
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,
77 base::ListValue* list,
78 const base::Value* override);
80 // TODO(aa): This seems out of place. Why is it not with the event routers for
81 // the other extension APIs?
82 scoped_ptr<extensions::BookmarkManagerPrivateDragEventRouter>
83 bookmark_manager_private_drag_event_router_;
85 // The URL this WebUI was created for.
86 GURL url_;
89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_