OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/app_list/search/common/url_icon_source.h" | 5 #include "chrome/browser/ui/app_list/search/common/url_icon_source.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 return icon_.GetRepresentation(scale); | 53 return icon_.GetRepresentation(scale); |
54 | 54 |
55 return ui::ResourceBundle::GetSharedInstance() | 55 return ui::ResourceBundle::GetSharedInstance() |
56 .GetImageSkiaNamed(default_icon_resource_id_)->GetRepresentation(scale); | 56 .GetImageSkiaNamed(default_icon_resource_id_)->GetRepresentation(scale); |
57 } | 57 } |
58 | 58 |
59 void UrlIconSource::OnURLFetchComplete( | 59 void UrlIconSource::OnURLFetchComplete( |
60 const net::URLFetcher* source) { | 60 const net::URLFetcher* source) { |
61 CHECK_EQ(icon_fetcher_.get(), source); | 61 CHECK_EQ(icon_fetcher_.get(), source); |
62 | 62 |
63 scoped_ptr<net::URLFetcher> fetcher(std::move(icon_fetcher_)); | 63 std::unique_ptr<net::URLFetcher> fetcher(std::move(icon_fetcher_)); |
64 | 64 |
65 if (!fetcher->GetStatus().is_success() || | 65 if (!fetcher->GetStatus().is_success() || |
66 fetcher->GetResponseCode() != 200) { | 66 fetcher->GetResponseCode() != 200) { |
67 return; | 67 return; |
68 } | 68 } |
69 | 69 |
70 std::string unsafe_icon_data; | 70 std::string unsafe_icon_data; |
71 fetcher->GetResponseAsString(&unsafe_icon_data); | 71 fetcher->GetResponseAsString(&unsafe_icon_data); |
72 | 72 |
73 ImageDecoder::Start(this, unsafe_icon_data); | 73 ImageDecoder::Start(this, unsafe_icon_data); |
74 } | 74 } |
75 | 75 |
76 void UrlIconSource::OnImageDecoded(const SkBitmap& decoded_image) { | 76 void UrlIconSource::OnImageDecoded(const SkBitmap& decoded_image) { |
77 icon_ = gfx::ImageSkiaOperations::CreateResizedImage( | 77 icon_ = gfx::ImageSkiaOperations::CreateResizedImage( |
78 gfx::ImageSkia::CreateFrom1xBitmap(decoded_image), | 78 gfx::ImageSkia::CreateFrom1xBitmap(decoded_image), |
79 skia::ImageOperations::RESIZE_BEST, | 79 skia::ImageOperations::RESIZE_BEST, |
80 gfx::Size(icon_size_, icon_size_)); | 80 gfx::Size(icon_size_, icon_size_)); |
81 | 81 |
82 icon_loaded_callback_.Run(); | 82 icon_loaded_callback_.Run(); |
83 } | 83 } |
84 | 84 |
85 void UrlIconSource::OnDecodeImageFailed() { | 85 void UrlIconSource::OnDecodeImageFailed() { |
86 // Failed to decode image. Do nothing and just use the default icon. | 86 // Failed to decode image. Do nothing and just use the default icon. |
87 } | 87 } |
88 | 88 |
89 } // namespace app_list | 89 } // namespace app_list |
OLD | NEW |