Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: chrome/browser/ui/webui/chrome_web_ui_factory.cc

Issue 6992019: Allow overriding WebUIFactory when test flag is set. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment namespace end. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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() {

Powered by Google App Engine
This is Rietveld 408576698