| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_TEST_CHROME_WEB_UI_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_TEST_CHROME_WEB_UI_FACTORY_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_TEST_CHROME_WEB_UI_FACTORY_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_TEST_CHROME_WEB_UI_FACTORY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <functional> | 9 #include <functional> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" | 13 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" |
| 14 #include "content/browser/webui/web_ui.h" | 14 #include "content/browser/webui/web_ui.h" |
| 15 | 15 |
| 16 class GURL; | 16 class GURL; |
| 17 class Profile; | 17 class Profile; |
| 18 class TabContents; | |
| 19 | 18 |
| 20 // This class replaces the ChromeWebUIFactory when the switches::kTestType flag | 19 // This class replaces the ChromeWebUIFactory when the switches::kTestType flag |
| 21 // is passed. It provides a registry to override CreateWebUIForURL() by host. | 20 // is passed. It provides a registry to override CreateWebUIForURL() by host. |
| 22 class TestChromeWebUIFactory : public ChromeWebUIFactory { | 21 class TestChromeWebUIFactory : public ChromeWebUIFactory { |
| 23 public: | 22 public: |
| 24 // Interface to create a new WebUI object. | 23 // Interface to create a new WebUI object. |
| 25 class WebUIProvider { | 24 class WebUIProvider { |
| 26 public: | 25 public: |
| 27 // Create and return a new WebUI object for the |tab_contents| based on the | 26 // Create and return a new WebUI object for the |tab_contents| based on the |
| 28 // |url|. | 27 // |url|. |
| 29 virtual WebUI* NewWebUI(TabContents* tab_contents, | 28 virtual WebUI* NewWebUI(content::WebContents* tab_contents, |
| 30 const GURL& url) = 0; | 29 const GURL& url) = 0; |
| 31 | 30 |
| 32 protected: | 31 protected: |
| 33 virtual ~WebUIProvider(); | 32 virtual ~WebUIProvider(); |
| 34 }; | 33 }; |
| 35 | 34 |
| 36 typedef std::map<std::string, WebUIProvider*> FactoryOverridesMap; | 35 typedef std::map<std::string, WebUIProvider*> FactoryOverridesMap; |
| 37 | 36 |
| 38 // Override the creation for urls having |host| with |provider|. | 37 // Override the creation for urls having |host| with |provider|. |
| 39 static void AddFactoryOverride(const std::string& host, | 38 static void AddFactoryOverride(const std::string& host, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 // Return the WebUIProvider for the |url|'s host if it exists, otherwise NULL. | 59 // Return the WebUIProvider for the |url|'s host if it exists, otherwise NULL. |
| 61 WebUIProvider* GetWebUIProvider(Profile* profile, const GURL& url) const; | 60 WebUIProvider* GetWebUIProvider(Profile* profile, const GURL& url) const; |
| 62 | 61 |
| 63 // Stores the mapping of host to WebUIProvider. | 62 // Stores the mapping of host to WebUIProvider. |
| 64 FactoryOverridesMap factory_overrides_; | 63 FactoryOverridesMap factory_overrides_; |
| 65 | 64 |
| 66 DISALLOW_COPY_AND_ASSIGN(TestChromeWebUIFactory); | 65 DISALLOW_COPY_AND_ASSIGN(TestChromeWebUIFactory); |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 #endif // CHROME_BROWSER_UI_WEBUI_TEST_CHROME_WEB_UI_FACTORY_H_ | 68 #endif // CHROME_BROWSER_UI_WEBUI_TEST_CHROME_WEB_UI_FACTORY_H_ |
| OLD | NEW |