| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/fallback_icon_source.h" | 5 #include "chrome/browser/ui/webui/fallback_icon_source.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| 11 #include "chrome/browser/search/instant_io_context.h" | 11 #include "chrome/browser/search/instant_io_context.h" |
| 12 #include "chrome/common/favicon/fallback_icon_url_parser.h" | 12 #include "chrome/common/favicon/fallback_icon_url_parser.h" |
| 13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 14 #include "grit/platform_locale_settings.h" | 14 #include "grit/platform_locale_settings.h" |
| 15 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/gfx/favicon_size.h" | 17 #include "ui/gfx/favicon_size.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 FallbackIconSource::FallbackIconSource() { | 20 FallbackIconSource::FallbackIconSource() { |
| 21 std::vector<std::string> font_list; | 21 std::vector<std::string> font_list; |
| 22 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 23 font_list.push_back("Noto Sans"); | 23 font_list.push_back("Noto Sans"); |
| 24 #elif defined(OS_IOS) | 24 #elif defined(OS_IOS) |
| 25 font_list.push_back("Helvetica Neue"); | 25 font_list.push_back("Helvetica Neue"); |
| 26 #else | 26 #else |
| 27 font_list.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY)); | 27 font_list.push_back(l10n_util::GetStringUTF8(IDS_SANS_SERIF_FONT_FAMILY)); |
| 28 #endif | 28 #endif |
| 29 fallback_icon_service_.reset( | 29 fallback_icon_service_.reset(new FallbackIconService(font_list)); |
| 30 new favicon_base::FallbackIconService(font_list)); | |
| 31 } | 30 } |
| 32 | 31 |
| 33 FallbackIconSource::~FallbackIconSource() { | 32 FallbackIconSource::~FallbackIconSource() { |
| 34 } | 33 } |
| 35 | 34 |
| 36 std::string FallbackIconSource::GetSource() const { | 35 std::string FallbackIconSource::GetSource() const { |
| 37 return chrome::kChromeUIFallbackIconHost; | 36 return chrome::kChromeUIFallbackIconHost; |
| 38 } | 37 } |
| 39 | 38 |
| 40 void FallbackIconSource::StartDataRequest( | 39 void FallbackIconSource::StartDataRequest( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return URLDataSource::ShouldServiceRequest(request); | 77 return URLDataSource::ShouldServiceRequest(request); |
| 79 } | 78 } |
| 80 | 79 |
| 81 void FallbackIconSource::SendDefaultResponse( | 80 void FallbackIconSource::SendDefaultResponse( |
| 82 const content::URLDataSource::GotDataCallback& callback) { | 81 const content::URLDataSource::GotDataCallback& callback) { |
| 83 std::vector<unsigned char> bitmap_data = | 82 std::vector<unsigned char> bitmap_data = |
| 84 fallback_icon_service_->RenderFallbackIconBitmap( | 83 fallback_icon_service_->RenderFallbackIconBitmap( |
| 85 GURL(), gfx::kFaviconSize, favicon_base::FallbackIconStyle()); | 84 GURL(), gfx::kFaviconSize, favicon_base::FallbackIconStyle()); |
| 86 callback.Run(base::RefCountedBytes::TakeVector(&bitmap_data)); | 85 callback.Run(base::RefCountedBytes::TakeVector(&bitmap_data)); |
| 87 } | 86 } |
| OLD | NEW |