OLD | NEW |
---|---|
(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 } | |
OLD | NEW |