| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 5 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "chrome/browser/ui/webui/omnibox/omnibox_ui.h" | 41 #include "chrome/browser/ui/webui/omnibox/omnibox_ui.h" |
| 42 #include "chrome/browser/ui/webui/options/options_ui.h" | 42 #include "chrome/browser/ui/webui/options/options_ui.h" |
| 43 #include "chrome/browser/ui/webui/performance_monitor/performance_monitor_ui.h" | 43 #include "chrome/browser/ui/webui/performance_monitor/performance_monitor_ui.h" |
| 44 #include "chrome/browser/ui/webui/plugins_ui.h" | 44 #include "chrome/browser/ui/webui/plugins_ui.h" |
| 45 #include "chrome/browser/ui/webui/predictors/predictors_ui.h" | 45 #include "chrome/browser/ui/webui/predictors/predictors_ui.h" |
| 46 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" | 46 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" |
| 47 #include "chrome/browser/ui/webui/profiler_ui.h" | 47 #include "chrome/browser/ui/webui/profiler_ui.h" |
| 48 #include "chrome/browser/ui/webui/quota_internals_ui.h" | 48 #include "chrome/browser/ui/webui/quota_internals_ui.h" |
| 49 #include "chrome/browser/ui/webui/signin_internals_ui.h" | 49 #include "chrome/browser/ui/webui/signin_internals_ui.h" |
| 50 #include "chrome/browser/ui/webui/sync_internals_ui.h" | 50 #include "chrome/browser/ui/webui/sync_internals_ui.h" |
| 51 #include "chrome/browser/ui/webui/test_chrome_web_ui_controller_factory.h" | |
| 52 #include "chrome/browser/ui/webui/tracing_ui.h" | 51 #include "chrome/browser/ui/webui/tracing_ui.h" |
| 53 #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" | 52 #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" |
| 54 #include "chrome/browser/ui/webui/version_ui.h" | 53 #include "chrome/browser/ui/webui/version_ui.h" |
| 55 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
| 56 #include "chrome/common/extensions/extension_constants.h" | 55 #include "chrome/common/extensions/extension_constants.h" |
| 57 #include "chrome/common/extensions/feature_switch.h" | 56 #include "chrome/common/extensions/feature_switch.h" |
| 58 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
| 59 #include "chrome/common/url_constants.h" | 58 #include "chrome/common/url_constants.h" |
| 60 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
| 61 #include "content/public/browser/web_ui.h" | 60 #include "content/public/browser/web_ui.h" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 #endif | 400 #endif |
| 402 #if defined(ENABLE_PRINTING) | 401 #if defined(ENABLE_PRINTING) |
| 403 if (url.host() == chrome::kChromeUIPrintHost && | 402 if (url.host() == chrome::kChromeUIPrintHost && |
| 404 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) | 403 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) |
| 405 return &NewWebUI<PrintPreviewUI>; | 404 return &NewWebUI<PrintPreviewUI>; |
| 406 #endif | 405 #endif |
| 407 | 406 |
| 408 return NULL; | 407 return NULL; |
| 409 } | 408 } |
| 410 | 409 |
| 411 // When the test-type switch is set, return a TestType object, which should be a | |
| 412 // subclass of Type. The logic is provided here in the traits class, rather than | |
| 413 // in GetInstance() so that the choice is made only once, when the Singleton is | |
| 414 // first instantiated, rather than every time GetInstance() is called. | |
| 415 template<typename Type, typename TestType> | |
| 416 struct PossibleTestSingletonTraits : public DefaultSingletonTraits<Type> { | |
| 417 static Type* New() { | |
| 418 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) | |
| 419 return DefaultSingletonTraits<TestType>::New(); | |
| 420 else | |
| 421 return DefaultSingletonTraits<Type>::New(); | |
| 422 } | |
| 423 }; | |
| 424 | |
| 425 void RunFaviconCallbackAsync( | 410 void RunFaviconCallbackAsync( |
| 426 const FaviconService::FaviconResultsCallback& callback, | 411 const FaviconService::FaviconResultsCallback& callback, |
| 427 const std::vector<history::FaviconBitmapResult>* results) { | 412 const std::vector<history::FaviconBitmapResult>* results) { |
| 428 base::MessageLoopProxy::current()->PostTask( | 413 base::MessageLoopProxy::current()->PostTask( |
| 429 FROM_HERE, | 414 FROM_HERE, |
| 430 base::Bind(&FaviconService::FaviconResultsCallbackRunner, | 415 base::Bind(&FaviconService::FaviconResultsCallbackRunner, |
| 431 callback, base::Owned(results))); | 416 callback, base::Owned(results))); |
| 432 } | 417 } |
| 433 | 418 |
| 434 } // namespace | 419 } // namespace |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 static_cast<int>(gfx::kFaviconSize * scale + 0.5f); | 497 static_cast<int>(gfx::kFaviconSize * scale + 0.5f); |
| 513 bitmap_result.pixel_size = gfx::Size(edge_pixel_size, edge_pixel_size); | 498 bitmap_result.pixel_size = gfx::Size(edge_pixel_size, edge_pixel_size); |
| 514 } | 499 } |
| 515 } | 500 } |
| 516 | 501 |
| 517 RunFaviconCallbackAsync(callback, favicon_bitmap_results); | 502 RunFaviconCallbackAsync(callback, favicon_bitmap_results); |
| 518 } | 503 } |
| 519 | 504 |
| 520 // static | 505 // static |
| 521 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { | 506 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { |
| 522 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits< | 507 return Singleton<ChromeWebUIControllerFactory>::get(); |
| 523 ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get(); | |
| 524 } | 508 } |
| 525 | 509 |
| 526 ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() { | 510 ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() { |
| 527 } | 511 } |
| 528 | 512 |
| 529 ChromeWebUIControllerFactory::~ChromeWebUIControllerFactory() { | 513 ChromeWebUIControllerFactory::~ChromeWebUIControllerFactory() { |
| 530 } | 514 } |
| 531 | 515 |
| 532 base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes( | 516 base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes( |
| 533 const GURL& page_url, ui::ScaleFactor scale_factor) const { | 517 const GURL& page_url, ui::ScaleFactor scale_factor) const { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 if (page_url.host() == chrome::kChromeUISettingsFrameHost) | 558 if (page_url.host() == chrome::kChromeUISettingsFrameHost) |
| 575 return options::OptionsUI::GetFaviconResourceBytes(scale_factor); | 559 return options::OptionsUI::GetFaviconResourceBytes(scale_factor); |
| 576 | 560 |
| 577 // Android doesn't use the plugins pages. | 561 // Android doesn't use the plugins pages. |
| 578 if (page_url.host() == chrome::kChromeUIPluginsHost) | 562 if (page_url.host() == chrome::kChromeUIPluginsHost) |
| 579 return PluginsUI::GetFaviconResourceBytes(scale_factor); | 563 return PluginsUI::GetFaviconResourceBytes(scale_factor); |
| 580 #endif | 564 #endif |
| 581 | 565 |
| 582 return NULL; | 566 return NULL; |
| 583 } | 567 } |
| OLD | NEW |