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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 if (IsEnableDomDistillerSet() && | 519 if (IsEnableDomDistillerSet() && |
520 url.host() == dom_distiller::kChromeUIDomDistillerHost) { | 520 url.host() == dom_distiller::kChromeUIDomDistillerHost) { |
521 return &NewWebUI<dom_distiller::DomDistillerUi>; | 521 return &NewWebUI<dom_distiller::DomDistillerUi>; |
522 } | 522 } |
523 | 523 |
524 return NULL; | 524 return NULL; |
525 } | 525 } |
526 | 526 |
527 void RunFaviconCallbackAsync( | 527 void RunFaviconCallbackAsync( |
528 const favicon_base::FaviconResultsCallback& callback, | 528 const favicon_base::FaviconResultsCallback& callback, |
529 const std::vector<favicon_base::FaviconBitmapResult>* results) { | 529 const std::vector<favicon_base::FaviconRawBitmapResult>* results) { |
530 base::MessageLoopProxy::current()->PostTask( | 530 base::MessageLoopProxy::current()->PostTask( |
531 FROM_HERE, | 531 FROM_HERE, |
532 base::Bind(&FaviconService::FaviconResultsCallbackRunner, | 532 base::Bind(&FaviconService::FaviconResultsCallbackRunner, |
533 callback, base::Owned(results))); | 533 callback, base::Owned(results))); |
534 } | 534 } |
535 | 535 |
536 } // namespace | 536 } // namespace |
537 | 537 |
538 WebUI::TypeID ChromeWebUIControllerFactory::GetWebUIType( | 538 WebUI::TypeID ChromeWebUIControllerFactory::GetWebUIType( |
539 content::BrowserContext* browser_context, const GURL& url) const { | 539 content::BrowserContext* browser_context, const GURL& url) const { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 ExtensionWebUI::HandleChromeURLOverride(&url, profile); | 579 ExtensionWebUI::HandleChromeURLOverride(&url, profile); |
580 | 580 |
581 // All extensions but the bookmark manager get their favicon from the icons | 581 // All extensions but the bookmark manager get their favicon from the icons |
582 // part of the manifest. | 582 // part of the manifest. |
583 if (url.SchemeIs(extensions::kExtensionScheme) && | 583 if (url.SchemeIs(extensions::kExtensionScheme) && |
584 url.host() != extension_misc::kBookmarkManagerId) { | 584 url.host() != extension_misc::kBookmarkManagerId) { |
585 #if defined(ENABLE_EXTENSIONS) | 585 #if defined(ENABLE_EXTENSIONS) |
586 ExtensionWebUI::GetFaviconForURL(profile, url, callback); | 586 ExtensionWebUI::GetFaviconForURL(profile, url, callback); |
587 #else | 587 #else |
588 RunFaviconCallbackAsync( | 588 RunFaviconCallbackAsync( |
589 callback, new std::vector<favicon_base::FaviconBitmapResult>()); | 589 callback, new std::vector<favicon_base::FaviconRawBitmapResult>()); |
590 #endif | 590 #endif |
591 return; | 591 return; |
592 } | 592 } |
593 | 593 |
594 std::vector<favicon_base::FaviconBitmapResult>* favicon_bitmap_results = | 594 std::vector<favicon_base::FaviconRawBitmapResult>* favicon_bitmap_results = |
595 new std::vector<favicon_base::FaviconBitmapResult>(); | 595 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
596 | 596 |
597 for (size_t i = 0; i < scale_factors.size(); ++i) { | 597 for (size_t i = 0; i < scale_factors.size(); ++i) { |
598 scoped_refptr<base::RefCountedMemory> bitmap(GetFaviconResourceBytes( | 598 scoped_refptr<base::RefCountedMemory> bitmap(GetFaviconResourceBytes( |
599 url, scale_factors[i])); | 599 url, scale_factors[i])); |
600 if (bitmap.get() && bitmap->size()) { | 600 if (bitmap.get() && bitmap->size()) { |
601 favicon_base::FaviconBitmapResult bitmap_result; | 601 favicon_base::FaviconRawBitmapResult bitmap_result; |
602 bitmap_result.bitmap_data = bitmap; | 602 bitmap_result.bitmap_data = bitmap; |
603 // Leave |bitmap_result|'s icon URL as the default of GURL(). | 603 // Leave |bitmap_result|'s icon URL as the default of GURL(). |
604 bitmap_result.icon_type = favicon_base::FAVICON; | 604 bitmap_result.icon_type = favicon_base::FAVICON; |
605 favicon_bitmap_results->push_back(bitmap_result); | 605 favicon_bitmap_results->push_back(bitmap_result); |
606 | 606 |
607 // Assume that |bitmap| is |gfx::kFaviconSize| x |gfx::kFaviconSize| | 607 // Assume that |bitmap| is |gfx::kFaviconSize| x |gfx::kFaviconSize| |
608 // DIP. | 608 // DIP. |
609 float scale = ui::GetScaleForScaleFactor(scale_factors[i]); | 609 float scale = ui::GetScaleForScaleFactor(scale_factors[i]); |
610 int edge_pixel_size = | 610 int edge_pixel_size = |
611 static_cast<int>(gfx::kFaviconSize * scale + 0.5f); | 611 static_cast<int>(gfx::kFaviconSize * scale + 0.5f); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 #endif | 687 #endif |
688 | 688 |
689 // Android doesn't use the plugins pages. | 689 // Android doesn't use the plugins pages. |
690 if (page_url.host() == chrome::kChromeUIPluginsHost) | 690 if (page_url.host() == chrome::kChromeUIPluginsHost) |
691 return PluginsUI::GetFaviconResourceBytes(scale_factor); | 691 return PluginsUI::GetFaviconResourceBytes(scale_factor); |
692 | 692 |
693 #endif | 693 #endif |
694 | 694 |
695 return NULL; | 695 return NULL; |
696 } | 696 } |
OLD | NEW |