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

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

Issue 12089051: Revert 179271 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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_controller_factory.cc
===================================================================
--- chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc (revision 179344)
+++ chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc (working copy)
@@ -48,6 +48,7 @@
#include "chrome/browser/ui/webui/quota_internals_ui.h"
#include "chrome/browser/ui/webui/signin_internals_ui.h"
#include "chrome/browser/ui/webui/sync_internals_ui.h"
+#include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h"
#include "chrome/browser/ui/webui/tracing_ui.h"
#include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
#include "chrome/browser/ui/webui/version_ui.h"
@@ -412,6 +413,20 @@
return NULL;
}
+// When the test-type switch is set, return a TestType object, which should be a
+// subclass of Type. The logic is provided here in the traits class, rather than
+// in GetInstance() so that the choice is made only once, when the Singleton is
+// first instantiated, rather than every time GetInstance() is called.
+template<typename Type, typename TestType>
+struct PossibleTestSingletonTraits : public DefaultSingletonTraits<Type> {
+ static Type* New() {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType))
+ return DefaultSingletonTraits<TestType>::New();
+ else
+ return DefaultSingletonTraits<Type>::New();
+ }
+};
+
void RunFaviconCallbackAsync(
const FaviconService::FaviconResultsCallback& callback,
const std::vector<history::FaviconBitmapResult>* results) {
@@ -506,7 +521,8 @@
// static
ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() {
- return Singleton<ChromeWebUIControllerFactory>::get();
+ return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits<
+ ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get();
}
ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() {

Powered by Google App Engine
This is Rietveld 408576698