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

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

Issue 12089051: Revert 179271 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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
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
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"
51 #include "chrome/browser/ui/webui/tracing_ui.h" 52 #include "chrome/browser/ui/webui/tracing_ui.h"
52 #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h" 53 #include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
53 #include "chrome/browser/ui/webui/version_ui.h" 54 #include "chrome/browser/ui/webui/version_ui.h"
54 #include "chrome/common/chrome_switches.h" 55 #include "chrome/common/chrome_switches.h"
55 #include "chrome/common/extensions/extension_constants.h" 56 #include "chrome/common/extensions/extension_constants.h"
56 #include "chrome/common/extensions/feature_switch.h" 57 #include "chrome/common/extensions/feature_switch.h"
57 #include "chrome/common/pref_names.h" 58 #include "chrome/common/pref_names.h"
58 #include "chrome/common/url_constants.h" 59 #include "chrome/common/url_constants.h"
59 #include "content/public/browser/web_contents.h" 60 #include "content/public/browser/web_contents.h"
60 #include "content/public/browser/web_ui.h" 61 #include "content/public/browser/web_ui.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 #endif 406 #endif
406 #if defined(ENABLE_PRINTING) 407 #if defined(ENABLE_PRINTING)
407 if (url.host() == chrome::kChromeUIPrintHost && 408 if (url.host() == chrome::kChromeUIPrintHost &&
408 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) 409 !profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled))
409 return &NewWebUI<PrintPreviewUI>; 410 return &NewWebUI<PrintPreviewUI>;
410 #endif 411 #endif
411 412
412 return NULL; 413 return NULL;
413 } 414 }
414 415
416 // When the test-type switch is set, return a TestType object, which should be a
417 // subclass of Type. The logic is provided here in the traits class, rather than
418 // in GetInstance() so that the choice is made only once, when the Singleton is
419 // first instantiated, rather than every time GetInstance() is called.
420 template<typename Type, typename TestType>
421 struct PossibleTestSingletonTraits : public DefaultSingletonTraits<Type> {
422 static Type* New() {
423 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType))
424 return DefaultSingletonTraits<TestType>::New();
425 else
426 return DefaultSingletonTraits<Type>::New();
427 }
428 };
429
415 void RunFaviconCallbackAsync( 430 void RunFaviconCallbackAsync(
416 const FaviconService::FaviconResultsCallback& callback, 431 const FaviconService::FaviconResultsCallback& callback,
417 const std::vector<history::FaviconBitmapResult>* results) { 432 const std::vector<history::FaviconBitmapResult>* results) {
418 base::MessageLoopProxy::current()->PostTask( 433 base::MessageLoopProxy::current()->PostTask(
419 FROM_HERE, 434 FROM_HERE,
420 base::Bind(&FaviconService::FaviconResultsCallbackRunner, 435 base::Bind(&FaviconService::FaviconResultsCallbackRunner,
421 callback, base::Owned(results))); 436 callback, base::Owned(results)));
422 } 437 }
423 438
424 } // namespace 439 } // namespace
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 static_cast<int>(gfx::kFaviconSize * scale + 0.5f); 514 static_cast<int>(gfx::kFaviconSize * scale + 0.5f);
500 bitmap_result.pixel_size = gfx::Size(edge_pixel_size, edge_pixel_size); 515 bitmap_result.pixel_size = gfx::Size(edge_pixel_size, edge_pixel_size);
501 } 516 }
502 } 517 }
503 518
504 RunFaviconCallbackAsync(callback, favicon_bitmap_results); 519 RunFaviconCallbackAsync(callback, favicon_bitmap_results);
505 } 520 }
506 521
507 // static 522 // static
508 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() { 523 ChromeWebUIControllerFactory* ChromeWebUIControllerFactory::GetInstance() {
509 return Singleton<ChromeWebUIControllerFactory>::get(); 524 return Singleton< ChromeWebUIControllerFactory, PossibleTestSingletonTraits<
525 ChromeWebUIControllerFactory, TestChromeWebUIControllerFactory> >::get();
510 } 526 }
511 527
512 ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() { 528 ChromeWebUIControllerFactory::ChromeWebUIControllerFactory() {
513 } 529 }
514 530
515 ChromeWebUIControllerFactory::~ChromeWebUIControllerFactory() { 531 ChromeWebUIControllerFactory::~ChromeWebUIControllerFactory() {
516 } 532 }
517 533
518 base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes( 534 base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(
519 const GURL& page_url, ui::ScaleFactor scale_factor) const { 535 const GURL& page_url, ui::ScaleFactor scale_factor) const {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 if (page_url.host() == chrome::kChromeUISettingsFrameHost) 576 if (page_url.host() == chrome::kChromeUISettingsFrameHost)
561 return options::OptionsUI::GetFaviconResourceBytes(scale_factor); 577 return options::OptionsUI::GetFaviconResourceBytes(scale_factor);
562 578
563 // Android doesn't use the plugins pages. 579 // Android doesn't use the plugins pages.
564 if (page_url.host() == chrome::kChromeUIPluginsHost) 580 if (page_url.host() == chrome::kChromeUIPluginsHost)
565 return PluginsUI::GetFaviconResourceBytes(scale_factor); 581 return PluginsUI::GetFaviconResourceBytes(scale_factor);
566 #endif 582 #endif
567 583
568 return NULL; 584 return NULL;
569 } 585 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698