blob: 6d8b5cd99f78adf36d4c591c059fdecc91c4fe29 (
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
56
57
|
// 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,
chrome::kChromeUISessionFaviconHost) {
}
SessionFaviconSource::~SessionFaviconSource() {
}
void SessionFaviconSource::StartDataRequest(const std::string& path,
bool is_incognito,
int request_id) {
ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
SessionModelAssociator* associator = sync_service ?
sync_service->GetSessionModelAssociator() : NULL;
std::string favicon_data;
if (associator &&
associator->GetSyncedFaviconForPageURL(path, &favicon_data)) {
scoped_refptr<base::RefCountedString> response =
new base::RefCountedString();
response->data() = favicon_data;
SendResponse(request_id, response);
} else {
FaviconSource::StartDataRequest(path, is_incognito, request_id);
}
}
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;
}
|