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

Side by Side Diff: chrome/browser/favicon/favicon_tab_helper.cc

Issue 839193002: Move ServiceAccessType into //components/keyed_service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on android Created 5 years, 11 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
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/favicon/favicon_tab_helper.h" 5 #include "chrome/browser/favicon/favicon_tab_helper.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/favicon/chrome_favicon_client.h" 8 #include "chrome/browser/favicon/chrome_favicon_client.h"
9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" 9 #include "chrome/browser/favicon/chrome_favicon_client_factory.h"
10 #include "chrome/browser/favicon/favicon_handler.h" 10 #include "chrome/browser/favicon/favicon_handler.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 113
114 void FaviconTabHelper::SaveFavicon() { 114 void FaviconTabHelper::SaveFavicon() {
115 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry(); 115 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry();
116 if (!entry || entry->GetURL().is_empty()) 116 if (!entry || entry->GetURL().is_empty())
117 return; 117 return;
118 118
119 // Make sure the page is in history, otherwise adding the favicon does 119 // Make sure the page is in history, otherwise adding the favicon does
120 // nothing. 120 // nothing.
121 HistoryService* history = HistoryServiceFactory::GetForProfile( 121 HistoryService* history = HistoryServiceFactory::GetForProfile(
122 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); 122 profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
123 if (!history) 123 if (!history)
124 return; 124 return;
125 history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle()); 125 history->AddPageNoVisitForBookmark(entry->GetURL(), entry->GetTitle());
126 126
127 FaviconService* service = FaviconServiceFactory::GetForProfile( 127 FaviconService* service = FaviconServiceFactory::GetForProfile(
128 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); 128 profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
129 if (!service) 129 if (!service)
130 return; 130 return;
131 const FaviconStatus& favicon(entry->GetFavicon()); 131 const FaviconStatus& favicon(entry->GetFavicon());
132 if (!favicon.valid || favicon.url.is_empty() || 132 if (!favicon.valid || favicon.url.is_empty() ||
133 favicon.image.IsEmpty()) { 133 favicon.image.IsEmpty()) {
134 return; 134 return;
135 } 135 }
136 service->SetFavicons( 136 service->SetFavicons(
137 entry->GetURL(), favicon.url, favicon_base::FAVICON, favicon.image); 137 entry->GetURL(), favicon.url, favicon_base::FAVICON, favicon.image);
138 } 138 }
139 139
140 void FaviconTabHelper::AddObserver(FaviconTabHelperObserver* observer) { 140 void FaviconTabHelper::AddObserver(FaviconTabHelperObserver* observer) {
141 observer_list_.AddObserver(observer); 141 observer_list_.AddObserver(observer);
142 } 142 }
143 143
144 void FaviconTabHelper::RemoveObserver(FaviconTabHelperObserver* observer) { 144 void FaviconTabHelper::RemoveObserver(FaviconTabHelperObserver* observer) {
145 observer_list_.RemoveObserver(observer); 145 observer_list_.RemoveObserver(observer);
146 } 146 }
147 147
148 int FaviconTabHelper::StartDownload(const GURL& url, int max_image_size) { 148 int FaviconTabHelper::StartDownload(const GURL& url, int max_image_size) {
149 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( 149 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
150 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); 150 profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
151 if (favicon_service && favicon_service->WasUnableToDownloadFavicon(url)) { 151 if (favicon_service && favicon_service->WasUnableToDownloadFavicon(url)) {
152 DVLOG(1) << "Skip Failed FavIcon: " << url; 152 DVLOG(1) << "Skip Failed FavIcon: " << url;
153 return 0; 153 return 0;
154 } 154 }
155 155
156 return web_contents()->DownloadImage( 156 return web_contents()->DownloadImage(
157 url, 157 url,
158 true, 158 true,
159 max_image_size, 159 max_image_size,
160 base::Bind(&FaviconTabHelper::DidDownloadFavicon,base::Unretained(this))); 160 base::Bind(&FaviconTabHelper::DidDownloadFavicon,base::Unretained(this)));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 DCHECK(web_contents()->GetController().GetActiveEntry()); 224 DCHECK(web_contents()->GetController().GetActiveEntry());
225 return web_contents()->GetController().GetActiveEntry()->GetFavicon(); 225 return web_contents()->GetController().GetActiveEntry()->GetFavicon();
226 } 226 }
227 227
228 void FaviconTabHelper::DidStartNavigationToPendingEntry( 228 void FaviconTabHelper::DidStartNavigationToPendingEntry(
229 const GURL& url, 229 const GURL& url,
230 NavigationController::ReloadType reload_type) { 230 NavigationController::ReloadType reload_type) {
231 if (reload_type != NavigationController::NO_RELOAD && 231 if (reload_type != NavigationController::NO_RELOAD &&
232 !profile_->IsOffTheRecord()) { 232 !profile_->IsOffTheRecord()) {
233 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( 233 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
234 profile_, Profile::IMPLICIT_ACCESS); 234 profile_, ServiceAccessType::IMPLICIT_ACCESS);
235 if (favicon_service) { 235 if (favicon_service) {
236 favicon_service->SetFaviconOutOfDateForPage(url); 236 favicon_service->SetFaviconOutOfDateForPage(url);
237 if (reload_type == NavigationController::RELOAD_IGNORING_CACHE) 237 if (reload_type == NavigationController::RELOAD_IGNORING_CACHE)
238 favicon_service->ClearUnableToDownloadFavicons(); 238 favicon_service->ClearUnableToDownloadFavicons();
239 } 239 }
240 } 240 }
241 } 241 }
242 242
243 void FaviconTabHelper::DidNavigateMainFrame( 243 void FaviconTabHelper::DidNavigateMainFrame(
244 const content::LoadCommittedDetails& details, 244 const content::LoadCommittedDetails& details,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 void FaviconTabHelper::DidDownloadFavicon( 287 void FaviconTabHelper::DidDownloadFavicon(
288 int id, 288 int id,
289 int http_status_code, 289 int http_status_code,
290 const GURL& image_url, 290 const GURL& image_url,
291 const std::vector<SkBitmap>& bitmaps, 291 const std::vector<SkBitmap>& bitmaps,
292 const std::vector<gfx::Size>& original_bitmap_sizes) { 292 const std::vector<gfx::Size>& original_bitmap_sizes) {
293 293
294 if (bitmaps.empty() && http_status_code == 404) { 294 if (bitmaps.empty() && http_status_code == 404) {
295 DVLOG(1) << "Failed to Download Favicon:" << image_url; 295 DVLOG(1) << "Failed to Download Favicon:" << image_url;
296 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( 296 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile(
297 profile_->GetOriginalProfile(), Profile::IMPLICIT_ACCESS); 297 profile_->GetOriginalProfile(), ServiceAccessType::IMPLICIT_ACCESS);
298 if (favicon_service) 298 if (favicon_service)
299 favicon_service->UnableToDownloadFavicon(image_url); 299 favicon_service->UnableToDownloadFavicon(image_url);
300 } 300 }
301 301
302 favicon_handler_->OnDidDownloadFavicon( 302 favicon_handler_->OnDidDownloadFavicon(
303 id, image_url, bitmaps, original_bitmap_sizes); 303 id, image_url, bitmaps, original_bitmap_sizes);
304 if (touch_icon_handler_.get()) { 304 if (touch_icon_handler_.get()) {
305 touch_icon_handler_->OnDidDownloadFavicon( 305 touch_icon_handler_->OnDidDownloadFavicon(
306 id, image_url, bitmaps, original_bitmap_sizes); 306 id, image_url, bitmaps, original_bitmap_sizes);
307 } 307 }
308 } 308 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_service_factory.cc ('k') | chrome/browser/history/android/android_history_provider_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698