Chromium Code Reviews| Index: chrome/browser/ui/webui/chrome_web_ui_factory.cc |
| diff --git a/chrome/browser/ui/webui/chrome_web_ui_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_factory.cc |
| index 71931fa327f22e02321d9aedf49a32bbfd5f4943..f1409abb800dcec01000c48f3c77ce4bf5b287a2 100644 |
| --- a/chrome/browser/ui/webui/chrome_web_ui_factory.cc |
| +++ b/chrome/browser/ui/webui/chrome_web_ui_factory.cc |
| @@ -27,6 +27,7 @@ |
| #include "chrome/browser/ui/webui/plugins_ui.h" |
| #include "chrome/browser/ui/webui/print_preview_ui.h" |
| #include "chrome/browser/ui/webui/sync_internals_ui.h" |
| +#include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" |
| #include "chrome/browser/ui/webui/textfields_ui.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/extensions/extension_constants.h" |
| @@ -217,6 +218,18 @@ static WebUIFactoryFunction GetWebUIFactoryFunction(Profile* profile, |
| return NULL; |
| } |
| +// When the test-type switch is set, return a TestType object, which should be a |
| +// subclass of Type. |
| +template<typename Type, typename TestType> |
| +struct PossibleTestSingletonTraits : public DefaultSingletonTraits<Type> { |
|
Evan Stade
2011/05/24 17:25:59
explicitly state privacy level
Lei Zhang (Do not use)
2011/05/24 18:00:06
Do you need this template? Why can't you just do t
Sheridan Rawlins
2011/05/24 20:17:22
This doesn't play nicely with the privacy/friendsh
Sheridan Rawlins
2011/05/24 20:17:22
As a derived struct of DefaultSingletonTraits, whi
Sheridan Rawlins
2011/05/25 18:29:42
As discussed in email thread, my main argument for
|
| + static Type* New() { |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) |
| + return DefaultSingletonTraits<TestType>::New(); |
| + else |
| + return DefaultSingletonTraits<Type>::New(); |
| + } |
| +}; |
| + |
| } // namespace |
| WebUI::TypeID ChromeWebUIFactory::GetWebUIType(Profile* profile, |
| @@ -286,7 +299,8 @@ void ChromeWebUIFactory::GetFaviconForURL( |
| // static |
| ChromeWebUIFactory* ChromeWebUIFactory::GetInstance() { |
| - return Singleton<ChromeWebUIFactory>::get(); |
| + return Singleton<ChromeWebUIFactory, PossibleTestSingletonTraits< |
| + ChromeWebUIFactory, TestChromeWebUIFactory> >::get(); |
| } |
| ChromeWebUIFactory::ChromeWebUIFactory() { |