bluetooth: Initial JNI setup for device/bluetooth.
[chromium-blink-merge.git] / chrome / test / base / test_chrome_web_ui_controller_factory.h
blobceb4af923dbdf92f35213a1cbd9b2b0052c5399a
1 // Copyright (c) 2011 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_TEST_BASE_TEST_CHROME_WEB_UI_CONTROLLER_FACTORY_H_
6 #define CHROME_TEST_BASE_TEST_CHROME_WEB_UI_CONTROLLER_FACTORY_H_
8 #include <functional>
9 #include <map>
10 #include <string>
12 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
13 #include "content/public/browser/web_ui.h"
15 // This class replaces the ChromeWebUIFactory when the switches::kTestType flag
16 // is passed. It provides a registry to override CreateWebUIControllerForURL()
17 // by host.
18 class TestChromeWebUIControllerFactory : public ChromeWebUIControllerFactory {
19 public:
20 // Interface to create a new WebUI object.
21 class WebUIProvider {
22 public:
23 // Create and return a new WebUI object for the |web_contents| based on the
24 // |url|.
25 virtual content::WebUIController* NewWebUI(content::WebUI* web_ui,
26 const GURL& url) = 0;
28 protected:
29 virtual ~WebUIProvider();
32 typedef std::map<std::string, WebUIProvider*> FactoryOverridesMap;
34 TestChromeWebUIControllerFactory();
35 ~TestChromeWebUIControllerFactory() override;
37 // Override the creation for urls having |host| with |provider|.
38 void AddFactoryOverride(const std::string& host, WebUIProvider* provider);
40 // Remove the override for urls having |host|.
41 void RemoveFactoryOverride(const std::string& host);
43 // ChromeWebUIFactory overrides.
44 content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context,
45 const GURL& url) const override;
46 content::WebUIController* CreateWebUIControllerForURL(
47 content::WebUI* web_ui,
48 const GURL& url) const override;
50 private:
51 // Return the WebUIProvider for the |url|'s host if it exists, otherwise NULL.
52 WebUIProvider* GetWebUIProvider(Profile* profile, const GURL& url) const;
54 // Stores the mapping of host to WebUIProvider.
55 FactoryOverridesMap factory_overrides_;
57 DISALLOW_COPY_AND_ASSIGN(TestChromeWebUIControllerFactory);
60 #endif // CHROME_TEST_BASE_TEST_CHROME_WEB_UI_CONTROLLER_FACTORY_H_