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

Unified Diff: chrome/browser/ui/intents/web_intent_icon_loader.cc

Issue 11137024: Factoring out of FaviconLoader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/intents/web_intent_icon_loader.cc
diff --git a/chrome/browser/ui/intents/web_intent_icon_loader.cc b/chrome/browser/ui/intents/web_intent_icon_loader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ab52b7b7f7399733f1fe5f1ad7bfb5ebe058df83
--- /dev/null
+++ b/chrome/browser/ui/intents/web_intent_icon_loader.cc
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/intents/web_intent_icon_loader.h"
+
+#include "chrome/browser/favicon/favicon_service.h"
+#include "chrome/browser/favicon/favicon_service_factory.h"
+#include "chrome/browser/ui/intents/web_intent_picker_model.h"
+#include "ui/gfx/favicon_size.h"
+
+namespace web_intents {
+
+IconLoader::IconLoader(Profile* profile,
+ WebIntentPickerModel* model)
+ : profile_(profile),
+ model_(model),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
+}
+
+IconLoader::~IconLoader() {}
+
+void IconLoader::LoadFavicon(const GURL& url) {
+ FaviconService* favicon_service =
+ FaviconServiceFactory::GetForProfile(profile_,
+ Profile::EXPLICIT_ACCESS);
+
+ favicon_service->GetFaviconImageForURL(
+ FaviconService::FaviconForURLParams(
+ profile_,
James Hawkins 2012/10/17 03:38:39 Optional nit: Condense parameters to save rows.
+ url,
+ history::FAVICON,
+ gfx::kFaviconSize,
+ &favicon_consumer_),
+ base::Bind(
+ &IconLoader::OnFaviconDataAvailable,
+ weak_ptr_factory_.GetWeakPtr(),
+ url));
+}
+
+void IconLoader::OnFaviconDataAvailable(
+ const GURL& url,
+ FaviconService::Handle,
+ const history::FaviconImageResult& image_result) {
+ if (!image_result.image.IsEmpty())
+ model_->UpdateFaviconForServiceWithURL(url, image_result.image);
+}
+
+} // namespace web_intents

Powered by Google App Engine
This is Rietveld 408576698