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 CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_
6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_
8 #include "content/common/content_export.h"
9 #include "content/public/browser/web_ui.h"
17 class WebUIController
;
19 // Interface for an object which controls which URLs are considered WebUI URLs
20 // and creates WebUIController instances for given URLs.
21 class CONTENT_EXPORT WebUIControllerFactory
{
23 virtual ~WebUIControllerFactory() {}
25 // Call to register a factory.
26 static void RegisterFactory(WebUIControllerFactory
* factory
);
28 static void UnregisterFactoryForTesting(WebUIControllerFactory
* factory
);
30 // Returns a WebUIController instance for the given URL, or nullptr if the URL
31 // doesn't correspond to a WebUI.
32 virtual WebUIController
* CreateWebUIControllerForURL(
33 WebUI
* web_ui
, const GURL
& url
) const = 0;
35 // Gets the WebUI type for the given URL. This will return kNoWebUI if the
36 // corresponding call to CreateWebUIForURL would fail, or something
37 // non-nullptr if CreateWebUIForURL would succeed.
38 virtual WebUI::TypeID
GetWebUIType(BrowserContext
* browser_context
,
39 const GURL
& url
) const = 0;
41 // Shorthand for the above, but returns a simple yes/no.
42 // See also ContentClient::HasWebUIScheme, which only checks the scheme
43 // (faster) and can be used to determine security policy.
44 virtual bool UseWebUIForURL(BrowserContext
* browser_context
,
45 const GURL
& url
) const = 0;
47 // Returns true for the subset of WebUIs that actually need WebUI bindings.
48 virtual bool UseWebUIBindingsForURL(BrowserContext
* browser_context
,
49 const GURL
& url
) const = 0;
52 } // namespace content
54 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_