OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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/chrome_web_ui_factory.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "chrome/browser/about_flags.h" | |
9 #include "chrome/browser/browser_process.h" | |
10 #include "chrome/browser/extensions/extension_service.h" | |
11 #include "chrome/browser/extensions/extension_web_ui.h" | |
12 #include "chrome/browser/history/history_types.h" | |
13 #include "chrome/browser/profiles/profile.h" | |
14 #include "chrome/browser/profiles/profile_manager.h" | |
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
16 #include "chrome/browser/ui/webui/about_page/about_page_ui.h" | |
17 #include "chrome/browser/ui/webui/about_ui.h" | |
18 #include "chrome/browser/ui/webui/bookmarks_ui.h" | |
19 #include "chrome/browser/ui/webui/constrained_html_ui.h" | |
20 #include "chrome/browser/ui/webui/crashes_ui.h" | |
21 #include "chrome/browser/ui/webui/devtools_ui.h" | |
22 #include "chrome/browser/ui/webui/downloads_ui.h" | |
23 #include "chrome/browser/ui/webui/edit_search_engine_dialog_ui_webui.h" | |
24 #include "chrome/browser/ui/webui/extensions/extensions_ui.h" | |
25 #include "chrome/browser/ui/webui/feedback_ui.h" | |
26 #include "chrome/browser/ui/webui/task_manager_ui.h" | |
27 #include "chrome/browser/ui/webui/flags_ui.h" | |
28 #include "chrome/browser/ui/webui/flash_ui.h" | |
29 #include "chrome/browser/ui/webui/gpu_internals_ui.h" | |
30 #include "chrome/browser/ui/webui/history_ui.h" | |
31 #include "chrome/browser/ui/webui/html_dialog_ui.h" | |
32 #include "chrome/browser/ui/webui/hung_renderer_dialog_ui.h" | |
33 #include "chrome/browser/ui/webui/media/media_internals_ui.h" | |
34 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" | |
35 #include "chrome/browser/ui/webui/network_action_predictor/network_action_predic
tor_ui.h" | |
36 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | |
37 #include "chrome/browser/ui/webui/omnibox/omnibox_ui.h" | |
38 #include "chrome/browser/ui/webui/options/options_ui.h" | |
39 #include "chrome/browser/ui/webui/options2/options_ui2.h" | |
40 #include "chrome/browser/ui/webui/plugins_ui.h" | |
41 #include "chrome/browser/ui/webui/policy_ui.h" | |
42 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" | |
43 #include "chrome/browser/ui/webui/profiler_ui.h" | |
44 #include "chrome/browser/ui/webui/quota_internals_ui.h" | |
45 #include "chrome/browser/ui/webui/sessions_ui.h" | |
46 #include "chrome/browser/ui/webui/sync_internals_ui.h" | |
47 #include "chrome/browser/ui/webui/test_chrome_web_ui_factory.h" | |
48 #include "chrome/browser/ui/webui/tracing_ui.h" | |
49 #include "chrome/browser/ui/webui/uber/uber_ui.h" | |
50 #include "chrome/browser/ui/webui/workers_ui.h" | |
51 #include "chrome/common/chrome_switches.h" | |
52 #include "chrome/common/extensions/extension_constants.h" | |
53 #include "chrome/common/pref_names.h" | |
54 #include "chrome/common/url_constants.h" | |
55 #include "content/public/browser/web_contents.h" | |
56 #include "content/public/browser/web_ui.h" | |
57 #include "googleurl/src/gurl.h" | |
58 | |
59 #if defined(OS_CHROMEOS) | |
60 #include "chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.h" | |
61 #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_ui.h" | |
62 #include "chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h" | |
63 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | |
64 #include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h" | |
65 #include "chrome/browser/ui/webui/chromeos/proxy_settings_ui.h" | |
66 #include "chrome/browser/ui/webui/chromeos/register_page_ui.h" | |
67 #include "chrome/browser/ui/webui/chromeos/sim_unlock_ui.h" | |
68 #include "chrome/browser/ui/webui/chromeos/system_info_ui.h" | |
69 #include "chrome/browser/ui/webui/active_downloads_ui.h" | |
70 #else | |
71 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" | |
72 #endif | |
73 | |
74 #if defined(USE_VIRTUAL_KEYBOARD) | |
75 #include "chrome/browser/ui/webui/keyboard_ui.h" | |
76 #endif | |
77 | |
78 #if defined(OS_WIN) | |
79 #include "chrome/browser/ui/webui/conflicts_ui.h" | |
80 #endif | |
81 | |
82 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
83 #include "chrome/browser/ui/webui/certificate_viewer_ui.h" | |
84 #endif | |
85 | |
86 #if !defined(USE_AURA) | |
87 #include "chrome/browser/ui/webui/input_window_dialog_ui.h" | |
88 #endif | |
89 | |
90 using content::WebContents; | |
91 using content::WebUI; | |
92 using content::WebUIController; | |
93 | |
94 namespace { | |
95 | |
96 // A function for creating a new WebUI. The caller owns the return value, which | |
97 // may be NULL (for example, if the URL refers to an non-existent extension). | |
98 typedef WebUIController* (*WebUIFactoryFunction)(content::WebUI* web_ui, | |
99 const GURL& url); | |
100 | |
101 // Template for defining WebUIFactoryFunction. | |
102 template<class T> | |
103 WebUIController* NewWebUI(content::WebUI* web_ui, const GURL& url) { | |
104 return new T(web_ui); | |
105 } | |
106 | |
107 // Special case for extensions. | |
108 template<> | |
109 WebUIController* NewWebUI<ExtensionWebUI>(content::WebUI* web_ui, | |
110 const GURL& url) { | |
111 return new ExtensionWebUI(web_ui, url); | |
112 } | |
113 | |
114 // Special case for older about: handlers. | |
115 template<> | |
116 WebUIController* NewWebUI<AboutUI>(content::WebUI* web_ui, const GURL& url) { | |
117 return new AboutUI(web_ui, url.host()); | |
118 } | |
119 | |
120 // Only create ExtensionWebUI for URLs that are allowed extension bindings, | |
121 // hosted by actual tabs. If tab_contents has no wrapper, it likely refers | |
122 // to another container type, like an extension background page. If there is | |
123 // no WebUI (it's not accessible when calling GetWebUIType and related | |
124 // functions) then we conservatively assume that we need a WebUI. | |
125 bool NeedsExtensionWebUI(content::WebUI* web_ui, | |
126 Profile* profile, | |
127 const GURL& url) { | |
128 ExtensionService* service = profile ? profile->GetExtensionService() : NULL; | |
129 return service && service->ExtensionBindingsAllowed(url) && | |
130 (!web_ui || | |
131 TabContentsWrapper::GetCurrentWrapperForContents( | |
132 web_ui->GetWebContents())); | |
133 } | |
134 | |
135 // Returns a function that can be used to create the right type of WebUI for a | |
136 // tab, based on its URL. Returns NULL if the URL doesn't have WebUI associated | |
137 // with it. | |
138 WebUIFactoryFunction GetWebUIFactoryFunction(content::WebUI* web_ui, | |
139 Profile* profile, | |
140 const GURL& url) { | |
141 if (NeedsExtensionWebUI(web_ui, profile, url)) | |
142 return &NewWebUI<ExtensionWebUI>; | |
143 | |
144 // This will get called a lot to check all URLs, so do a quick check of other | |
145 // schemes to filter out most URLs. | |
146 if (!url.SchemeIs(chrome::kChromeDevToolsScheme) && | |
147 !url.SchemeIs(chrome::kChromeInternalScheme) && | |
148 !url.SchemeIs(chrome::kChromeUIScheme)) { | |
149 return NULL; | |
150 } | |
151 | |
152 // Special case the new tab page. In older versions of Chrome, the new tab | |
153 // page was hosted at chrome-internal:<blah>. This might be in people's saved | |
154 // sessions or bookmarks, so we say any URL with that scheme triggers the new | |
155 // tab page. | |
156 if (url.host() == chrome::kChromeUINewTabHost || | |
157 url.SchemeIs(chrome::kChromeInternalScheme)) { | |
158 return &NewWebUI<NewTabUI>; | |
159 } | |
160 | |
161 /**************************************************************************** | |
162 * Please keep this in alphabetical order. If #ifs or special logics are | |
163 * required, add it below in the appropriate section. | |
164 ***************************************************************************/ | |
165 // We must compare hosts only since some of the Web UIs append extra stuff | |
166 // after the host name. | |
167 if (url.host() == chrome::kChromeUIBookmarksHost) | |
168 return &NewWebUI<BookmarksUI>; | |
169 // All platform builds of Chrome will need to have a cloud printing | |
170 // dialog as backup. It's just that on Chrome OS, it's the only | |
171 // print dialog. | |
172 if (url.host() == chrome::kChromeUICloudPrintResourcesHost) | |
173 return &NewWebUI<ExternalHtmlDialogUI>; | |
174 if (url.host() == chrome::kChromeUICloudPrintSetupHost) | |
175 return &NewWebUI<HtmlDialogUI>; | |
176 if (url.spec() == chrome::kChromeUIConstrainedHTMLTestURL) | |
177 return &NewWebUI<ConstrainedHtmlUI>; | |
178 if (url.host() == chrome::kChromeUICrashesHost) | |
179 return &NewWebUI<CrashesUI>; | |
180 if (url.host() == chrome::kChromeUIDevToolsHost) | |
181 return &NewWebUI<DevToolsUI>; | |
182 if (url.host() == chrome::kChromeUIDialogHost) | |
183 return &NewWebUI<ConstrainedHtmlUI>; | |
184 if (url.host() == chrome::kChromeUIDownloadsHost) | |
185 return &NewWebUI<DownloadsUI>; | |
186 if (url.host() == chrome::kChromeUIEditSearchEngineDialogHost) | |
187 return &NewWebUI<EditSearchEngineDialogUI>; | |
188 if (url.host() == chrome::kChromeUIExtensionsFrameHost) | |
189 return &NewWebUI<ExtensionsUI>; | |
190 if (url.host() == chrome::kChromeUIFeedbackHost) | |
191 return &NewWebUI<FeedbackUI>; | |
192 if (url.host() == chrome::kChromeUIFlagsHost) | |
193 return &NewWebUI<FlagsUI>; | |
194 if (url.host() == chrome::kChromeUIFlashHost) | |
195 return &NewWebUI<FlashUI>; | |
196 if (url.host() == chrome::kChromeUIGpuInternalsHost) | |
197 return &NewWebUI<GpuInternalsUI>; | |
198 if (url.host() == chrome::kChromeUIHistoryHost) | |
199 return &NewWebUI<HistoryUI>; | |
200 if (url.host() == chrome::kChromeUIHungRendererDialogHost) | |
201 return &NewWebUI<HungRendererDialogUI>; | |
202 if (url.host() == chrome::kChromeUIMediaInternalsHost) | |
203 return &NewWebUI<MediaInternalsUI>; | |
204 if (url.host() == chrome::kChromeUINetInternalsHost) | |
205 return &NewWebUI<NetInternalsUI>; | |
206 if (url.host() == chrome::kChromeUINetworkActionPredictorHost) | |
207 return &NewWebUI<NetworkActionPredictorUI>; | |
208 if (url.host() == chrome::kChromeUIOmniboxHost) | |
209 return &NewWebUI<OmniboxUI>; | |
210 if (url.host() == chrome::kChromeUIPluginsHost) | |
211 return &NewWebUI<PluginsUI>; | |
212 if (url.host() == chrome::kChromeUIProfilerHost) | |
213 return &NewWebUI<ProfilerUI>; | |
214 if (url.host() == chrome::kChromeUIQuotaInternalsHost) | |
215 return &NewWebUI<QuotaInternalsUI>; | |
216 if (url.host() == chrome::kChromeUISSLClientCertificateSelectorHost) | |
217 return &NewWebUI<ConstrainedHtmlUI>; | |
218 if (url.host() == chrome::kChromeUISettingsFrameHost) | |
219 return &NewWebUI<options2::OptionsUI>; | |
220 if (url.host() == chrome::kChromeUISessionsHost) | |
221 return &NewWebUI<SessionsUI>; | |
222 if (url.host() == chrome::kChromeUISettingsHost) | |
223 return &NewWebUI<OptionsUI>; | |
224 if (url.host() == chrome::kChromeUISyncInternalsHost) | |
225 return &NewWebUI<SyncInternalsUI>; | |
226 if (url.host() == chrome::kChromeUISyncResourcesHost) | |
227 return &NewWebUI<HtmlDialogUI>; | |
228 if (url.host() == chrome::kChromeUITaskManagerHost) | |
229 return &NewWebUI<TaskManagerUI>; | |
230 if (url.host() == chrome::kChromeUITracingHost) | |
231 return &NewWebUI<TracingUI>; | |
232 if (url.host() == chrome::kChromeUIUberFrameHost) | |
233 return &NewWebUI<UberFrameUI>; | |
234 if (url.host() == chrome::kChromeUIUberHost) | |
235 return &NewWebUI<UberUI>; | |
236 if (url.host() == chrome::kChromeUIWorkersHost) | |
237 return &NewWebUI<WorkersUI>; | |
238 | |
239 /**************************************************************************** | |
240 * OS Specific #defines | |
241 ***************************************************************************/ | |
242 #if defined(OS_WIN) | |
243 if (url.host() == chrome::kChromeUIConflictsHost) | |
244 return &NewWebUI<ConflictsUI>; | |
245 #endif | |
246 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
247 if (url.host() == chrome::kChromeUICertificateViewerHost) | |
248 return &NewWebUI<CertificateViewerUI>; | |
249 #endif | |
250 #if defined(OS_CHROMEOS) | |
251 if (url.host() == chrome::kChromeUIActiveDownloadsHost) | |
252 return &NewWebUI<ActiveDownloadsUI>; | |
253 if (url.host() == chrome::kChromeUIChooseMobileNetworkHost) | |
254 return &NewWebUI<chromeos::ChooseMobileNetworkUI>; | |
255 if (url.host() == chrome::kChromeUIImageBurnerHost) | |
256 return &NewWebUI<ImageBurnUI>; | |
257 if (url.host() == chrome::kChromeUIKeyboardOverlayHost) | |
258 return &NewWebUI<KeyboardOverlayUI>; | |
259 if (url.host() == chrome::kChromeUIMobileSetupHost) | |
260 return &NewWebUI<MobileSetupUI>; | |
261 if (url.host() == chrome::kChromeUIOobeHost) | |
262 return &NewWebUI<chromeos::OobeUI>; | |
263 if (url.host() == chrome::kChromeUIProxySettingsHost) | |
264 return &NewWebUI<chromeos::ProxySettingsUI>; | |
265 if (url.host() == chrome::kChromeUIRegisterPageHost) | |
266 return &NewWebUI<RegisterPageUI>; | |
267 if (url.host() == chrome::kChromeUISimUnlockHost) | |
268 return &NewWebUI<chromeos::SimUnlockUI>; | |
269 if (url.host() == chrome::kChromeUISystemInfoHost) | |
270 return &NewWebUI<SystemInfoUI>; | |
271 if (url.host() == chrome::kChromeUIAboutPageFrameHost) | |
272 return &NewWebUI<AboutPageUI>; | |
273 #endif // defined(OS_CHROMEOS) | |
274 | |
275 /**************************************************************************** | |
276 * Other #defines and special logics. | |
277 ***************************************************************************/ | |
278 #if defined(ENABLE_CONFIGURATION_POLICY) | |
279 if (url.host() == chrome::kChromeUIPolicyHost) | |
280 return &NewWebUI<PolicyUI>; | |
281 #endif | |
282 #if defined(USE_VIRTUAL_KEYBOARD) | |
283 if (url.host() == chrome::kChromeUIKeyboardHost) | |
284 return &NewWebUI<KeyboardUI>; | |
285 #endif | |
286 | |
287 #if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA) | |
288 if (url.host() == chrome::kChromeUICollectedCookiesHost || | |
289 url.host() == chrome::kChromeUIHttpAuthHost || | |
290 url.host() == chrome::kChromeUITabModalConfirmDialogHost) { | |
291 return &NewWebUI<ConstrainedHtmlUI>; | |
292 } | |
293 #endif | |
294 | |
295 #if !defined(USE_AURA) | |
296 if (url.host() == chrome::kChromeUIInputWindowDialogHost) | |
297 return &NewWebUI<InputWindowDialogUI>; | |
298 #endif | |
299 | |
300 if (url.host() == chrome::kChromeUIPrintHost && | |
301 !g_browser_process->local_state()->GetBoolean( | |
302 prefs::kPrintPreviewDisabled)) { | |
303 return &NewWebUI<PrintPreviewUI>; | |
304 } | |
305 | |
306 #if !defined(OS_CHROMEOS) | |
307 if (url.host() == chrome::kChromeUISyncPromoHost) { | |
308 // If the sync promo page is enabled then use the sync promo WebUI otherwise | |
309 // use the NTP WebUI. We don't want to return NULL if the sync promo page | |
310 // is disabled because the page can be disabled mid-flight (for example, | |
311 // if sync login finishes). | |
312 if (SyncPromoUI::ShouldShowSyncPromo(profile)) | |
313 return &NewWebUI<SyncPromoUI>; | |
314 else | |
315 return &NewWebUI<NewTabUI>; | |
316 } | |
317 #endif | |
318 | |
319 if (url.host() == chrome::kChromeUIChromeURLsHost || | |
320 url.host() == chrome::kChromeUICreditsHost || | |
321 url.host() == chrome::kChromeUIDNSHost || | |
322 url.host() == chrome::kChromeUIHistogramsHost || | |
323 url.host() == chrome::kChromeUIMemoryHost || | |
324 url.host() == chrome::kChromeUIMemoryRedirectHost || | |
325 url.host() == chrome::kChromeUIStatsHost || | |
326 url.host() == chrome::kChromeUITaskManagerHost || | |
327 url.host() == chrome::kChromeUITermsHost || | |
328 url.host() == chrome::kChromeUIVersionHost | |
329 #if defined(USE_TCMALLOC) | |
330 || url.host() == chrome::kChromeUITCMallocHost | |
331 #endif | |
332 #if defined(OS_LINUX) || defined(OS_OPENBSD) | |
333 || url.host() == chrome::kChromeUILinuxProxyConfigHost | |
334 || url.host() == chrome::kChromeUISandboxHost | |
335 #endif | |
336 #if defined(OS_CHROMEOS) | |
337 || url.host() == chrome::kChromeUICryptohomeHost | |
338 || url.host() == chrome::kChromeUIDiscardsHost | |
339 || url.host() == chrome::kChromeUINetworkHost | |
340 || url.host() == chrome::kChromeUIOSCreditsHost | |
341 #endif | |
342 ) { | |
343 return &NewWebUI<AboutUI>; | |
344 } | |
345 | |
346 DLOG(WARNING) << "Unknown WebUI:" << url; | |
347 return NULL; | |
348 } | |
349 | |
350 // When the test-type switch is set, return a TestType object, which should be a | |
351 // subclass of Type. The logic is provided here in the traits class, rather than | |
352 // in GetInstance() so that the choice is made only once, when the Singleton is | |
353 // first instantiated, rather than every time GetInstance() is called. | |
354 template<typename Type, typename TestType> | |
355 struct PossibleTestSingletonTraits : public DefaultSingletonTraits<Type> { | |
356 static Type* New() { | |
357 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) | |
358 return DefaultSingletonTraits<TestType>::New(); | |
359 else | |
360 return DefaultSingletonTraits<Type>::New(); | |
361 } | |
362 }; | |
363 | |
364 } // namespace | |
365 | |
366 WebUI::TypeID ChromeWebUIFactory::GetWebUIType( | |
367 content::BrowserContext* browser_context, const GURL& url) const { | |
368 Profile* profile = Profile::FromBrowserContext(browser_context); | |
369 WebUIFactoryFunction function = GetWebUIFactoryFunction(NULL, profile, url); | |
370 return function ? reinterpret_cast<WebUI::TypeID>(function) : WebUI::kNoWebUI; | |
371 } | |
372 | |
373 bool ChromeWebUIFactory::UseWebUIForURL( | |
374 content::BrowserContext* browser_context, const GURL& url) const { | |
375 return GetWebUIType(browser_context, url) != WebUI::kNoWebUI; | |
376 } | |
377 | |
378 bool ChromeWebUIFactory::UseWebUIBindingsForURL( | |
379 content::BrowserContext* browser_context, const GURL& url) const { | |
380 // Extensions are rendered via WebUI in tabs, but don't actually need WebUI | |
381 // bindings (see the ExtensionWebUI constructor). | |
382 return !NeedsExtensionWebUI(NULL, | |
383 Profile::FromBrowserContext(browser_context), | |
384 url) && | |
385 UseWebUIForURL(browser_context, url); | |
386 } | |
387 | |
388 bool ChromeWebUIFactory::HasWebUIScheme(const GURL& url) const { | |
389 return url.SchemeIs(chrome::kChromeDevToolsScheme) || | |
390 url.SchemeIs(chrome::kChromeInternalScheme) || | |
391 url.SchemeIs(chrome::kChromeUIScheme); | |
392 } | |
393 | |
394 bool ChromeWebUIFactory::IsURLAcceptableForWebUI( | |
395 content::BrowserContext* browser_context, | |
396 const GURL& url) const { | |
397 return UseWebUIForURL(browser_context, url) || | |
398 // javacsript: URLs are allowed to run in Web UI pages | |
399 url.SchemeIs(chrome::kJavaScriptScheme) || | |
400 // It's possible to load about:blank in a Web UI renderer. | |
401 // See http://crbug.com/42547 | |
402 url.spec() == chrome::kAboutBlankURL || | |
403 // Chrome URLs crash, kill, hang, and shorthang are allowed. | |
404 url == GURL(chrome::kChromeUICrashURL) || | |
405 url == GURL(chrome::kChromeUIKillURL) || | |
406 url == GURL(chrome::kChromeUIHangURL) || | |
407 url == GURL(chrome::kChromeUIShorthangURL); | |
408 } | |
409 | |
410 WebUIController* ChromeWebUIFactory::CreateWebUIForURL( | |
411 content::WebUI* web_ui, | |
412 const GURL& url) const { | |
413 Profile* profile = Profile::FromWebUI(web_ui); | |
414 WebUIFactoryFunction function = GetWebUIFactoryFunction(web_ui, | |
415 profile, url); | |
416 if (!function) | |
417 return NULL; | |
418 | |
419 return (*function)(web_ui, url); | |
420 } | |
421 | |
422 void ChromeWebUIFactory::GetFaviconForURL( | |
423 Profile* profile, | |
424 FaviconService::GetFaviconRequest* request, | |
425 const GURL& page_url) const { | |
426 // All extensions but the bookmark manager get their favicon from the icons | |
427 // part of the manifest. | |
428 if (page_url.SchemeIs(chrome::kExtensionScheme) && | |
429 page_url.host() != extension_misc::kBookmarkManagerId) { | |
430 ExtensionWebUI::GetFaviconForURL(profile, request, page_url); | |
431 } else { | |
432 history::FaviconData favicon; | |
433 favicon.image_data = scoped_refptr<RefCountedMemory>( | |
434 GetFaviconResourceBytes(page_url)); | |
435 favicon.known_icon = favicon.image_data.get() != NULL && | |
436 favicon.image_data->size() > 0; | |
437 favicon.icon_type = history::FAVICON; | |
438 request->ForwardResultAsync(request->handle(), favicon); | |
439 } | |
440 } | |
441 | |
442 // static | |
443 ChromeWebUIFactory* ChromeWebUIFactory::GetInstance() { | |
444 return Singleton< ChromeWebUIFactory, PossibleTestSingletonTraits< | |
445 ChromeWebUIFactory, TestChromeWebUIFactory> >::get(); | |
446 } | |
447 | |
448 ChromeWebUIFactory::ChromeWebUIFactory() { | |
449 } | |
450 | |
451 ChromeWebUIFactory::~ChromeWebUIFactory() { | |
452 } | |
453 | |
454 RefCountedMemory* ChromeWebUIFactory::GetFaviconResourceBytes( | |
455 const GURL& page_url) const { | |
456 // The bookmark manager is a chrome extension, so we have to check for it | |
457 // before we check for extension scheme. | |
458 if (page_url.host() == extension_misc::kBookmarkManagerId) | |
459 return BookmarksUI::GetFaviconResourceBytes(); | |
460 | |
461 // The extension scheme is handled in GetFaviconForURL. | |
462 if (page_url.SchemeIs(chrome::kExtensionScheme)) { | |
463 NOTREACHED(); | |
464 return NULL; | |
465 } | |
466 | |
467 if (!HasWebUIScheme(page_url)) | |
468 return NULL; | |
469 | |
470 #if defined(OS_WIN) | |
471 if (page_url.host() == chrome::kChromeUIConflictsHost) | |
472 return ConflictsUI::GetFaviconResourceBytes(); | |
473 #endif | |
474 | |
475 if (page_url.host() == chrome::kChromeUICrashesHost) | |
476 return CrashesUI::GetFaviconResourceBytes(); | |
477 | |
478 if (page_url.host() == chrome::kChromeUIDownloadsHost) | |
479 return DownloadsUI::GetFaviconResourceBytes(); | |
480 | |
481 if (page_url.host() == chrome::kChromeUIHistoryHost) | |
482 return HistoryUI::GetFaviconResourceBytes(); | |
483 | |
484 if (page_url.host() == chrome::kChromeUIFlagsHost) | |
485 return FlagsUI::GetFaviconResourceBytes(); | |
486 | |
487 if (page_url.host() == chrome::kChromeUISessionsHost) | |
488 return SessionsUI::GetFaviconResourceBytes(); | |
489 | |
490 if (page_url.host() == chrome::kChromeUIFlashHost) | |
491 return FlashUI::GetFaviconResourceBytes(); | |
492 | |
493 if (page_url.host() == chrome::kChromeUISettingsHost) | |
494 return OptionsUI::GetFaviconResourceBytes(); | |
495 | |
496 if (page_url.host() == chrome::kChromeUISettingsFrameHost) | |
497 return options2::OptionsUI::GetFaviconResourceBytes(); | |
498 | |
499 if (page_url.host() == chrome::kChromeUIPluginsHost) | |
500 return PluginsUI::GetFaviconResourceBytes(); | |
501 | |
502 return NULL; | |
503 } | |
OLD | NEW |