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

Side by Side Diff: chrome/browser/ui/webui/test_chrome_web_ui_factory.cc

Issue 9288074: Rename WebUIFactory to WebUIControllerFactory since that's what it creates now. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: blah Created 8 years, 10 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/profiles/profile.h"
8 #include "content/public/browser/web_contents.h"
9
10 using content::WebContents;
11 using content::WebUI;
12 using content::WebUIController;
13
14 TestChromeWebUIFactory::WebUIProvider::~WebUIProvider() {
15 }
16
17 TestChromeWebUIFactory::TestChromeWebUIFactory() {
18 }
19
20 TestChromeWebUIFactory::~TestChromeWebUIFactory() {
21 }
22
23 void TestChromeWebUIFactory::AddFactoryOverride(const std::string& host,
24 WebUIProvider* provider) {
25 DCHECK_EQ(0U, GetInstance()->factory_overrides_.count(host));
26 GetInstance()->factory_overrides_[host] = provider;
27 }
28
29 void TestChromeWebUIFactory::RemoveFactoryOverride(const std::string& host) {
30 DCHECK_EQ(1U, GetInstance()->factory_overrides_.count(host));
31 GetInstance()->factory_overrides_.erase(host);
32 }
33
34 WebUI::TypeID TestChromeWebUIFactory::GetWebUIType(
35 content::BrowserContext* browser_context, const GURL& url) const {
36 Profile* profile = Profile::FromBrowserContext(browser_context);
37 WebUIProvider* provider = GetWebUIProvider(profile, url);
38 return provider ? reinterpret_cast<WebUI::TypeID>(provider) :
39 ChromeWebUIFactory::GetWebUIType(profile, url);
40 }
41
42 WebUIController* TestChromeWebUIFactory::CreateWebUIForURL(
43 content::WebUI* web_ui, const GURL& url) const {
44 Profile* profile = Profile::FromWebUI(web_ui);
45 WebUIProvider* provider = GetWebUIProvider(profile, url);
46 return provider ? provider->NewWebUI(web_ui, url) :
47 ChromeWebUIFactory::CreateWebUIForURL(web_ui, url);
48 }
49
50 TestChromeWebUIFactory* TestChromeWebUIFactory::GetInstance() {
51 return static_cast<TestChromeWebUIFactory*>(
52 ChromeWebUIFactory::GetInstance());
53 }
54
55 TestChromeWebUIFactory::WebUIProvider* TestChromeWebUIFactory::GetWebUIProvider(
56 Profile* profile, const GURL& url) const {
57 FactoryOverridesMap::const_iterator found =
58 factory_overrides_.find(url.host());
59 return (found == factory_overrides_.end()) ? NULL : found->second;
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698