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

Side by Side Diff: components/favicon/core/favicon_driver_impl.cc

Issue 1415543002: Remove redundant FaviconDriverImpl::large_icon_handler_ on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@initial_simplify
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « components/favicon/core/favicon_driver_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/favicon/core/favicon_driver_impl.h" 5 #include "components/favicon/core/favicon_driver_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 FaviconDriverImpl::FaviconDriverImpl(FaviconService* favicon_service, 44 FaviconDriverImpl::FaviconDriverImpl(FaviconService* favicon_service,
45 history::HistoryService* history_service, 45 history::HistoryService* history_service,
46 bookmarks::BookmarkModel* bookmark_model) 46 bookmarks::BookmarkModel* bookmark_model)
47 : favicon_service_(favicon_service), 47 : favicon_service_(favicon_service),
48 history_service_(history_service), 48 history_service_(history_service),
49 bookmark_model_(bookmark_model) { 49 bookmark_model_(bookmark_model) {
50 favicon_handler_.reset(new FaviconHandler( 50 favicon_handler_.reset(new FaviconHandler(
51 favicon_service_, this, kEnableTouchIcon ? FaviconHandler::LARGEST_FAVICON 51 favicon_service_, this, kEnableTouchIcon ? FaviconHandler::LARGEST_FAVICON
52 : FaviconHandler::FAVICON)); 52 : FaviconHandler::FAVICON));
53 if (kEnableTouchIcon) { 53 if (kEnableTouchIcon || IsIconNTPEnabled()) {
54 touch_icon_handler_.reset(new FaviconHandler( 54 touch_icon_handler_.reset(new FaviconHandler(
55 favicon_service_, this, FaviconHandler::LARGEST_TOUCH)); 55 favicon_service_, this, FaviconHandler::LARGEST_TOUCH));
56 } 56 }
57 if (IsIconNTPEnabled()) {
58 large_icon_handler_.reset(new FaviconHandler(
59 favicon_service_, this, FaviconHandler::LARGEST_TOUCH));
60 }
61 } 57 }
62 58
63 FaviconDriverImpl::~FaviconDriverImpl() { 59 FaviconDriverImpl::~FaviconDriverImpl() {
64 } 60 }
65 61
66 void FaviconDriverImpl::FetchFavicon(const GURL& url) { 62 void FaviconDriverImpl::FetchFavicon(const GURL& url) {
67 favicon_handler_->FetchFavicon(url); 63 favicon_handler_->FetchFavicon(url);
68 if (touch_icon_handler_.get()) 64 if (touch_icon_handler_.get())
69 touch_icon_handler_->FetchFavicon(url); 65 touch_icon_handler_->FetchFavicon(url);
70 if (large_icon_handler_.get())
71 large_icon_handler_->FetchFavicon(url);
72 } 66 }
73 67
74 void FaviconDriverImpl::DidDownloadFavicon( 68 void FaviconDriverImpl::DidDownloadFavicon(
75 int id, 69 int id,
76 int http_status_code, 70 int http_status_code,
77 const GURL& image_url, 71 const GURL& image_url,
78 const std::vector<SkBitmap>& bitmaps, 72 const std::vector<SkBitmap>& bitmaps,
79 const std::vector<gfx::Size>& original_bitmap_sizes) { 73 const std::vector<gfx::Size>& original_bitmap_sizes) {
80 if (bitmaps.empty() && http_status_code == 404) { 74 if (bitmaps.empty() && http_status_code == 404) {
81 DVLOG(1) << "Failed to Download Favicon:" << image_url; 75 DVLOG(1) << "Failed to Download Favicon:" << image_url;
82 if (favicon_service_) 76 if (favicon_service_)
83 favicon_service_->UnableToDownloadFavicon(image_url); 77 favicon_service_->UnableToDownloadFavicon(image_url);
84 } 78 }
85 79
86 favicon_handler_->OnDidDownloadFavicon(id, image_url, bitmaps, 80 favicon_handler_->OnDidDownloadFavicon(id, image_url, bitmaps,
87 original_bitmap_sizes); 81 original_bitmap_sizes);
88 if (touch_icon_handler_.get()) { 82 if (touch_icon_handler_.get()) {
89 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, bitmaps, 83 touch_icon_handler_->OnDidDownloadFavicon(id, image_url, bitmaps,
90 original_bitmap_sizes); 84 original_bitmap_sizes);
91 } 85 }
92 if (large_icon_handler_.get()) {
93 large_icon_handler_->OnDidDownloadFavicon(id, image_url, bitmaps,
94 original_bitmap_sizes);
95 }
96 } 86 }
97 87
98 bool FaviconDriverImpl::IsBookmarked(const GURL& url) { 88 bool FaviconDriverImpl::IsBookmarked(const GURL& url) {
99 return bookmark_model_ && bookmark_model_->IsBookmarked(url); 89 return bookmark_model_ && bookmark_model_->IsBookmarked(url);
100 } 90 }
101 91
102 void FaviconDriverImpl::OnFaviconAvailable(const GURL& page_url, 92 void FaviconDriverImpl::OnFaviconAvailable(const GURL& page_url,
103 const GURL& icon_url, 93 const GURL& icon_url,
104 const gfx::Image& image, 94 const gfx::Image& image,
105 bool is_active_favicon) { 95 bool is_active_favicon) {
(...skipping 18 matching lines...) Expand all
124 } 114 }
125 if (!image.IsEmpty()) 115 if (!image.IsEmpty())
126 NotifyFaviconAvailable(image); 116 NotifyFaviconAvailable(image);
127 } 117 }
128 118
129 bool FaviconDriverImpl::HasPendingTasksForTest() { 119 bool FaviconDriverImpl::HasPendingTasksForTest() {
130 if (favicon_handler_->HasPendingTasksForTest()) 120 if (favicon_handler_->HasPendingTasksForTest())
131 return true; 121 return true;
132 if (touch_icon_handler_ && touch_icon_handler_->HasPendingTasksForTest()) 122 if (touch_icon_handler_ && touch_icon_handler_->HasPendingTasksForTest())
133 return true; 123 return true;
134 if (large_icon_handler_ && large_icon_handler_->HasPendingTasksForTest())
135 return true;
136 return false; 124 return false;
137 } 125 }
138 126
139 bool FaviconDriverImpl::WasUnableToDownloadFavicon(const GURL& url) { 127 bool FaviconDriverImpl::WasUnableToDownloadFavicon(const GURL& url) {
140 return favicon_service_ && favicon_service_->WasUnableToDownloadFavicon(url); 128 return favicon_service_ && favicon_service_->WasUnableToDownloadFavicon(url);
141 } 129 }
142 130
143 void FaviconDriverImpl::SetFaviconOutOfDateForPage(const GURL& url, 131 void FaviconDriverImpl::SetFaviconOutOfDateForPage(const GURL& url,
144 bool force_reload) { 132 bool force_reload) {
145 if (favicon_service_) { 133 if (favicon_service_) {
146 favicon_service_->SetFaviconOutOfDateForPage(url); 134 favicon_service_->SetFaviconOutOfDateForPage(url);
147 if (force_reload) 135 if (force_reload)
148 favicon_service_->ClearUnableToDownloadFavicons(); 136 favicon_service_->ClearUnableToDownloadFavicons();
149 } 137 }
150 } 138 }
151 139
152 void FaviconDriverImpl::OnUpdateFaviconURL( 140 void FaviconDriverImpl::OnUpdateFaviconURL(
153 const GURL& page_url, 141 const GURL& page_url,
154 const std::vector<FaviconURL>& candidates) { 142 const std::vector<FaviconURL>& candidates) {
155 DCHECK(!candidates.empty()); 143 DCHECK(!candidates.empty());
156 favicon_handler_->OnUpdateFaviconURL(page_url, candidates); 144 favicon_handler_->OnUpdateFaviconURL(page_url, candidates);
157 if (touch_icon_handler_.get()) 145 if (touch_icon_handler_.get())
158 touch_icon_handler_->OnUpdateFaviconURL(page_url, candidates); 146 touch_icon_handler_->OnUpdateFaviconURL(page_url, candidates);
159 if (large_icon_handler_.get())
160 large_icon_handler_->OnUpdateFaviconURL(page_url, candidates);
161 } 147 }
162 148
163 } // namespace favicon 149 } // namespace favicon
OLDNEW
« no previous file with comments | « components/favicon/core/favicon_driver_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698