OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/intents/web_intent_icon_loader.h" | |
6 | |
7 #include "chrome/browser/favicon/favicon_service.h" | |
8 #include "chrome/browser/favicon/favicon_service_factory.h" | |
9 #include "chrome/browser/ui/intents/web_intent_picker_model.h" | |
10 #include "ui/gfx/favicon_size.h" | |
11 | |
12 namespace web_intents { | |
13 | |
14 IconLoader::IconLoader(Profile* profile, | |
15 WebIntentPickerModel* model) | |
16 : profile_(profile), | |
17 model_(model), | |
18 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | |
19 } | |
20 | |
21 IconLoader::~IconLoader() {} | |
22 | |
23 void IconLoader::LoadFavicon(const GURL& url) { | |
24 FaviconService* favicon_service = | |
25 FaviconServiceFactory::GetForProfile(profile_, | |
26 Profile::EXPLICIT_ACCESS); | |
27 | |
28 favicon_service->GetFaviconImageForURL( | |
29 FaviconService::FaviconForURLParams( | |
30 profile_, | |
James Hawkins
2012/10/17 03:38:39
Optional nit: Condense parameters to save rows.
| |
31 url, | |
32 history::FAVICON, | |
33 gfx::kFaviconSize, | |
34 &favicon_consumer_), | |
35 base::Bind( | |
36 &IconLoader::OnFaviconDataAvailable, | |
37 weak_ptr_factory_.GetWeakPtr(), | |
38 url)); | |
39 } | |
40 | |
41 void IconLoader::OnFaviconDataAvailable( | |
42 const GURL& url, | |
43 FaviconService::Handle, | |
44 const history::FaviconImageResult& image_result) { | |
45 if (!image_result.image.IsEmpty()) | |
46 model_->UpdateFaviconForServiceWithURL(url, image_result.image); | |
47 } | |
48 | |
49 } // namespace web_intents | |
OLD | NEW |