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

Unified Diff: chrome/browser/ui/intents/web_intent_picker_controller.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_picker_controller.cc
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc
index d25caabe711c34cc9a0c7910dd728cdeea68b612..44a63502ba50db041e7b6f4858c3e09ac314f2d8 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc
@@ -16,8 +16,6 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/extensions/webstore_installer.h"
-#include "chrome/browser/favicon/favicon_service.h"
-#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/intents/cws_intents_registry_factory.h"
#include "chrome/browser/intents/default_web_intent_service.h"
#include "chrome/browser/intents/intent_service_host.h"
@@ -33,6 +31,7 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/constrained_window_tab_helper.h"
+#include "chrome/browser/ui/intents/web_intent_icon_loader.h"
#include "chrome/browser/ui/intents/web_intent_picker.h"
#include "chrome/browser/ui/intents/web_intent_picker_model.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
@@ -65,13 +64,6 @@ const int kMaxHiddenSetupTimeMs = 200;
// Minimum amount of time to show waiting dialog, if it is shown.
const int kMinThrobberDisplayTimeMs = 800;
-
-// Gets the favicon service for the specified profile.
-FaviconService* GetFaviconService(Profile* profile) {
- return FaviconServiceFactory::GetForProfile(profile,
- Profile::EXPLICIT_ACCESS);
-}
-
// Gets the web intents registry for the specified profile.
WebIntentsRegistry* GetWebIntentsRegistry(Profile* profile) {
return WebIntentsRegistryFactory::GetForProfile(profile);
@@ -113,7 +105,6 @@ void URLFetcherTrampoline::OnURLFetchComplete(
delete source;
delete this;
}
-
class SourceWindowObserver : content::WebContentsObserver {
public:
SourceWindowObserver(content::WebContents* web_contents,
@@ -187,6 +178,7 @@ WebIntentPickerController::WebIntentPickerController(
source_intents_dispatcher_(NULL),
intents_dispatcher_(NULL),
service_tab_(NULL),
+ icon_loader_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
ALLOW_THIS_IN_INITIALIZER_LIST(timer_factory_(this)),
ALLOW_THIS_IN_INITIALIZER_LIST(dispatcher_factory_(this)) {
@@ -194,6 +186,8 @@ WebIntentPickerController::WebIntentPickerController(
#if defined(TOOLKIT_VIEWS)
cancelled_ = true;
#endif
+ icon_loader_.reset(
+ new web_intents::IconLoader(profile_, picker_model_.get()));
}
WebIntentPickerController::~WebIntentPickerController() {
@@ -613,26 +607,13 @@ void WebIntentPickerController::OnSendReturnMessage(
void WebIntentPickerController::AddServiceToModel(
const webkit_glue::WebIntentServiceData& service) {
- FaviconService* favicon_service = GetFaviconService(profile_);
picker_model_->AddInstalledService(
service.title,
service.service_url,
service.disposition);
- pending_async_count_++;
- FaviconService::Handle handle = favicon_service->GetFaviconImageForURL(
- FaviconService::FaviconForURLParams(
- profile_,
- service.service_url,
- history::FAVICON,
- gfx::kFaviconSize,
- &favicon_consumer_),
- base::Bind(
- &WebIntentPickerController::OnFaviconDataAvailable,
- weak_ptr_factory_.GetWeakPtr()));
- favicon_consumer_.SetClientData(
- favicon_service, handle, picker_model_->GetInstalledServiceCount() - 1);
+ icon_loader_->LoadFavicon(service.service_url);
}
void WebIntentPickerController::OnWebIntentServicesAvailable(
@@ -697,18 +678,6 @@ void WebIntentPickerController::RegistryCallsCompleted() {
OnIntentDataArrived();
}
-void WebIntentPickerController::OnFaviconDataAvailable(
- FaviconService::Handle handle,
- const history::FaviconImageResult& image_result) {
- size_t index = favicon_consumer_.GetClientDataForCurrentRequest();
- if (!image_result.image.IsEmpty()) {
- picker_model_->UpdateFaviconAt(index, image_result.image);
- return;
- }
-
- AsyncOperationFinished();
-}
-
void WebIntentPickerController::OnCWSIntentServicesAvailable(
const CWSIntentsRegistry::IntentExtensionList& extensions) {
ExtensionServiceInterface* extension_service =
@@ -812,7 +781,11 @@ void WebIntentPickerController::Reset() {
pending_cws_request_ = false;
// Reset picker.
+ icon_loader_.reset();
picker_model_.reset(new WebIntentPickerModel());
+ icon_loader_.reset(
+ new web_intents::IconLoader(profile_, picker_model_.get()));
+
picker_shown_ = false;
DCHECK(web_contents_);

Powered by Google App Engine
This is Rietveld 408576698