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

Side by Side Diff: chrome/browser/ui/webui/test_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h"
6
7 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
8 #include "content/browser/tab_contents/tab_contents.h"
9 #include "content/browser/webui/web_ui.h"
10
11 TestChromeWebUIFactory::WebUIProvider::~WebUIProvider() {
12 }
13
14 TestChromeWebUIFactory::TestChromeWebUIFactory() {
15 }
16
17 TestChromeWebUIFactory::~TestChromeWebUIFactory() {
18 }
19
20 void
Evan Stade 2011/05/24 17:25:59 wrap the args rather than the return type
Sheridan Rawlins 2011/05/24 20:17:22 Done.
21 TestChromeWebUIFactory::AddFactoryOverride(const std::string& host,
22 WebUIProvider* provider) {
23 DCHECK_EQ(size_t(0), GetInstance()->factory_overrides_.count(host));
Evan Stade 2011/05/24 17:25:59 0U rather than size_t(0)
Sheridan Rawlins 2011/05/24 20:17:22 Done.
24 GetInstance()->factory_overrides_[host] = provider;
25 }
26
27 void
28 TestChromeWebUIFactory::RemoveFactoryOverride(const std::string& host) {
29 DCHECK_EQ(size_t(1), GetInstance()->factory_overrides_.count(host));
30 GetInstance()->factory_overrides_.erase(host);
31 }
32
33 WebUI::TypeID
34 TestChromeWebUIFactory::GetWebUIType(Profile* profile, const GURL& url) const {
35 WebUIProvider* provider = GetWebUIProvider(profile, url);
36 return provider ? reinterpret_cast<WebUI::TypeID>(provider) :
37 ChromeWebUIFactory::GetWebUIType(profile, url);
38 }
39
40 WebUI*
41 TestChromeWebUIFactory::CreateWebUIForURL(TabContents* tab_contents,
42 const GURL& url) const {
43 WebUIProvider* provider = GetWebUIProvider(tab_contents->profile(), url);
44 return provider ? provider->NewWebUI(tab_contents, url) :
45 ChromeWebUIFactory::CreateWebUIForURL(tab_contents, url);
46 }
47
48 TestChromeWebUIFactory* TestChromeWebUIFactory::GetInstance() {
49 return static_cast<TestChromeWebUIFactory*>(
50 ChromeWebUIFactory::GetInstance());
51 }
52
53 TestChromeWebUIFactory::WebUIProvider*
54 TestChromeWebUIFactory::GetWebUIProvider(Profile* profile,
55 const GURL& url) const {
56 FactoryOverridesMap::const_iterator found =
57 factory_overrides_.find(url.host());
58 if (found != factory_overrides_.end()) {
Evan Stade 2011/05/24 17:25:59 no curlies
Sheridan Rawlins 2011/05/24 20:17:22 Done.
59 return found->second;
60 }
61 return NULL;
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698