blob: 273b2a18a71263150db28f00cf8f508e3474c689 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// 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/webui/session_favicon_source.h"
#include "chrome/browser/sync/glue/session_model_associator.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/common/url_constants.h"
using browser_sync::SessionModelAssociator;
SessionFaviconSource::SessionFaviconSource(Profile* profile)
: FaviconSource(profile, FaviconSource::FAVICON) {
}
SessionFaviconSource::~SessionFaviconSource() {
}
std::string SessionFaviconSource::GetSource() const {
return chrome::kChromeUISessionFaviconHost;
}
std::string SessionFaviconSource::GetMimeType(const std::string&) const {
return "image/png";
}
bool SessionFaviconSource::ShouldReplaceExistingSource() const {
// Leave the existing DataSource in place, otherwise we'll drop any pending
// requests on the floor.
return false;
}
bool SessionFaviconSource::AllowCaching() const {
// Prevent responses from being cached, otherwise session favicons won't
// update in a timely manner.
return false;
}
bool SessionFaviconSource::HandleMissingResource(const IconRequest& request) {
ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
SessionModelAssociator* associator = sync_service ?
sync_service->GetSessionModelAssociator() : NULL;
scoped_refptr<base::RefCountedMemory> response;
if (associator &&
associator->GetSyncedFaviconForPageURL(request.request_path,
&response)) {
request.callback.Run(response);
return true;
}
return false;
}
|